Chat Completions
POST /api/v1/chat/completionsOpenAI Chat Completions format. Works with every model in the catalog — including Anthropic-slugged models — via any-to-any translation.
Request body
Body — application/json (required)
modelstringrequiredModel slug to invoke (e.g. deepseek/deepseek-v4-pro).
messagesobject[]requiredConversation messages; at least one is required.
Show 6 nested fields
rolestringrequiredConversation role. `developer` maps to `system`.
Possible values: system developer user assistant tool
contentstring | (text | image_url | file)[] | nullMessage content: a string, an array of content parts, or null.
Show 2 variants
stringstring(text | image_url | file)[](text | image_url | file)[]Show 3 variants
textobjectShow 2 nested fields
type"text"requiredtextstringrequiredThe text content.
image_urlobjectShow 2 nested fields
type"image_url"requiredimage_urlobjectrequiredShow 2 nested fields
urlstringrequiredImage URL or data: URL.
detailstringOpenAI vision detail level (low/high/auto).
fileobjectShow 2 nested fields
type"file"requiredfileobjectrequiredShow 4 nested fields
filenamestringOptional filename hint.
file_datastringFile contents as a data: URL.
file_urlstringFile contents as a fetchable URL.
file_idstringUploaded file id (not supported — use file_data or file_url).
namestringOptional participant name.
reasoningstring | nullPrior reasoning text (OpenRouter extension).
tool_callsobject[]Tool calls produced by the model.
Show 3 nested fields
idstringrequiredTool call id assigned by the model.
type"function"requiredfunctionobjectrequiredShow 2 nested fields
namestringrequiredFunction name.
argumentsstringrequiredJSON-encoded arguments string.
tool_call_idstringTool call id this result message answers.
tools(function | object)[]Function tools and/or OpenRouter server-tool activations (024-R26).
Show 2 variants
functionobjectShow 2 nested fields
type"function"requiredfunctionobjectrequiredShow 4 nested fields
namestringrequiredFunction name.
descriptionstringNatural-language description for the model.
parametersobjectJSON Schema for the function arguments.
strictbooleanEnable OpenAI strict structured outputs.
objectobjectShow 4 nested fields
typestringrequiredOpenRouter server tool id (openrouter:web_search|...).
parametersobjectOpenRouter server-tool parameters.
max_usesintegerMax invocations of this tool in the request (018).
eventsbooleanOpt this tool into `hi.tool_event` streaming (009-R55).
tool_choicestring | functionHow to choose tools: auto, none, required, or a specific function.
Show 2 variants
stringstringPossible values: auto none required
functionobjectShow 2 nested fields
type"function"requiredfunctionobjectrequiredShow 1 nested field
namestringrequiredFunction name to force.
parallel_tool_callsbooleanAllow the model to call tools in parallel.
max_tokensintegerMax output tokens (legacy name; prefer max_completion_tokens).
max_completion_tokensintegerMax output tokens.
temperaturenumberSampling temperature, 0–2.
top_pnumberNucleus sampling probability, 0–1.
stopstring | string[]Stop sequence(s); generation halts when hit.
response_formatobjectForce text, JSON, or a specific JSON Schema on the output.
Show 2 nested fields
typestringrequiredResponse format mode.
Possible values: text json_object json_schema
json_schemaobjectThe JSON Schema when type is json_schema.
Show 3 nested fields
namestringrequiredSchema name.
schemaobjectrequiredJSON Schema describing the response.
strictbooleanEnable strict structured outputs.
reasoning_effortstringReasoning effort dial (none|minimal|low|medium|high|xhigh|max).
Possible values: none minimal low medium high xhigh max
streambooleanStream SSE chunks instead of returning one object.
stream_optionsobjectStreaming options. Usage is always emitted (002-R8).
Show 1 nested field
include_usagebooleanEmit a final usage chunk.
pluginsobject[]Server-tool activations (OpenRouter plugins idiom, 002-R11).
Show 3 nested fields
idstringrequiredServer tool id (OpenRouter plugins idiom, 002-R11).
Possible values: web_search web_fetch pdf datetime image
eventsbooleanOpt this tool into `hi.tool_event` streaming (009-R55).
max_usesintegerMax invocations of this tool in the request (018). Default 1000.
web_search_optionsobjectOpenAI web_search_options → our `web_search` server tool (024-R26).
Show 2 nested fields
search_context_sizestringHow much context to retrieve.
Possible values: low medium high
user_locationobjectApproximate user location for location-biased results.
Show 2 nested fields
type"approximate"approximateobjectShow 4 nested fields
citystringregionstringcountrystringtimezonestringhi_tool_eventsbooleanOpt the whole request into `hi.tool_event` streaming (009-R55).
userstringEnd-user identifier for abuse monitoring.
service_tierstringOpenAI service tier — accepted but the gateway owns tiering.
nintegerNumber of choices. Only n=1 is supported (024-R3/D6).
seedintegerSampling seed for best-effort determinism.
frequency_penaltynumberPenalize tokens by frequency, -2 to 2.
presence_penaltynumberPenalize tokens by presence, -2 to 2.
logit_biasmap<string, number>Token-id → bias map (-100 to 100).
logprobsbooleanReturn log probabilities of output tokens.
top_logprobsintegerTop-N log probabilities per token (requires logprobs:true).
min_pnumberMin-p sampling threshold, 0–1.
top_anumberTop-a sampling threshold, 0–1.
repetition_penaltynumberRepetition penalty, 0–2.
verbositystringOutput verbosity dial.
Possible values: low medium high xhigh max
predictionobjectPredicted Outputs content hint.
Show 2 nested fields
type"content"requiredcontentstring | any[]requiredPredicted content.
modalitiesstring[]Requested output modalities. Only text is supported.
audioanyAudio output options — not supported (text-only deployment).
Generated at build time from the API's OpenAPI document — the same schemas that validate requests, so this section cannot drift from the API.
max_tokens and max_completion_tokens are aliases — either caps generated tokens at
the model’s max output. stream: true switches to SSE — see Streaming;
stream_options is accepted for compatibility (the final usage chunk is always
emitted). plugins is the HyperInfer extension for server tools.
Beyond the fields above, the full OpenAI sampling / tool / output surface is accepted
and forwarded — seed, frequency_penalty, presence_penalty, logit_bias,
logprobs, parallel_tool_calls, per-tool strict, verbosity, prediction, and so
on — along with OpenRouter extensions (min_p, top_a, repetition_penalty,
provider routing, transforms) and any custom top-level field, all passed through
verbatim to the OpenAI-compatible upstream. A few parameters are rejected rather than silently ignored
(service_tier, n > 1, audio / non-text modalities) — see Errors.
Response
{
"id": "gen-abc123",
"object": "chat.completion",
"created": 1767312000,
"model": "anthropic/claude-sonnet-4.5",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Hello there, all five words." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 7,
"total_tokens": 19,
"prompt_tokens_details": { "cached_tokens": 0 },
"completion_tokens_details": { "reasoning_tokens": 0 }
}
}The id is gen-<request id> — pass the request ID (also returned in the
X-Request-Id header) to GET /generation for cost and
latency metadata.
Response schema
200Response
The completion. With `stream: true`, an SSE stream instead (see the text/event-stream variant).
application/json
idstringrequiredgen-<request id> — pass the request id to GET /api/v1/generation.
object"chat.completion"requiredcreatedintegerrequiredUnix seconds.
modelstringrequiredchoicesobject[]requiredShow 4 nested fields
indexintegermessageobjectShow 4 nested fields
role"assistant"contentstring | nullreasoningstringtool_callsobject[]Show 3 nested fields
idstringtype"function"functionobjectShow 2 nested fields
namestringargumentsstringfinish_reasonstringPossible values: stop length tool_calls content_filter
logprobsnullusageobjectrequiredShow 6 nested fields
prompt_tokensintegerrequiredcompletion_tokensintegerrequiredtotal_tokensintegerrequiredprompt_tokens_detailsobjectShow 2 nested fields
cached_tokensintegeraudio_tokensintegerAudio input tokens; omitted when 0.
completion_tokens_detailsobjectShow 4 nested fields
reasoning_tokensintegeraudio_tokensintegerAudio output tokens; omitted when 0.
accepted_prediction_tokensintegerPredicted Outputs accepted tokens; omitted when 0.
rejected_prediction_tokensintegerPredicted Outputs rejected tokens; omitted when 0.
costnumberHyperInfer usage-accounting extension: total cost in credits (USD).
text/event-streamSSE streamSSE stream of `chat.completion.chunk` objects (`data:` frames): a role frame, then content/reasoning/tool_call deltas, a finish_reason frame, a final usage-only chunk (always emitted — stream_options.include_usage semantics, 002-R8), and `data: [DONE]`. Keep-alive comments every 15 s.
errorError envelope (any non-2xx status)
Error in this ingress format's native envelope, with the stable taxonomy `code` (002-R7). See the ErrorCode schema for the code → HTTP status mapping.
errorobjectrequiredShow 6 nested fields
messagestringrequiredtypestringrequiredOpenAI-compatible error class (e.g. invalid_request_error).
codestringrequiredStable error taxonomy (002-R7), identical across ingress formats. HTTP status per code: provider_auth=502, provider_rate_limit=429, provider_overloaded=529, context_length_exceeded=400, content_filter=400, provider_timeout=504, provider_unavailable=502, insufficient_credits=402, key_limit_exceeded=402, model_not_allowed=403, invalid_api_key=401, workspace_locked=403, rate_limit_exceeded=429, invalid_request=400, payload_too_large=413, internal_error=500.
Possible values: provider_auth provider_rate_limit provider_overloaded context_length_exceeded content_filter provider_timeout provider_unavailable insufficient_credits key_limit_exceeded model_not_allowed invalid_api_key workspace_locked rate_limit_exceeded invalid_request payload_too_large internal_error
paramstring | nullrequest_idstringretry_after_secondsintegerSeconds until the request can be retried (clamped to 1–120). Present iff a Retry-After HTTP header is also set — on rate_limit_exceeded (429), provider_rate_limit (429), provider_overloaded (529), provider_timeout (504), and provider_unavailable (502). Absent on all other errors.
Generated at build time from the API's OpenAPI document — the same schemas that validate requests, so this section cannot drift from the API.
Examples
curl
curl https://api.hyperinfer.ai/api/v1/chat/completions \
-H "Authorization: Bearer $HYPERINFER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.5",
"messages": [
{ "role": "system", "content": "You are a concise assistant." },
{ "role": "user", "content": "In one sentence: what is speculative decoding?" }
],
"max_tokens": 256
}'Errors
OpenAI error object with the stable taxonomy, e.g. HTTP 402:
{ "error": { "message": "…", "type": "insufficient_credits", "code": "insufficient_credits", "param": null } }