# API reference

> The base URL, authentication, request format and versioning for the Antarya API.

## Overview

The Antarya API is a plain web API. Send JSON to `https://antarya.ai/v1` and read JSON back. Every endpoint below uses the same key, the same error shape and the same headers.

| Endpoint | Purpose |
|---|---|
| `POST /v1/chat` | Reply to a conversation, as one body or as a stream. |
| [`/v1/sessions`](https://antarya.ai/docs/api/sessions.md) | Keep a conversation on Antarya's side and add to it turn by turn. |
| [`POST /v1/chat/completions`](https://antarya.ai/docs/api/openai-compatibility.md) | The OpenAI-shaped door, for clients written for OpenAI. |
| `POST /v1/count-tokens` | Count the input tokens of a chat request. |
| `/v1/files` | Upload, list, fetch and delete files for use in messages. |
| `/v1/batches` | Run many chat requests at once and collect the replies later. |
| `GET /v1/models` | List models and describe one. Paged lists (sessions and files) reply as `{object: "list", data, has_more}`. The models list is not paged and has no `has_more`. |

## Base URL

```
https://antarya.ai/v1
```

## Authentication

Send your key in the `Authorization` header on every request. Keys start with `ak-`. Make one on the Keys page of the platform, and keep it out of code that runs in a browser.

```bash
curl https://antarya.ai/v1/models \
  -H "Authorization: Bearer $ANTARYA_API_KEY"
```

```python
from antarya import Antarya

client = Antarya()  # reads ANTARYA_API_KEY
models = client.models.list()
```

```typescript
import Antarya from "antarya";

const client = new Antarya(); // reads ANTARYA_API_KEY
const models = await client.models.list();
```

Output:

```
{
  "data": [
    {"id": "antarya"}
  ]
}
```

## Requests and replies

Bodies are JSON, sent with `Content-Type: application/json`. The one exception is a file upload, which is multipart form data. Replies are JSON, or server-sent events when a chat request sets `stream` to true.

## Request ids

Every reply carries a `request-id` header. A failed request also returns the same value as `request_id` in its body. Include it when you write to support, and Antarya can find the request.

## Versioning

The version is part of the path. `/v1` stays as it is: new fields and new endpoints can appear in it, and nothing in it is removed or renamed. A change that breaks existing requests ships as `/v2`, and `/v1` keeps working alongside it. Write your code to ignore fields it does not know.

## Next steps

- [Chat](https://antarya.ai/docs/api/chat.md): Send a conversation and read the reply.
- [Errors](https://antarya.ai/docs/api/errors.md): Every status, its type and what to do.
- [Rate limits](https://antarya.ai/docs/api/rate-limits.md): How many requests a key and an account can make.
