api/Chat CompletionsPOST

POST /v1/chat/completions

Complete API specification for chat completions, streaming, tool calls, and model fallbacks.


Endpoint Specification

`POST https://unlockedai.net/v1/chat/completions` Creates a model response for the given conversation history. Standard OpenAI API wire compatibility.
ParameterTypeRequiredDescription
modelstringYes*Target model ID or smart alias (`claude-sonnet-5.5`, `auto`, `frontier`).
modelsstring[]NoOrdered array of fallback models to cascade through upon upstream failure.
messagesarrayYesList of conversation turns (`system`, `user`, `assistant`, `tool`).
streambooleanNoIf true, streams partial message deltas via Server-Sent Events. Default false.
temperaturenumberNoSampling temperature between 0.0 and 2.0. Defaults to model standard.
max_tokensintegerNoUpper limit on generated completion tokens (capped at 8,192).
top_pnumberNoNucleus sampling probability mass cutoff between 0.0 and 1.0.
toolsarrayNoList of tools the model may generate JSON arguments for.
tool_choicestring | objectNoControls tool usage (`auto`, `none`, `required`, or explicit function).
response_formatobjectNoEnforces structured outputs, e.g. `{"type": "json_object"}`.
presence_penaltynumberNoNumber between -2.0 and 2.0 penalizing new tokens based on presence.
frequency_penaltynumberNoNumber between -2.0 and 2.0 penalizing new tokens based on frequency.
seedintegerNoDeterministic sampling integer for reproducible completions.

HTTP Request Headers

Header NameRequiredDescription
AuthorizationYesBearer token authentication: `Bearer sk-unlocked-...`
Content-TypeYesMust be `application/json`.
HTTP-RefererNoOptional site URL for client attribution.
X-TitleNoOptional client application title.

Response Payload Schema

{
  "id": "gen_8e7f9a2b",
  "object": "chat.completion",
  "created": 1740000000,
  "model": "claude-sonnet-5.5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A Raft consensus cluster tolerates up to (N-1)/2 node failures without losing state."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 32,
    "completion_tokens": 18,
    "total_tokens": 50
  }
}

Need an Unlocked AI Key or Credits?

Generate secret API keys backed by non-expiring pay-as-you-go credits starting at $5. No monthly minimums.