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

# TokModel API reference overview

> Complete reference for the TokModel API. Covers the base URL, authentication header, content type, all available endpoints, and standard HTTP error codes.

TokModel exposes a single base URL through which you can reach every supported endpoint. All requests require a TokModel API key, and all request and response bodies use JSON. The sections below describe the connection details, list every available endpoint, and document the error codes you may encounter.

## Base URL

All API requests are sent to:

```
https://tokmodel.com
```

## Authentication

Include your API key in the `Authorization` header of every request:

```
Authorization: Bearer YOUR_API_KEY
```

You can create and manage API keys from the [TokModel console](https://tokmodel.com/console).

## Content type

Set `Content-Type: application/json` on all requests that include a body. Multipart file upload endpoints (audio transcription, audio translation, image edits, and image variations) use `multipart/form-data` instead.

## Endpoints

| Method | Path                       | Description                                                                            |
| ------ | -------------------------- | -------------------------------------------------------------------------------------- |
| `POST` | `/v1/chat/completions`     | [Chat completions](/api-reference/chat-completions) — OpenAI-compatible chat interface |
| `POST` | `/v1/responses`            | [Responses](/api-reference/responses) — OpenAI Responses API format                    |
| `POST` | `/v1/responses/compact`    | [Responses (compact)](/api-reference/responses) — Returns output text only             |
| `POST` | `/v1/messages`             | [Messages](/api-reference/messages) — Anthropic-compatible messages interface          |
| `GET`  | `/v1beta/models`           | [Models](/api-reference/models) — List all available models                            |
| `POST` | `/v1/embeddings`           | [Embeddings](/api-reference/embeddings) — Generate text embeddings                     |
| `POST` | `/v1/rerank`               | [Rerank](/api-reference/rerank) — Rerank documents by relevance                        |
| `POST` | `/v1/images/generations`   | [Image generation](/api-reference/images) — Generate images from a prompt              |
| `POST` | `/v1/images/edits`         | [Image edits](/api-reference/images) — Edit an image with a prompt and mask            |
| `POST` | `/v1/images/variations`    | [Image variations](/api-reference/images) — Create variations of an image              |
| `POST` | `/v1/audio/speech`         | [Text-to-speech](/api-reference/audio) — Synthesize speech from text                   |
| `POST` | `/v1/audio/transcriptions` | [Transcription](/api-reference/audio) — Transcribe audio to text                       |
| `POST` | `/v1/audio/translations`   | [Translation](/api-reference/audio) — Translate audio to English text                  |

## Error codes

TokModel returns standard HTTP status codes. When a request fails, the response body contains an `error` object with a `message` field describing the problem.

| Status | Name                  | Description                                                                              |
| ------ | --------------------- | ---------------------------------------------------------------------------------------- |
| `400`  | Bad Request           | The request body is malformed or a required parameter is missing.                        |
| `401`  | Unauthorized          | The `Authorization` header is absent or the API key is invalid.                          |
| `403`  | Forbidden             | Your API key is valid but your account has insufficient credits to complete the request. |
| `404`  | Not Found             | The requested endpoint or resource does not exist.                                       |
| `429`  | Too Many Requests     | You have exceeded the rate limit. Back off and retry after a short delay.                |
| `500`  | Internal Server Error | An unexpected error occurred on TokModel's servers. Retry the request.                   |

### Example error response

```json theme={null}
{
  "error": {
    "message": "Invalid API key provided.",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```
