> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trynito.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat Completions

> One OpenAI-compatible endpoint for chat and text generation.

Send a list of messages, name a model, get a reply in the OpenAI chat-completions shape. The model ID carries the privacy level.

## Endpoint

`POST /v1/chat/completions` accepts OpenAI-compatible requests. Unknown fields at gateway-owned objects are dropped for compatibility. A control the model cannot honor returns `400 invalid_request` before any usage is reserved.

## Request

Only `messages` is required.

| Field | Type | Notes |
| - | - | - |
| `messages` | array | **Required.** An empty array is rejected. |
| `model` | string | Logical ID such as `openai/gpt-5.5`. Add `:confidential` for the attested variant. |
| `temperature` | number | Forwarded when set. |
| `top_p` | number | Forwarded when set. |
| `max_tokens` | integer | Cap on generated tokens, used when `max_completion_tokens` is unset. |
| `max_completion_tokens` | integer | Preferred cap. |
| `stream` | boolean | Server-Sent Events. See [Streaming](/api/features/streaming). |
| `stream_options.include_usage` | boolean | Trailing usage chunk on the stream. |
| `reasoning` | object | See [Reasoning](/api/features/reasoning). |
| `reasoning_effort` | string | Flat OpenAI-style effort: `minimal`, `low`, `medium`, `high`. `reasoning.effort` wins when both are present. |
| `web_search` | boolean | See [Web Search](/api/features/server-side-tools/web-search). |
| `web_fetch` | boolean | See [Web Fetch](/api/features/server-side-tools/web-fetch). |
| `tools` | array | Function tools plus the aliases `{"type":"web_search"}` and `{"type":"web_fetch"}`. See [Tool Calling](/api/features/tool-calling). |
| `tool_choice` | string or object | `auto`, `none`, `required`, or a named function. |
| `response_format` | object | JSON mode or JSON Schema, on models advertising `json_mode` or `structured_outputs`. |
| `stop`, `frequency_penalty`, `presence_penalty`, `parallel_tool_calls` | various | Accepted on models whose catalog entry advertises the control; otherwise `400`. |
| `user` | string | Opaque end-user identifier, forwarded where supported. |

`n: 1` and `store: false` are accepted as no-ops. `n` above 1, `store: true`, and audio output are rejected. The same feature sent twice (for example `web_search` as a field and as a tool) is rejected.

A model's supported optional controls are in `supported_parameters` on its catalog entry. The `supports` query can filter for controls such as `json_mode`; `structured_outputs` qualifies `response_format` rather than naming a top-level request field. See [Model Discovery](/api/api-reference/models-catalog/list-models).

### Messages

Each message has `role` and `content`. Roles: `system`, `user`, `assistant`, `tool`, `developer`. A `tool` message pairs with a `tool_call_id`. `content` is a string or an array of parts for [multimodal input](/api/features/multimodal).

### Suffixes on the Model ID

Clients that can only set `model` can carry a few controls in the ID: `z-ai/glm-5.2?reasoning_effort=high`, `moonshotai/kimi-k3?web_search=auto`. Suffix and body must agree when both are present. The suffix is stripped before routing. See [Model ID Convention](/models/model-id-convention).

## Example

<CodeGroup>
  ```shellscript curl wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl https://app.trynito.ai/v1/chat/completions \
    -H "Authorization: Bearer $NITO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "moonshotai/kimi-k3",
      "messages": [
        {"role": "system", "content": "You are concise."},
        {"role": "user", "content": "Explain a gateway in one sentence."}
      ]
    }'
  ```

  ```python Python lines wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://app.trynito.ai/v1",
      api_key="YOUR_NITO_API_KEY",
  )

  resp = client.chat.completions.create(
      model="moonshotai/kimi-k3",
      messages=[
          {"role": "system", "content": "You are concise."},
          {"role": "user", "content": "Explain a gateway in one sentence."},
      ],
  )

  print(resp.choices[0].message.content)
  ```

  ```typescript TypeScript lines wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://app.trynito.ai/v1",
    apiKey: process.env.NITO_API_KEY,
  });

  const resp = await client.chat.completions.create({
    model: "moonshotai/kimi-k3",
    messages: [
      { role: "system", content: "You are concise." },
      { role: "user", content: "Explain a gateway in one sentence." },
    ],
  });

  console.log(resp.choices[0].message.content);
  ```
</CodeGroup>

For attested hardware, use a `:confidential` variant, for example `"model": "moonshotai/kimi-k3:confidential"`. `GET /v1/models` lists their `:confidential` IDs. See [Privacy Levels](/privacy/levels).

## Response

```json lines wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "...",
  "object": "chat.completion",
  "created": 1751299200,
  "model": "moonshotai/kimi-k3",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "A gateway is a single entry point that routes your request to the right backend." },
      "finish_reason": "stop"
    }
  ],
  "system_fingerprint": null,
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 17,
    "total_tokens": 41
  }
}
```

* Exactly one choice. Read `choices[0]`.
* `finish_reason`: `stop`, `length`, `tool_calls`, or `error`.
* `system_fingerprint` is always `null`.
* `usage`: `prompt_tokens`, `completion_tokens`, `total_tokens`, plus `reasoning_tokens`, `server_tool_use`, cached-token details, and `customer_cost` when relevant. See [Check Usage](/api/get-started/check-usage).

## Errors

Validation problems return `400` with `{"error": {"message", "code", "param"}}`. Non-POST requests return `405` with `Allow`. All responses carry `Cache-Control: no-store`. See the [error reference](/api/api-reference/errors-and-rate-limits/error-codes).

## Other Text Endpoints

* `POST /v1/messages` for Anthropic-shaped clients. See the [Anthropic drop-in](/api/get-started/quickstart-anthropic-sdk).
* `POST /v1/responses` for stateless Responses-API clients. See the [Responses reference](/api/api-reference/endpoints/responses/createopenairesponse).

## Related

<CardGroup cols={3}>
  <Card title="Tool Calling" icon="wrench" href="/api/features/tool-calling">
    Function calls.
  </Card>

  <Card title="Reasoning" icon="brain" href="/api/features/reasoning">
    Think first.
  </Card>

  <Card title="Streaming" icon="bolt" href="/api/features/streaming">
    Token by token.
  </Card>

  <Card title="Privacy Levels" icon="shield-check" href="/privacy/levels">
    The four levels.
  </Card>

  <Card title="Chat Completions Endpoint" icon="book" href="/api/api-reference/chat-and-text/chat-completions">
    Schema reference.
  </Card>

  <Card title="Model ID Convention" icon="tag" href="/models/model-id-convention">
    IDs and suffixes.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.