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

# Claude Opus 5

> 通过 AnyFast 调用 Anthropic 的 Claude Opus 5。具备 1M 上下文，适用于深度推理、复杂智能体编码和长时企业任务。

Claude Opus 5 是 Anthropic 面向复杂智能体编码和企业任务的 Opus 模型，通过 AnyFast 以原生 Anthropic Messages API 提供服务。相比 Claude Opus 4.8，它进一步增强了深度推理、长时工具调用、代码审查、视觉理解和多智能体协作能力。

## 核心能力

* **1M 上下文窗口** — 默认 1M Token，最大输出 Token 为 128K
* **自适应思维** — 默认开启，通过 `output_config.effort` 控制推理深度
* **五档 effort** — 支持 `low`、`medium`、`high`、`xhigh` 和 `max`，默认值为 `high`
* **智能体编码** — 适合多文件功能开发、大型重构、代码审查和长时工具调用
* **视觉与长上下文** — 可处理图片、图表、文档和示意图，并在长输入中保持稳定理解
* **工具与流式输出** — 通过 Messages API 支持工具调用和 SSE 实时响应
* **模型 ID** — 使用 `claude-opus-5`

## 快速示例

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/messages \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "claude-opus-5",
      "max_tokens": 4096,
      "output_config": { "effort": "high" },
      "messages": [
        { "role": "user", "content": "写一个 Python 函数合并两个有序数组。" }
      ]
    }'
  ```

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

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

  message = client.messages.create(
      model="claude-opus-5",
      max_tokens=4096,
      output_config={"effort": "high"},
      messages=[
          {"role": "user", "content": "写一个 Python 函数合并两个有序数组。"}
      ]
  )

  print(message.content[0].text)
  ```

  ```python 流式输出 theme={null}
  import anthropic

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

  with client.messages.stream(
      model="claude-opus-5",
      max_tokens=1024,
      messages=[
          {"role": "user", "content": "解释异步编程和同步编程的区别。"}
      ],
  ) as stream:
      for text in stream.text_stream:
          print(text, end="")
  ```
</CodeGroup>

## 参数说明

| 参数               | 类型      | 必填 | 说明                                                                                  |
| ---------------- | ------- | -- | ----------------------------------------------------------------------------------- |
| `model`          | string  | 是  | 固定为 `claude-opus-5`                                                                 |
| `messages`       | array   | 是  | `{ role, content }` 对象数组                                                            |
| `max_tokens`     | integer | 是  | 最大生成 Token 数。Claude Opus 5 最多支持 128K 输出 Token。                                      |
| `output_config`  | object  | 否  | 使用 `{"effort":"low" \| "medium" \| "high" \| "xhigh" \| "max"}` 控制自适应思维深度。默认 `high` |
| `thinking`       | object  | 否  | 省略时使用默认自适应思维，或使用 `{"type":"disabled"}` 关闭思维。                                        |
| `stream`         | boolean | 否  | 开启 SSE 流式传输，默认 `false`                                                              |
| `stop_sequences` | array   | 否  | 触发停止生成的序列                                                                           |

<Note>
  Claude Opus 5 默认使用自适应思维。`max_tokens` 会同时限制思维 Token 和可见回答 Token，因此在 `xhigh` 或 `max` 任务中应设置足够大的值。
</Note>

<Warning>
  手动扩展思维（`thinking: {type: "enabled", budget_tokens: N}`）以及非默认的 `temperature`、`top_p`、`top_k` 会返回 400 错误。仅在 `low`、`medium` 或 `high` effort 下可以使用 `thinking: {type: "disabled"}` 关闭思维；与 `xhigh` 或 `max` 组合也会返回 400 错误。
</Warning>

<Card title="API 参考" icon="code" href="/zh/api-reference/model-api/anthropic/claude-opus-5">
  查看 Claude Opus 5 的交互式 API Playground。
</Card>

<script src="/feedback.js" />
