Skip to main content
POST
Chat Completions

Create Chat Completion

Generate a response from an AI model given a conversation history.

Request

Headers

Body Parameters

string
required
The model ID to use (e.g., claude-sonnet-4-5, gpt-4o, gemini-2.5-pro). See Supported Models for the full list.
array
required
An array of message objects representing the conversation history.Each message object has:
  • role (string): One of system, user, or assistant
  • content (string): The message content
boolean
default:"false"
If true, responses are streamed back as Server-Sent Events (SSE).
number
default:"1.0"
Sampling temperature between 0 and 2. Lower values make output more focused and deterministic.
integer
Maximum number of tokens to generate in the response.
number
default:"1.0"
Nucleus sampling parameter. An alternative to temperature.
string | array
Up to 4 sequences where the API will stop generating further tokens.

Example Request

Response

Response Fields

Streaming

Set "stream": true to receive Server-Sent Events (SSE) as the model generates tokens.

Streaming Request

Streaming Response

Each event is a JSON object prefixed with data: :

Streaming with Python

Streaming with Node.js