/chat/completions

Create model responses for chat conversations. This is the primary endpoint for interactive AI applications.

POST
/v1/chat/completions

Creates a model response for the given chat conversation.

Request Body

modelID of the model to use (required)
messagesList of messages comprising the conversation (required)
temperatureSampling temperature 0-2 (default: 1). Higher values = more random
max_tokensMaximum tokens to generate
streamStream response using server-sent events (default: false)
top_pNucleus sampling threshold 0-1 (alternative to temperature)
toolsList of tools (functions) the model may call
tool_choiceControl tool usage: 'auto', 'none', or specific tool
reasoningThinking (reasoning) control: {"effort": "low"} sets the level, {"max_tokens": 2000} caps thinking tokens, {"enabled": false} turns it off. Supported models and defaults: see Reasoning Control
Request Body
{
  "model": "your-model",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 1000,
  "reasoning": {"effort": "low"},
  "stream": false
}

Response

Returns a chat completion object with choices, usage metrics, and finish reason.

Response
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1677858242,
  "model": "your-model",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 12,
    "total_tokens": 32,
    "completion_tokens_details": {
      "reasoning_tokens": 0
    }
  }
}

On reasoning models the thinking arrives in message.reasoning_content (delta.reasoning_content when streaming) and its token count in usage.completion_tokens_details.reasoning_tokens. Thinking tokens are part of completion_tokens and bill at the output rate.