Skip to main content
POST
Chat completions
Create a chat completion. Supports streaming, tool calling, and MCP server integration across all providers.

Authenticate

Use an API key in the Authorization header.

Request body

string
required
Model ID to use for completion. See available chat models for the full list.
array
required
Conversation history as an array of message objects.
boolean
default:"false"
Enable Server-Sent Events streaming for the response.
number
Sampling temperature between 0 and 2. Higher values make output more random.
integer
Maximum tokens to generate in the completion.
array
List of tools the model may call. Supports OpenAI function tools.
string | object
Controls tool calling. Options: auto, none, required, or a specific tool.
array
MCP server addresses for server-side tool execution.
object
Extended thinking configuration for Anthropic models.
string
Constrains effort on reasoning for supported reasoning models. Higher values use more compute, improving quality at the cost of latency and tokens.Options: low, medium, high
string
Pre-created Google or Vertex cache resource to use as context, in cachedContents/{id} format. When omitted, prompt_cache_key is used as the cache resource for Google and Vertex models. Cache resource creation and management happen directly through Google, outside the gateway.
object
Google generationConfig object. Merged with auto-generated config. Use for Google-specific params like candidateCount or responseMimeType.
array
Google safety settings for harm categories and thresholds.

Response

string
Unique identifier for the completion.
string
Always chat.completion.
integer
Unix timestamp of when the completion was created.
string
The model used for the completion.
array
Array of completion choices.
object
Token usage statistics.
array
List of MCP tools executed server-side, if any.

Examples