Skip to main content
The AI Chat API provides two endpoints for interacting with large language models: a multi-turn chat endpoint that supports streaming, and a single-prompt completions endpoint. Both are available on the Pro and Enterprise tiers and are subject to rate limiting. All endpoints are mounted under /api/ai/.
These endpoints are available on Pro and Enterprise plans only. Requests from free-tier users will be rejected with a 403 response.

POST /api/ai/chat

Send a conversation to the configured LLM provider and receive a response. You can choose the provider (openai, anthropic, or gemini) and optionally stream the response as server-sent events. Headers:
string
required
Bearer <access_token>
Request body:
object[]
required
An ordered list of messages representing the conversation history. Each message must have a role and content.
string
default:"openai"
The LLM provider to use. One of "openai", "anthropic", or "gemini". The provider must be configured with a valid API key in your backend environment.
string
The specific model to use (e.g., "gpt-4o", "claude-3-5-sonnet-20241022", "gemini-1.5-pro"). If omitted, the provider’s default model is used.
number
default:"0.7"
Sampling temperature between 0.0 and 2.0. Lower values produce more deterministic output; higher values increase creativity.
number
default:"1000"
Maximum number of tokens to generate. Must be between 1 and 16384.
boolean
default:"false"
When true, the response is streamed as server-sent events (SSE). Each event contains a token field with the next piece of text. The stream ends with data: [DONE].

Non-streaming example

ResponseChatResponse:
string
required
The full generated text response from the model.
string
required
The model identifier that was used to generate the response.
object
required
Token consumption breakdown for the request.

Streaming example

Set "stream": true to receive the response token by token as server-sent events. Each event is a JSON object with a token field. The final event is the literal string [DONE].
SSE stream format:

POST /api/ai/completions

Generate a single completion from a plain text prompt, without a conversation history. Useful for summarization, classification, code generation, and other single-turn tasks. Headers:
string
required
Bearer <access_token>
Request body:
string
required
The user’s input prompt.
string
An optional system message that sets the model’s behavior for this request (e.g., "You are a JSON formatter.").
string
default:"openai"
The LLM provider to use. One of "openai", "anthropic", or "gemini".
string
The specific model to use. If omitted, the provider’s default model is used.
number
default:"0.7"
Sampling temperature between 0.0 and 2.0.
number
default:"1000"
Maximum number of tokens to generate. Must be between 1 and 16384.
Response:
string
required
The generated text response.
string
required
The model identifier that produced the response.
object
required
Token consumption breakdown (same shape as ChatResponse.usage).