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

# Anthropic Claude models

> The Claude Haiku / Sonnet / Opus series, including thinking mode

OpenPAI integrates Anthropic Claude over two protocols at once: **OpenAI-compatible** and the **Claude-native `/v1/messages`**.

## Available models

| Model ID            | Context | Max output | Positioning                                                                        |
| ------------------- | ------- | ---------- | ---------------------------------------------------------------------------------- |
| `claude-opus-4-8`   | 1M      | 128K       | Latest top tier — strongest at complex reasoning and long-horizon agentic coding   |
| `claude-sonnet-4-6` | 1M      | 64K        | Best balance of speed and intelligence — recommended for code / reasoning / agents |
| `claude-haiku-4-5`  | 200K    | 64K        | Fastest, near-frontier intelligence — first choice for everyday chat and code      |

### Legacy (still available)

| Model ID                     | Context | Notes                    |
| ---------------------------- | ------- | ------------------------ |
| `claude-opus-4-7`            | 1M      | Previous-gen top tier    |
| `claude-opus-4-5`            | 200K    | Older flagship           |
| `claude-sonnet-4-5`          | 200K    | Previous-gen Sonnet      |
| `claude-3-7-sonnet-20250219` | 200K    | Interim version          |
| `claude-3-5-sonnet-20241022` | 200K    | Older, for compatibility |

## Thinking

Claude can reason internally before the final answer. There are two approaches across generations:

* **Extended Thinking**: `claude-sonnet-4-6` and `claude-haiku-4-5` set a `budget_tokens` thinking budget via the `thinking` parameter.
* **Adaptive Thinking**: `claude-opus-4-8` and `claude-opus-4-7` are controlled by the `effort` parameter (`low` / `medium` / `high`); Opus 4.8 defaults to `high` and no longer uses `budget_tokens`.

### Enable extended thinking via model ID

| Model ID                     | Behavior                                   |
| ---------------------------- | ------------------------------------------ |
| `claude-sonnet-4-6-thinking` | Sonnet 4.6, thinking enabled automatically |
| `claude-haiku-4-5-thinking`  | Haiku 4.5, thinking enabled automatically  |

### Enable via parameter (Claude native protocol)

```bash theme={null}
# Extended thinking: Sonnet 4.6 / Haiku 4.5
curl https://openp.ai/v1/messages \
  -H "x-api-key: $OPENPAI_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 4096,
    "thinking": { "type": "enabled", "budget_tokens": 8000 },
    "messages": [{"role": "user", "content": "Prove Goldbach's conjecture"}]
  }'
```

```bash theme={null}
# Adaptive thinking: Opus 4.8 (effort defaults to high)
curl https://openp.ai/v1/messages \
  -H "x-api-key: $OPENPAI_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 4096,
    "effort": "high",
    "messages": [{"role": "user", "content": "Prove Goldbach's conjecture"}]
  }'
```

<Note>Tokens produced by thinking and tokens in the final answer are **billed separately** (thinking\_tokens vs. output\_tokens), shown distinctly in the console log. Exact parameter support is subject to the console.</Note>

## Examples

### OpenAI-compatible protocol

```python theme={null}
from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://openp.ai/v1")

resp = client.chat.completions.create(
    model="claude-opus-4-8",
    messages=[
        {"role": "system", "content": "You are a senior Go engineer."},
        {"role": "user", "content": "Implement a consistent-hashing ring in Go."},
    ],
)
```

### Claude native SDK

```python theme={null}
from anthropic import Anthropic

client = Anthropic(
    api_key="sk-XXXXXXXXXXXXXXXX",
    base_url="https://openp.ai",
)

resp = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=2048,
    system="You are a senior Go engineer.",
    messages=[{"role": "user", "content": "Implement a consistent-hashing ring in Go."}],
)
print(resp.content[0].text)
```

## Tool calling

Claude natively supports the three-step `tools` / `tool_use` / `tool_result` tool-calling flow, fully compatible with the official Anthropic protocol.
When accessed via the OpenAI-compatible endpoint, tool calls are automatically converted to OpenAI's `tools` / `tool_calls` structures.
See [Function calling](/en/advanced/function-calling).

## Vision

Supports image URL and base64 input:

```json theme={null}
{
  "model": "claude-opus-4-8",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "What's in the image?"},
        {"type": "image_url", "image_url": {"url": "https://example.com/x.png"}}
      ]
    }
  ]
}
```

## Prompt caching

Claude supports marking long context segments with `cache_control` to hit the prompt cache, with cache hits billed at a lower rate.
OpenPAI passes this field through verbatim — see [Cache billing](/en/pricing/cache-billing).

## Other capabilities

Anthropic also offers **Message Batches (asynchronous, \~50% off)**, the **Files API**, **1M long context**, **citations**, and **memory**. Whether these are exposed through the OpenPAI gateway is subject to the **console / site announcements**.

## API docs

* [Claude Messages API](/en/api-reference/anthropic/messages)
* [Count Tokens API](/en/api-reference/anthropic/count-tokens)
