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

# Chat Completions

> The OpenAI-compatible chat completions endpoint.

Valkyrie serves deployed models through the OpenAI Chat Completions contract.

## Endpoint

```
POST https://valkyrie-back.azumo.com/{deployment_slug}/v1/chat/completions
```

With an [alias](https://docs.valkyrieapp.azumo.com/guides/aliases.md):

```
POST https://valkyrie-back.azumo.com/{account_slug}/{alias}/v1/chat/completions
```

An alias can point at a deployment or an inference pool. A pool alias sends each
request to a pool member, needs an account-wide API key, and uses the pool's model
whatever `model` you send. Send `X-Session-Affinity` to keep a session on one member.
See [Point an alias at an inference pool](https://docs.valkyrieapp.azumo.com/guides/aliases.md#point-an-alias-at-an-inference-pool).

## Request

Send the standard OpenAI Chat Completions body. Common fields:

| Field | Type | Notes |
| - | - | - |
| `model` | string | Your deployment slug or alias |
| `messages` | array | Conversation, each `{ "role", "content" }` |
| `temperature` | number | Sampling temperature (optional) |
| `max_tokens` | integer | Maximum tokens to generate (optional) |
| `stream` | boolean | Stream tokens as server-sent events (optional) |

```bash theme={null}
curl https://valkyrie-back.azumo.com/{deployment_slug}/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $VALKYRIE_API_KEY" \
  -d '{
    "model": "{deployment_slug}",
    "messages": [
      {"role": "system", "content": "You are concise."},
      {"role": "user", "content": "What is Valkyrie?"}
    ],
    "temperature": 0.7,
    "max_tokens": 256
  }'
```

## Response

The response follows the OpenAI shape:

```json theme={null}
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "{deployment_slug}",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
```

## Streaming

Set `"stream": true` to receive incremental `chat.completion.chunk` events as
server-sent events, terminated by a `[DONE]` sentinel, identical to the OpenAI
streaming format. The OpenAI SDKs expose this through their streaming helpers.

> [!NOTE]
>
> Supported sampling parameters and context length depend on the deployed model and
> its serving engine. If a deployment is stopped, requests fail until it is resumed.


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