Create a chat completion

OpenAI-compatible chat completions with ordered model fallbacks and provider routing policy. Pass model "@slug" to run a saved preset you own — the preset supplies models, prompt, tools, and routing; send only messages.

post/chat/completions

Request

  • Base URL: https://www.ninjachat.ai/api/v1
  • URL: https://www.ninjachat.ai/api/v1/chat/completions
  • Auth: HTTP bearer

Headers

Idempotency-Keystring

Safely retry the same logical write without duplicate billing or execution.

Request body

modelstring
modelsstring[]
max_completion_tokensinteger

Maximum completion tokens, including reasoning where the provider counts it. Must fit the selected provider's output and context limits. Defaults to 2048 when omitted.

temperaturenumber
top_pnumber
frequency_penaltynumber
presence_penaltynumber
seedinteger
userstring
streamboolean
parallel_tool_callsboolean

Response

Chat completion or SSE stream.

balancestring
idstring required
object'chat.completion' required
createdinteger required
modelstring required
resolved_modelstring required
providerstring nullable required
cost_usdnumber required
request_idstring required

Changes

No recorded changes to this operation across all 1 revision of this API.