Contact
Skip to the page text

Documentation / Guides / Inference API

Chat Completions (OpenAI schema)

POST https://<platform-address>/v1/chat/completions. Your platform's real endpoint and model ids are on the APIs page (/apis).

Request headers

Content-Type: application/json
Authorization: Bearer onprem-gw-your-key

The anthropic-version header has no effect on this route. /v1/chat/completions is always parsed as an OpenAI chat completion.

Request body

{
  "model": "my-model-id",
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "Hello!" }
  ],
  "stream": true,
  "max_tokens": 1024,
  "temperature": 0.7,
  "stream_options": { "include_usage": true }
}
ParameterTypeRequiredDescription
modelstringyesModel id as listed by /v1/models (or a configured alias)
messagesarrayyesConversation messages; content is a string or an array of content parts (see Vision)
streambooleanno (false)Enable SSE streaming
max_tokensintegernoMax output tokens; the legacy alias max_completion_tokens is also read
temperaturenumbernoSampling temperature
top_pnumbernoNucleus sampling
stoparray of stringsnoStop sequences
presence_penalty / frequency_penaltynumbernoRepetition penalties
tools / tool_choicearray / objectnoOpenAI-style function tools
stream_options.include_usagebooleannoThe gateway sets this to true on every streaming request anyway (see Streaming)

Notes on gateway behavior (verified in the gateway source):

  • Omitted max_tokens: the gateway injects the model's configured default cap into the request (clamped to the remaining context window), so the engine always enforces a real output bound. Client-declared values are never modified.
  • Native passthrough: for engines that speak OpenAI natively (vLLM), the request body is forwarded as-is apart from the model-id rewrite and the injections above -- additional OpenAI-compatible parameters supported by the engine pass through unvalidated.
  • Request bodies are limited to 10 MB.

Vision (image input)

For multimodal models, content becomes an array of typed parts:

{
  "model": "my-vision-model",
  "messages": [{
    "role": "user",
    "content": [
      { "type": "text", "text": "What is in this image?" },
      { "type": "image_url", "image_url": { "url": "data:image/png;base64,iVBOR..." } }
    ]
  }],
  "stream": true,
  "max_tokens": 1024
}
Part typeFields
texttext: string
image_urlimage_url: { url: string } -- typically a data: URI with base64 image data

Multiple image_url parts per message are allowed. Whether a given model accepts images depends on the model (see its catalog card / the APIs page).

Non-streaming response

With "stream": false, the engine's chat completion object is returned directly:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "my-model-id",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Hello! How can I help?" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 13, "completion_tokens": 9, "total_tokens": 15 }
}

Streaming response (SSE)

With "stream": true the response is text/event-stream. The gateway injects stream_options: {"include_usage": true} into every streaming request, so the stream always ends with a usage chunk before [DONE]:

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"!"}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":5,"total_tokens":15}}

data: [DONE]

Read each data: line as JSON:

  • choices[0].delta.content -- incremental text
  • choices[0].finish_reason -- "stop" (or "length", "tool_calls") on the final content chunk
  • usage -- exact token counts in the final chunk

If the stream fails mid-flight (after headers are sent), the gateway emits the error envelope as a data: event instead of silently closing. If the model produces no first token within its deadline, no stream starts at all -- you get a clean 503 (see below).

Common errors

All use the envelope described in API Overview. The ones you will actually hit:

HTTPtype / codeCause
401invalid_request_error / authentication_errorMissing or invalid Authorization: Bearer header
404ModelNotFoundmodel value is not a deployed model id or alias
400ParseBody is not valid JSON
502UpstreamEngine error; upstream_status / upstream_body carry the engine's real response
503OverloadedLoad shedding; code is one of concurrency_budget_exceeded, ttft_deadline_exceeded, kv_cache_utilization_exceeded; Retry-After: 2 header set

Example 503:

{
  "error": {
    "message": "Service overloaded -- model 'my-model-id' produced no first token within 8000ms. Please retry later.",
    "type": "Overloaded",
    "code": "ttft_deadline_exceeded"
  }
}

Overload rejections are 503 (not 429). Honor Retry-After and back off.

Found a mistake, or is something missing? Suggest an improvement to this page on GitHub.

Platform release 5.10.4, . Source of this page at v5.10.4. This page as Markdown.