Skip to main content

Endpoint

Send a conversation to an AI model and receive a text response. Compatible with the OpenAI Chat Completions API.

Request Body

string
required
The model to use for completion. Use provider prefix for explicit routing (e.g., geminicli:gemini-2.5-pro) or omit prefix for auto-routing.
array
required
Array of message objects forming the conversation.
boolean
default:false
If true, returns a stream of server-sent events instead of a single response.
number
Sampling temperature between 0 and 2. Higher values make output more random.
integer
Maximum number of tokens to generate in the completion.
number
Nucleus sampling parameter. Alternative to temperature.
number
default:0
Penalize tokens based on frequency in the text so far (-2.0 to 2.0).
number
default:0
Penalize tokens based on presence in the text so far (-2.0 to 2.0).
string | array
Up to 4 sequences where the API will stop generating tokens.
array
List of tools the model may call. Currently supports function calling.
object
Provider-specific extensions. See CLI Attachments for CLI provider options.

Response Format

string
Unique identifier for the completion
string
Object type, always chat.completion or chat.completion.chunk for streaming
integer
Unix timestamp of when the completion was created
string
The model used for completion
array
Array of completion choices
object
Token usage statistics

Examples

Basic Request

Streaming Response

Multi-Turn Conversation

Provider-Specific Routing

Advanced Features

Temperature Control

Adjust randomness of responses:

Token Limits

Constrain response length:

Stop Sequences

Stop generation at specific strings:

Error Handling

Next Steps

Provider Prefixes

Learn about routing to specific providers

CLI Attachments

Pass files and folders to CLI providers

Models

List and discover available models

WebSocket

Use real-time bidirectional streaming