Skip to main content
Version: 2.0

Create a chat completion

POST 

/v2/llms/chat/completions

Creates a chat completion for a multi-turn chat through an OpenAI-compatible interface. Applications built for the OpenAI Chat Completions format can use the platform's language models with minimal changes to existing tools or code.

Use this endpoint for interactive chat experiences with context-aware responses, streaming output, and token usage tracking.

The request includes a series of chat messages and optional parameters that control the behavior and structure of the model response. The request body must include the messages parameter. This is an array of message objects (role, content) that represents the full conversation so far.

Streaming responses​

If the stream parameter is set to true, the response arrives as a series of text/event-stream parts (also known as chunks). Each chunk includes a delta field with the incremental message update.

Finish reason​

Each choice has a finish_reason. stop means the model finished, and length means it ran out of output tokens and the content is incomplete. A json_schema response that is cut off always reports length. Other values can appear. A streamed response carries it on its last chunk. To allow a longer output, set max_tokens in the request body.

Example request​

This example sends a simple chat conversation to the API, asking the model for the capital of France. The request includes a system message, a user message, and a temperature setting for response variability.

{
"model": "chat-model-001","messages": [{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "What is the capital of France?" }
],
"temperature": 0.7,
"stream": false
}

Example response​

The response includes the model's assistant reply, along with token usage statistics. In this example, the model returns a direct answer to a user question.

{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1712454830,
"model": "chat-model-001",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 21,
"completion_tokens": 9,
"total_tokens": 30
}
}

Request​

Responses​

A chat completion