---
title: "Generate chat completions with Messari AI"
method: POST
path: "/ai/v2/chat/completions"
---

# Generate chat completions with Messari AI

`POST /ai/v2/chat/completions`

## Request

- Base URL: `https://api.messari.io`
- URL: `https://api.messari.io/ai/v2/chat/completions`
- Auth: API key in header `X-Messari-API-Key`
- TypeScript: <https://skmtc.dev/messari/apis/messari-api-deep-research-v1/docs/ai/v2/chat/completions/post.ts> (a function with typed inputs; its response is checked against the schema)

Processes a conversation and returns an AI-generated response with Messari's standard format. Consumes 5 credits per request.

## Request body

- ChatCompletionRequest
  - `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` ChatCompletionMessage[], 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
  - `data` ChatCompletionResponse, required
    - `messages` ChatCompletionResponseMessage[], required: Array of response messages from the assistant
  - `error` string
  - `metadata` ChatCompletionResponseMetadataV2
    - `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

## Other responses

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

---

[API](https://skmtc.dev/messari/apis/messari-api-deep-research-v1.md) - [All operations](https://skmtc.dev/messari/apis/messari-api-deep-research-v1/llms.txt) - [OpenAPI document](https://skmtc.dev/messari/apis/messari-api-deep-research-v1/revisions/af35b9757e14?raw)
