---
title: "Generate chat completions in OpenAI format"
method: POST
path: "/ai/openai/chat/completions"
---

# Generate chat completions in OpenAI format

`POST /ai/openai/chat/completions`

Processes a conversation and returns an AI-generated response in OpenAI-compatible format. Consumes 5 credits per request.

## Request body

- ChatCompletionRequestOpenAI
  - `allow_clarification_query` boolean — Whether the AI can ask for clarification when the query is ambiguous
  - `generate_related_questions` integer — Adds AI generated related questions to use as follow up questions
  - `inline_citations` boolean — Adds inline citation document references in the payload metadata
  - `messages` object[], required — Array of messages in the conversation history
    - `role` 'user' | 'assistant' | 'system', required — The role of the message author
    - `content` string, required — The content of the message
  - `response_format` string — Text format for the response. Values accepted are 'markdown' and 'plaintext'.
  - `stream` boolean — Stream the response through the API
  - `verbosity` string — Controls the length and detail level of the AI-generated response. Values accepted are 'succinct', 'balanced', and 'verbose'.

## Response `200`

Default response

- object
  - `choices` ChatCompletionResponseChoiceOpenAI[], required — Array of completion choices
    - `finish_reason` string, required — Reason the model stopped generating (e.g., 'stop')
    - `index` integer, required — Index of the choice in the array
    - `message` object, required — The message output by the model
      - `role` string, required — The role of the message author
      - `content` string, required — The content of the message
  - `created` integer, required — Unix timestamp when the completion was created
  - `id` string, required — Unique identifier for the completion request
  - `metadata` object — Additional metadata about the completion
    - `charts` ChartSource[] — Chart data referenced in the response
    - `related_questions` string[] — Follow-up questions related to the original query
    - `sources` StandardSource[] — Sources used to construct the response content. If using inline citations, sources will include citationIds associated with the response citations.
    - `status` string, required — Current status of the completion request
    - `trace_id` string, byte, required — Unique identifier for tracing the request
  - `model` string, required — Model used for the completion
  - `object` string, required — Type of object returned, always 'chat.completion'

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `500` — Internal Server Error

---

[API](https://skmtc.net/messari/apis/messari-api-deep-research-v1.md) · [All operations](https://skmtc.net/messari/apis/messari-api-deep-research-v1/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/messari/messari-api-deep-research-v1/revisions/af35b9757e14/schema)
