v2

latestOpenAPI 3.1.02026-08-05267431678.1 KB
openai-compat

Chat Completions

OpenAI-compatible chat completions endpoint.

Thin shell over :func:services.inference.adapters.openai_chat.run_chat_completion. The adapter handles LLM-passthrough vs Pioneer-task dispatch, SSE rendering with <think>...</think> folding for reasoning models, tool-call deltas, finish-reason mapping, persistence, and error mapping. The router keeps only HTTP-shaped concerns: route declaration, auth, rate limiting.

Args: body: Validated :class:ChatCompletionRequest. request: FastAPI request (forwarded so the adapter can read API-key billing context out of request.state for streaming responses). auth: Authenticated request context.

Returns: :class:ChatCompletionResponse for non-streaming, or a :class:StreamingResponse of chat.completion.chunk SSE events terminated by data: [DONE] when body.stream is true.

post/v1/chat/completions

Request body

modelstring required
temperaturenumber nullable
max_tokensinteger nullable
response_formatobject nullable
streamboolean
extra_headersobject nullable
extra_bodyobject nullable
reasoningobject nullable

Opt-in reasoning / extended-thinking controls. Accepts the OpenRouter-normalized shape with keys enabled (bool), max_tokens (int, Anthropic-style budget), effort (one of minimal/low/medium/high/xhigh/max/none, OpenAI/Grok-style tier), and exclude (bool, hide reasoning tokens from the response). effort and max_tokens are mutually exclusive. Pioneer extensions for Claude routes (Anthropic direct + Bedrock): mode (manual/adaptive — adaptive lets the model pick thinking depth per request, required on Opus 4.7+) and display (summarized/omitted — controls whether thinking text streams back; omitted preserves only the signature for multi-turn). On Chat Completions, provider reasoning text is hidden by default and is returned on message.reasoning_content / delta.reasoning_content only when the caller explicitly requests visible reasoning with exclude=false or display=summarized. Pioneer canonicalizes this into InferenceRequest.reasoning at the adapter boundary and each provider renders it to its native wire field (Anthropic thinking, OpenAI reasoning_effort, OpenRouter reasoning). Pioneer does not enable reasoning by default.

storeboolean
metadataobject nullable
top_pnumber nullable
ninteger nullable
presence_penaltynumber nullable
frequency_penaltynumber nullable
logit_biasobject nullable
userstring nullable
seedinteger nullable
task_typestring nullable

Deprecated. Legacy task hint (extract_entities / classify_text / extract_json / ner / schema). The unified schema disambiguates the task automatically so this field is no longer required. Submitting it emits Deprecation: true and Sunset: <RFC 7231 date> headers on the response.

include_confidenceboolean
include_spansboolean
effort'low' | 'medium' | 'high' | 'xhigh' | 'max'

Per-request routing-effort tier, ascending in cost and quality.

A router-agnostic label the caller sends as the effort param (or as a model suffix). Each router type maps these tiers to its own concrete policy via its :class:RouterProfile.

modelsstring[] nullable

Per-request candidate-model subset the router may select between. Overrides the router's stored candidate set for this request only; ignored for non-router models.

Response

Chat completion. Returns application/json (ChatCompletionResponse) by default, or text/event-stream of ChatCompletionStreamChunk events terminated by data: [DONE] when stream=true.

idstring
objectstring
createdinteger
modelstring required