Generate a chat completion.
JWT token from Stytch B2B authentication (magic link, SSO, or M2M)
Stream format for SSE responses. Set to ai-sdk to enable Vercel AI SDK UI Message Stream Protocol compatibility. When enabled, response includes x-vercel-ai-ui-message-stream: v1 header.
ai-sdk Request schema for chat completions.
Messages to send to the model
1Existing chat ID to continue conversation
"chat_abc123"
Identifier of the AI model for this request. If omitted and chatId is provided, the chat's existing model is used. Must match a model 'id' from the /v1/models API.
System-level instructions for the AI model.
Create temporary chat for testing. Ephemeral chats are automatically deleted.
false
Enable streaming response
true
Maximum number of tokens to generate for this response
1 <= x <= 32000128
Structured output format specification (AI models-compatible json_schema format). Enforces the AI response to match the specified JSON schema.
{
"json_schema": {
"name": "response",
"schema": {
"additionalProperties": false,
"properties": {
"summary": { "type": "string" },
"confidence": {
"maximum": 1,
"minimum": 0,
"type": "number"
}
},
"required": ["summary"],
"type": "object"
},
"strict": true
},
"type": "json_schema"
}Enable reasoning/thinking tokens for supported models. When enabled, the model will expose its thinking process in the response. Supported by: AI models (extended thinking), AI models o1/o3, AI models thinking models. Note: Reasoning tokens are billed separately and may significantly increase costs.
true
false
Maximum tokens for reasoning/thinking (only used when enableReasoning=true). Higher budgets allow deeper reasoning but increase latency and cost. Default: 10000 for AI models, varies by provider.
1000 <= x <= 12800010000
List of tools the model may call. Pass-through to AI provider. Tools are defined and executed by the client, not the server.
[
{
"function": {
"description": "Get current weather for a location",
"name": "get_weather",
"parameters": {
"properties": {
"location": { "type": "string" },
"unit": {
"enum": ["celsius", "fahrenheit"],
"type": "string"
}
},
"required": ["location"],
"type": "object"
}
},
"type": "function"
}
]Controls tool selection. Options: 'auto' (model decides), 'none' (no tools), 'required' (must use a tool), or specific tool object.
"auto"
Whether to allow parallel tool calls (AI models-specific, default true)
Server-Sent Events stream of chat completion chunks (when stream=true)
The response is of type string.