Skip to navigation

Run chat inference against any canonical model

View as Markdown

The unified endpoint’s only POST. model must be a canonical id (openai/<id>, anthropic/<id>, xai/<id>, huggingface/<owner>/<model>[:provider]) — there is no default and no fallback if it’s missing or unresolved; routing from a valid canonical id to a provider and model is deterministic, never inferred or best-guessed. The request body accepts only the field set every backing provider can express in common (see GET /inference/v1/models → supported_parameters for the exact list) — a field outside it is rejected with 400 unsupported_parameter before any upstream call, never silently dropped. Set stream: true for Server-Sent Events instead of a single JSON object; both forms are OpenAI Chat Completions-shaped regardless of which of the four providers actually served the request, including for Anthropic, whose native Messages wire shape is fully translated in both directions to produce this contract. A response’s model field is rewritten to the canonical id that served it, and cross-provider usage and tool_calls are reported in this same normalized shape either way.

Authentication

AuthorizationBearer

Your per-client bearer token — the API key the gateway issued to you. Present it in Authorization: Bearer <token> form. A token that is missing, unknown, or revoked draws a 401. Before the call is sent upstream the token is removed (stripped, or swapped for the upstream’s own credential); it never makes it past the gateway.

Request

This endpoint expects an object.
modelstringRequired

A canonical model id. Mandatory — there is no default and no fallback. See the Inference API guide for the openai/<id> / anthropic/<id> / xai/<id> / huggingface/<owner>/<model>[:provider] forms.

messageslist of objectsRequired
max_tokensintegerOptional>=1

For a request resolving to an Anthropic model, mapped to that API’s required max_tokens field; if neither this nor max_completion_tokens is set, the gateway injects Anthropic’s configured default rather than letting the call 400 there alone.

max_completion_tokensintegerOptional>=1
temperaturedoubleOptional
top_pdoubleOptional
stopstring or list of stringsOptional
streambooleanOptional

Selects the text/event-stream response form over a single JSON object.

stream_optionsobjectOptional
toolslist of objectsOptional
tool_choiceenum or objectOptional

"auto", "none", "required", or an object pinning one specific function tool.

parallel_tool_callsbooleanOptional

Response headers

x-nativeport-request-idstringOptional

A gateway-assigned id for this call, for support/troubleshooting — present on every response from this endpoint, success or error.

x-nativeport-providerstringOptional

Which of the four backing providers served the request (openai, anthropic, xai, or huggingface).

x-nativeport-modelstringOptional

The canonical model id that served the request — the same value as the response body’s model field.

Response

A normalized OpenAI Chat Completions response — application/json for a single chat.completion object, or text/event-stream (when the request set stream: true) for incremental chat.completion.chunk events terminated by a literal data: [DONE] line. Regardless of which of the four providers served the request, usage and tool_calls (or their streaming delta equivalents) are reported in this one shape, and model carries the canonical id that served it. Every response — this one included — carries the diagnostic x-nativeport-request-id, x-nativeport-provider, and x-nativeport-model headers described on the Inference API guide.

idstringOptional
object"chat.completion"Optional
createdintegerOptional
modelstringOptional
Rewritten to the canonical id that actually served the request, regardless of the provider's own native model identifier.
choiceslist of objectsOptional
usageobjectOptional

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
429
Too Many Requests Error
502
Bad Gateway Error