Skip to main content
POST
Create a chat completion

Authorizations

Authorization
string
header
required

User-bound credential carrying an identity: either a session JWT or a user access token (at:*) generated from the user settings UI. Send as Authorization: Bearer <token>. Org API keys (iak_*) are not accepted here - they carry no user identity. Use the x-prismeai-api-key header instead (see OrgApiKeyAuth).

Body

application/json

OpenAI-compatible chat completion request. Only the fields actually accepted by the gateway are documented here.

messages
object[]
required

Conversation history (system + user/assistant/tool turns).

model
string

Model id from the catalogue (e.g. gpt-4o, eu.anthropic.claude-sonnet-4-20250514-v1:0, vertex-gemini-2.5-flash). Defaults to the gateway's defaults.completions model when omitted.

Maximum string length: 256
temperature
any

Sampling temperature (provider-dependent range, typically 0 to 2).

max_tokens
any

Max tokens to generate.

max_completion_tokens
any

Max tokens to generate, OpenAI's newer name for max_tokens. Either one is accepted; the gateway forwards a single max_tokens (the lower value when both are sent), capped to the model's limits.max_response_tokens. It is sent back as max_completion_tokens where the model requires it, through the model's rename_params or the provider's parameterAliases. A provider entry that excludes max_tokens without such a rename sends no output limit.

top_p
any

Nucleus sampling parameter.

frequency_penalty
any

OpenAI-style frequency penalty.

presence_penalty
any

OpenAI-style presence penalty.

stop
any

One or more stop sequences (string or array of strings).

stream
boolean

When true, the response is a text/event-stream of ChatCompletionChunk deltas terminating with data: [DONE].

tools
object[]

Tool/function definitions made available to the model. Forwarded to providers that support tool calling.

tool_choice
any

Tool selection hint: "auto", "none", "required", or { type: "function", function: { name } }.

response_format
object

OpenAI-style structured output hint (e.g. { "type": "json_object" }).

seed
any

Provider seed for reproducible sampling (where supported).

fallback_models
string[]

Prisme.ai extension. Ordered fallback models tried when the requested model fails (merged with the governance failover mapping). Each one is checked against the caller's access like the primary.

Maximum array length: 5
task_id
string

Prisme.ai extension. Opaque correlation id propagated to A2A (agent-to-agent) flows.

Maximum string length: 128
analytics_context
object

Prisme.ai extension. Caller-supplied analytics context merged into the analytics.llm.completion event.

prompt_cache
boolean

Prisme.ai extension. When omitted, prompt caching is on for conversations, i.e. requests that carry prompt_cache_key or analytics_context.context_id, and off for one-shot calls, whose cache write would never be read back. true turns it on even without a key; false turns it off. Caching means cache markers (Claude, Nova) and a cache key (OpenAI, Azure GPT, Mistral — on Mistral the key is what enables caching). The automatic caching of OpenAI / Azure GPT and Gemini cannot be switched off and stays active.

prompt_cache_key
string

Prisme.ai extension (standard OpenAI field). Cache routing key sent to OpenAI, Azure GPT and Mistral. Defaults to analytics_context.context_id. Ignored when prompt_cache is false.

Maximum string length: 256

Response

Successful completion. Content type depends on request.stream:

  • application/json: non-streaming ChatCompletionResponse.
  • text/event-stream: SSE stream of ChatCompletionChunk payloads followed by data: [DONE] and a final chat.completion frame.

Non-streaming chat completion response. Mirrors OpenAI's shape with Prisme.ai extensions on usage (cost, duration_ms, carbon).

id
string
required

Generated id (chatcmpl-<correlationId>).

object
enum<string>
required
Available options:
chat.completion
created
integer
required

Unix timestamp (seconds).

model
string
required

Resolved model id used to serve the request.

choices
object[]
required
usage
object

Token, cost, and carbon accounting.

failover
object

Reported when the requested model was attempted, failed, and a fallback answered instead. Absent when no switch happened.