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

# Messages (Claude)

> Chat with Claude models through the Anthropic Messages API format — works with the official Anthropic SDKs and Claude Code.

This endpoint speaks the **Anthropic Messages API** format: request body, response body, streaming events and
error shapes are the same as Anthropic's. Point the official Anthropic SDK (or Claude Code) at our base URL and use
your ModelHunter.AI API key.

## Models

| Model | Input / 1M tokens | Output / 1M tokens | Cache read / 1M tokens |
| - | - | - | - |
| `claude-fable-5` | \$10 | \$50 | \$1 |
| `claude-opus-5-5` | \$4 | \$20 | \$0.40 |
| `claude-sonnet-5-5` | \$2 | \$10 | \$0.20 |
| `claude-haiku-5-5` | \$0.10 | \$0.50 | \$0.01 |

> [!NOTE]
>
> `claude-haiku-5-5`: prompts above 100K input tokens are billed at 5× these rates (official tiered pricing).
> Prompt-cache writes are billed at the official cache-write rate.

## Authentication

Send your API key as `x-api-key: YOUR_API_KEY` (what the Anthropic SDKs send) or `Authorization: Bearer YOUR_API_KEY`.

```python Python theme={null}
import anthropic

client = anthropic.Anthropic(
    api_key="YOUR_API_KEY",
    base_url="https://api.modelhunter.ai/api",
)

message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)
```

```javascript JavaScript theme={null}
import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.modelhunter.ai/api',
})

const message = await client.messages.create({
  model: 'claude-sonnet-5-5',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(message.content[0].text)
```

```bash Claude Code theme={null}
export ANTHROPIC_BASE_URL="https://api.modelhunter.ai/api"
export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"
export ANTHROPIC_MODEL="claude-opus-5-5"
claude
```

## Body Parameters

The body follows the Anthropic Messages API. The most common fields:

**model** `string` *required*

One of the models above.

**messages** `object[]` *required*

Conversation turns: `[{ "role": "user" | "assistant", "content": string | content blocks }]`.
Content blocks may include images and tool results.

**max\_tokens** `integer` *required*

Maximum output tokens, including extended thinking.

**system** `string | object[]`

System prompt.

**stream** `boolean` (default: false)

Stream the response as Anthropic server-sent events (`message_start`, `content_block_delta`, `message_delta`, `message_stop`).

**temperature** `number`

Sampling temperature.

**tools** `object[]`

Tool definitions, in Anthropic format.

Other Anthropic fields (`stop_sequences`, `top_p`, `top_k`, `tool_choice`, `thinking`, `metadata`) are passed through unchanged.
Optional headers `anthropic-version` and `anthropic-beta` are forwarded.

## Long requests and streaming

> [!TIP]
>
> **Use `"stream": true` for reasoning models and long outputs.** Tokens arrive as they are generated, so long
> answers never sit idle on the connection. While a stream is waiting for the model (for example while it is
> thinking), we send `: keepalive` SSE comments every 15 seconds; SSE clients and the official SDKs ignore them.
>
> Non-streaming requests that take longer than 15 seconds are also kept alive: the response starts with
> `200 OK` and leading whitespace (ignored by JSON parsers) until the result is ready. If such a request fails
> after that point, the error is returned in the response body with status `200` instead of an error status,
> so check the body for an `error` field.

## Billing

Each call is billed per token at the official price. When the request starts, the maximum possible cost
(estimated input + `max_tokens` of output) is held from your balance; when it finishes you are charged for the
tokens actually used and the rest is released. Failed requests are not charged. Calls appear in your usage
history as `chat` tasks (prompts and responses are not stored).

```json 200 theme={null}
{
  "id": "msg_01AbC...",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5-5",
  "content": [{ "type": "text", "text": "Hello! How can I help you today?" }],
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 9, "output_tokens": 12 }
}
```

```json 400 theme={null}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "\"max_tokens\" is required and must be a positive integer."
  }
}
```


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