# Chat completions

Send OpenAI-compatible chat requests for an enabled model and pool. Use Bearer authentication.

Source: https://zrelay.net/docs/api/chat-completions/

## Request

```
curl https://api.zrelay.net/v1/chat/completions \
  -H "Authorization: Bearer $ZRELAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6.1-sol","messages":[{"role":"user","content":"Hello from Zrelay"}],"max_tokens":256}'
```

## Core request fields

| Field | Meaning |
| --- | --- |
| model | Required exact model identifier from the selected pool |
| messages | Conversation messages in Chat Completions format |
| max_tokens | Bounded output budget; accepted controls depend on model |
| stream | Optional true for server-sent events |
| tools | Optional tool schemas on models that support tools |

## Response

```
{
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello!"
      },
      "finish_reason": "stop"
    }
  ]
}
```

This is a partial response shape, not a complete schema. Tool responses can carry `tool_calls` instead of text. Usage details and optional fields depend on the selected route.

## Grok and other chat models

For Grok, DeepSeek, Gemini, GLM and Kimi chat routes, use an exact enabled model ID and a matching key. Availability and endpoint support follow the catalog; do not send an Anthropic Messages body to this endpoint.

Examples demonstrate request formats. Select an enabled model, endpoint and pool from the [live catalog](https://zrelay.net/prices.html#per-model) before sending a request. Availability and rates can change.

## Streaming and failures

See [Streaming](https://zrelay.net/docs/md/capabilities/streaming.md), [Tool calling](https://zrelay.net/docs/md/capabilities/tool-calling.md) and [Errors](https://zrelay.net/docs/md/api/errors.md).
