POST /v1/chat/completions

OpenAI-compatible chat completions.

Inference APIs

Create a chat completion using OpenAI-compatible request and response shapes, with gateway rewrites, caching, and streaming support.

POST/v1/chat/completions

Request

  • Auth: tenant auth when enabled; otherwise dev mode is open
  • Content-Type: application/json
  • Max body size: 4 MiB
  • Streaming: SSE when stream=true

Request fields

FieldTypeRequiredNotes
modelstringyesAlias or direct provider/upstream-model string
messagesarrayyesOpenAI chat messages
streambooleannoEnables SSE streaming
max_tokensintegernoPassed upstream when present
max_completion_tokensintegernoPassed upstream when present
temperaturenumbernoPassed upstream when present
top_pnumbernoPassed upstream when present
toolsany JSONnoPassed through unchanged
tool_choiceany JSONnoPassed through unchanged
response_formatany JSONnoPassed through unchanged
stream_options.include_usagebooleannoEnables usage chunks on stream-capable upstreams
metadata or arammobjectnoAttribution fields stripped before upstream dispatch
any other fieldsany JSONnoPreserved in Extra and forwarded unchanged

Response schema

FieldTypeRequiredNotes
idstringyesGateway-owned completion ID
objectstringyesAlways chat.completion for unary responses
createdint64yesUnix timestamp from the gateway boundary
modelstringyesRewritten to the public alias
choicesarrayyesAlways present
choices[].indexintegeryesChoice index
choices[].message.rolestringyesUsually assistant
choices[].message.contentstringnoAssistant content when returned as text
choices[].finish_reasonstringyesStop reason from the upstream provider
usageobjectnoPresent when the upstream provides usage
usage.prompt_tokensintegernoPrompt token count
usage.completion_tokensintegernoCompletion token count
usage.total_tokensintegernoTotal token count
usage.costnumbernoGateway estimate when available

Errors

HTTPCodeWhen
400invalid_requestMalformed JSON, missing model, missing messages, or invalid message content
400invalid_modelUnknown model or unsupported route resolution
400provider_not_configuredProvider missing from config or unavailable
422pii_detectedPII blocked in pre-call or post-call guardrails
422BLOCKED_POLICY_VIOLATIONPDPA keyword policy block
403CROSS_BORDER_TRANSFER_BLOCKEDPDPA cross-border transfer rejected
429rate_limit_exceededTenant rate limit exceeded
402monthly_budget_exceededMonthly spend limit exceeded
402insufficient_creditsCredit balance too low
502upstream_errorProvider failure without a normalized provider error body

Notes

  • Unary requests may be served from the exact response cache.
  • Streaming requests proxy OpenAI-style SSE frames frame-by-frame.
  • Response model is rewritten to the public alias.
  • Response id is rewritten to a gateway-owned completion ID.
  • metadata and aramm body fields are stripped before upstream dispatch.