跳转到主要内容
厂商: Anthropic Model ID: claude-opus-4-8 能力: 200K context · tool use · vision · prompt caching · streaming · extended thinking 价格: 按 token,Opus 档(实时价格 Opus 4.8 是当前的 Anthropic 旗舰,也是 Opus 4.7 的 后继。当那一发必须对时你伸手抓的就是它。它比 Sonnet 慢、比 Sonnet 贵,并且在 Sonnet 开始偷工减料的地方明显更稳:长上下文推理、每一步 都依赖上一步的多步计划,以及那种 第一稿 就要能编译并匹配既有代码 库架构约定的代码生成。开 extended thinking 后等待变长,但在难题上的 答案质量提升超过延迟成本所暗示的幅度。

请求

curl https://llm.bytespike.ai/v1/messages \
  -H "x-api-key: $BYTESPIKE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 16384,
    "messages": [
      {"role": "user", "content": "Implement an LRU cache with O(1) get and put."}
    ]
  }'

Body 参数

字段类型是否必填默认说明
modelstringclaude-opus-4-8
messagesarray对话历史。最多 200K token 输入。
max_tokensinteger硬上限。本模型最大:32768。
systemstring | arrayarray 形式支持 cache_control
temperaturenumber1.0范围 0.0–1.0。
top_pnumber1.0Nucleus sampling。
toolsarray支持,并行调用支持。
tool_choiceobject{"type":"auto"}auto / any / tool(指定名)。
thinkingobjectExtended-thinking。预算越大,长程推理答案越好,延迟越高。
streambooleanfalseSSE 流式。

响应

{
  "id": "msg_opus_…",
  "type": "message",
  "role": "assistant",
  "model": "claude-opus-4-8",
  "content": [
    {"type": "thinking", "thinking": "<extended reasoning trace>"},
    {"type": "text", "text": "Here's the LRU cache..."}
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 32,
    "output_tokens": 1248,
    "thinking_tokens": 4032
  }
}
thinking_tokens 按输入 token 价计费(extended thinking 增加延迟但不 增加全额输出成本)。当前价格见 pricing table

代码示例

curl https://llm.bytespike.ai/v1/messages \
  -H "x-api-key: $BYTESPIKE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 16384,
    "messages": [{"role": "user", "content": "Implement an LRU cache with O(1) get and put."}]
  }'

Extended thinking

设置 thinking 块来开启:
{
  "model": "claude-opus-4-8",
  "max_tokens": 16384,
  "thinking": {
    "type": "enabled",
    "budget_tokens": 8192
  },
  "messages": [...]
}
budget_tokens 是内部推理 token 的上限。模型可能用得更少;下限是几 百。推荐预算:
任务建议预算
多步编码4K–8K
长上下文总结8K–16K
难题数学 / 证明16K–32K
更高预算在难题上单调提升答案质量 —— 但多数任务在 16K 以上边际收益 迅速下降。

Cache control

{
  "model": "claude-opus-4-8",
  "system": [
    {
      "type": "text",
      "text": "<the corpus you keep referring to>",
      "cache_control": {"type": "ephemeral"}
    }
  ],
  "messages": [...]
}
缓存读取按 pricing table 的折扣价计 费。在 Opus 4.8 上,cache control 是单项杠杆最高的成本优化 —— 大块 system prompt 付一次,每个后续轮次按缓存读取价计费。

错误

Code触发是否计费
400Body 校验失败
401key 缺失 / 已撤销
402钱包用尽(Opus 比 Sonnet 触发得更快)
413输入超过 200K token
429速率限制
5xx上游 provider 问题否(自动重试信封)

何时使用

  • 一发即中的质量重要,并且你愿意等一个深思熟虑的答案。
  • 在既有代码库中、约定重要的代码生成。
  • 每一步都依赖上一步的多步计划(Sonnet 开始漏;Opus 4.8 把链条保持紧)。
  • 200K 窗口内法律 / 医学 / 技术语料的长上下文推理。
  • 中端成本 / 延迟,见 Sonnet 4.6
  • 高吞吐 agent loop,见 Haiku 4.5

限制

限制
Context window200K tokens
Max output32768 tokens
支持 tool use是(并行)
支持 vision
支持 streaming
支持 prompt caching
支持 extended thinking