# Claude Opus 4.7

## Model and endpoint

Use `claude-opus-4-7` with `POST https://api.toklab.ai/v1/messages`. Keep your TokLab API key on the server.

This reference covers the core text-generation request. Optional reasoning, tool and sampling controls depend on the model and selected route; do not assume that settings from another model version are interchangeable.

## Quick example

```bash
curl https://api.toklab.ai/v1/messages \
  -H "x-api-key: $TOKLAB_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-opus-4-7", "max_tokens": 1024, "messages": [{"role": "user", "content": "Explain optimistic concurrency in three bullet points."}]}'
```

### Python

```python
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["TOKLAB_API_KEY"],
    base_url="https://api.toklab.ai",
)
response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Explain optimistic concurrency."}],
)
print("".join(block.text for block in response.content if block.type == "text"))
```

## Request parameters

| Field        | Type                     | Usage                                                             |
| ------------ | ------------------------ | ----------------------------------------------------------------- |
| `model`      | string                   | Required; `claude-opus-4-7` or an available full `model:group` ID |
| `messages`   | object\[]                | Required conversation turns; each has `role` and `content`        |
| `max_tokens` | integer                  | Required positive output-token budget; the example uses 1024      |
| `system`     | string or content blocks | Optional system instructions                                      |
| `stream`     | boolean                  | Optional; `true` returns server-sent events                       |

Omit optional controls to use the upstream defaults. Token budgets must fit the selected model's context and output limits; this reference does not advertise unverified limits.

## Response and streaming

The JSON response contains `id`, `model`, `content`, `stop_reason`, and `usage`. Read text blocks from `content` where `type` is `text`.

Set `stream: true` and add `-N` to cURL to consume the event stream. For streaming, handle `message_start`, `content_block_delta`, `message_delta`, and `message_stop` events. Text deltas are carried in `delta.text`. A closed connection alone does not establish a successful response.

## Chat Completions compatibility

The shared gateway also accepts `POST /v1/chat/completions` with Bearer authentication:

```json
{
  "model": "claude-opus-4-7",
  "messages": [
    {
      "role": "user",
      "content": "Explain optimistic concurrency."
    }
  ]
}
```

Read the answer from `choices[0].message.content`; streamed deltas appear in `choices[0].delta.content`. Use the native endpoint above for provider-specific features.

## Pricing and route selection

TokLab reads prices from the shared gateway. Input, output, cache usage and any context-length tiers are listed in **Current rates** below; all amounts are USD. The catalogue's starting price is the input rate per million tokens, not the total request cost.

Discover the calling IDs available to your key:

```bash
curl https://api.toklab.ai/v1/models \
  -H "Authorization: Bearer $TOKLAB_API_KEY"
```

Use an exact ID returned by discovery. A listed `model:group` ID selects that group's rates and requires access to that group. Public pricing alone does not guarantee that every key can call a route.

## Errors

Check the HTTP status and response body before reading the output. Authentication failures return 401; access or permission failures may return 403; malformed or unsupported parameters return a 4xx response; rate limits return 429. Retry transient errors with backoff, and avoid automatically resubmitting an interrupted request whose outcome is unknown. See the [shared error reference](https://toklab.ai/docs/api/errors).

## Pricing

Every rate this model is billed at, read live from the price list billing uses. A tier applies when its condition matches, checked top to bottom.

### claude-opus-4-7

| Input (per 1M tokens) | Output (per 1M tokens) | Cache read (per 1M tokens) | Cache write (5 min) (per 1M tokens) | Cache write (1 h) (per 1M tokens) |
| --- | --- | --- | --- | --- |
| $1.75 | $8.75 | $0.175 | $2.1875 | $3.50 |

Price tier AWSB (`claude-opus-4-7:claude-0.7`):

| Input (per 1M tokens) | Output (per 1M tokens) | Cache read (per 1M tokens) | Cache write (5 min) (per 1M tokens) | Cache write (1 h) (per 1M tokens) |
| --- | --- | --- | --- | --- |
| $3.50 | $17.50 | $0.35 | $4.375 | $7.00 |

## Related

* [Browse models](https://toklab.ai/models)
* [Pricing](https://toklab.ai/pricing)
* [Download OpenAPI](https://toklab.ai/docs/claude-opus-4-7.openapi.json)
* [Copyable Markdown](https://toklab.ai/docs/claude-opus-4-7.md)
