Chat Completions

Create a chat completion

Changed on

Creates a model response in the OpenAI Chat Completions dialect and charges the account for the tokens it used. Requires an API key. /v1/responses and /v1/messages serve the same models in the other two dialects.

post/v1/chat/completions

Request

Headers

x-naga-routing-strategy'reliability' | 'balanced' | 'latency' | 'throughput' | 'cache'

The order in which NagaAI tries the providers that serve a model. A NagaAI extension.

The routing strategy when the body names none. An unknown name is ignored. A NagaAI extension.

Request body

modelstring required

The model to run, named by an id or alias from NagaAI's catalog. An entry without the chat.completions capability draws a refusal.

modelsstring[] nullable

Fallback models, tried in order when model cannot answer: none of its providers served it, or the request does not fit it. At most 3; the answer's model names the one that answered, and only that one is billed. A NagaAI extension in OpenRouter's shape.

temperaturenumber double nullable

How much randomness goes into the reply, between 0 and 2, and an alternative to top_p.

top_pnumber double nullable

The sampling cut-off, between 0 and 1, and an alternative to temperature.

streamboolean nullable

Whether the reply arrives incrementally as the model writes it.

max_completion_tokensinteger nullable

The ceiling on generated tokens, reasoning included. At least 1.

max_tokensinteger nullable

An alias of max_completion_tokens, read only when that key is absent.

reasoning_effort'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' nullable

How much reasoning to spend before answering, from none to max. A model without the level runs the nearest one it has.

presence_penaltynumber double nullable

How hard a token is penalized for having appeared, from -2 to 2.

frequency_penaltynumber double nullable

How hard repetition is penalized, scaled by how often, from -2 to 2.

parallel_tool_callsboolean nullable

Whether the model may return several tool calls in one turn.

Response

The completion. application/json carries one chat.completion object when stream is false; text/event-stream carries one chat.completion.chunk per event, then the data: [DONE] sentinel, when it is true.

OR

Example response

{
  "object": "chat.completion",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "tool_calls": [
          {
            "type": "function"
          }
        ],
        "images": [
          {
            "type": "image_url"
          }
        ],
        "annotations": [
          {
            "type": "url_citation"
          }
        ]
      },
      "finish_reason": "stop"
    }
  ]
}

Changes

    • info

      added the new optional request property

    • info

      added the optional property /////////// to the response with the status