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

# API formats

> Chat Completions, Messages and Responses: what each supports and what it refuses.

Aesoteric accepts three request formats. All of them use the same keys, models, prices and limits.

| Endpoint | Format |
| - | - |
| `POST /v1/chat/completions` | OpenAI Chat Completions |
| `POST /v1/messages` | Anthropic Messages |
| `POST /v1/messages/count_tokens` | Anthropic token counting, free |
| `POST /v1/responses` | OpenAI Responses |
| `GET /v1/models` | The models you can call |

The base URL is `https://api.aesoteric.ai/v1` for OpenAI clients and `https://api.aesoteric.ai` for Anthropic clients.

Streaming and non-streaming requests work in every format. A request returns one answer.

## Chat Completions

```bash theme={null}
curl https://api.aesoteric.ai/v1/chat/completions \
  -H "Authorization: Bearer $AESOTERIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-id>",
    "messages": [{"role": "user", "content": "Name three prime numbers."}],
    "reasoning_effort": "low",
    "stream": true
  }'
```

* `messages` is required and can't be empty.
* `n` must be 1.
* Set the output limit with `max_tokens` (or `max_completion_tokens`). It can be at most your chosen model's context size minus the input; a larger value is answered `400` with the largest value allowed.
* `reasoning_effort` sets how much a model reasons. Use a value from that model's `reasoning.supported_efforts`, listed in the [model catalog](https://docs.aesoteric.ai/models.md#model-catalog).
* A stream always ends with a chunk that carries `usage`, including `usage.cost`.
* `web_search_options` is answered `400`: there is no web search.

## Messages (Anthropic)

```bash theme={null}
curl https://api.aesoteric.ai/v1/messages \
  -H "x-api-key: $AESOTERIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-id>",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Name three prime numbers."}]
  }'
```

Tool use, `system` as text or blocks, images and streaming events work as in Anthropic's API.

* Send the key as `x-api-key` or `Authorization: Bearer`.
* `model` must be an Aesoteric model id. Claude model names, such as `claude-*`, are answered `404 not_found_error`.
* `max_tokens` is required, and can be at most your chosen model's context size minus the input.
* `thinking` sets the reasoning effort: `disabled` turns it off, `enabled` picks an effort from `budget_tokens` (below 1024 `minimal`, below 2048 `low`, below 4096 `medium`, otherwise `high`), and `adaptive` uses `output_config.effort` or `medium`. `reasoning_effort` also works and wins over `thinking`. Reasoning comes back as `thinking` content blocks.
* `input_tokens` excludes cached input, which is in `cache_read_input_tokens`. `cache_creation_input_tokens` is always 0.
* `cache_control` is accepted and ignored: caching is automatic. See [Prompt caching](https://docs.aesoteric.ai/prompt-caching.md).
* The hosted web search tool (`web_search_*`) is answered `400`, and the whole request is refused. Remove the tool from your request.
* `/v1/messages/batches` is not available.

### Count tokens

`POST /v1/messages/count_tokens` takes the same body without `max_tokens` and answers `{"input_tokens": N}`. Counting is free. It has its own per-minute limit, equal to your tier's requests per minute, so counts never use up your request limit.

```bash theme={null}
curl https://api.aesoteric.ai/v1/messages/count_tokens \
  -H "x-api-key: $AESOTERIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-id>",
    "messages": [{"role": "user", "content": "Name three prime numbers."}]
  }'
```

## Responses

```bash theme={null}
curl https://api.aesoteric.ai/v1/responses \
  -H "Authorization: Bearer $AESOTERIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-id>",
    "input": "Name three prime numbers.",
    "reasoning": {"effort": "low"}
  }'
```

Responses are not stored. Send the whole conversation in `input` each time.

* `store: true`, `background: true`, `previous_response_id`, `conversation` and `prompt` are answered `400`. `store: false` and no `store` work, and every answer says `"store": false`.
* Only `POST /v1/responses` is available: retrieving, deleting, cancelling or compacting a response, `input_items`, `input_tokens` and WebSocket mode are not.
* Tools: `function`, `custom` and `namespace` tools work. Hosted web search (`web_search`, `web_search_preview`) is removed from the request, and a `tool_choice` naming it becomes `auto`. Any other hosted tool (`mcp`, `file_search`, `code_interpreter` and others) is answered `400`.
* `tool_choice` can be `none`, `auto`, `required` or a function or custom tool. Anything else, `allowed_tools` included, is answered `400`.
* `reasoning.effort` sets how much a model reasons. Reasoning comes back as a `reasoning` output item; a stream sends it as `response.reasoning_summary_text` events.
* Set the output limit with `max_output_tokens`.
* `input_tokens` includes cached input, which is also in `input_tokens_details.cached_tokens`.
* `prompt_cache_key` is ignored.
* An input too long for the context is answered with the code `context_length_exceeded`. A stream that fails after it started ends with `response.failed`, never `response.completed`.

## Usage and cost

Every completed answer reports what it is charged, in USD, as `cost` in its usage:

| Format | Where |
| - | - |
| Chat Completions | `usage.cost`; on a stream, the final usage chunk |
| Messages | `usage.cost` in the message, and in the stream's `message_delta` |
| Responses | `usage.cost` in the response, and in the stream's `response.completed` |

`cost` is absent when nothing is charged, such as for a failed request. See [Billing](https://docs.aesoteric.ai/billing.md).


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