跳转至

Claude Sonnet 4.6

Anthropic 当前兼顾速度与智能的主力模型,适合生产级编程、Agent 编排与企业工作流。

模型信息

属性
模型ID claude-sonnet-4-6
任务类型 对话(Chat)/ 推理 / 编程 / Agent
输入 文本 / 图片 / 文档(PDF、纯文本)/ 工具结果
输出 文本 / 思考块 / 工具调用块
标准上下文窗口 200K tokens
扩展上下文窗口 1M tokens(beta,需要 anthropic-beta: context-1m-2025-08-07
最大输出 64K tokens
视觉理解 支持
扩展思考 支持,兼容手动思考与自适应思考

支持的能力

能力 支持
文本生成
图片输入
PDF / 文档输入
流式输出
扩展思考
自适应思考
手动思考预算 是(thinking.type: "enabled"
工具调用
结构化输出
Prompt Caching
Batch API
数据驻留控制 是(inference_geo

API 调用

端点

POST https://api.anthropic.com/v1/messages

请求头

参数 类型 必填 说明
Content-Type string 固定为 application/json
X-Api-Key string 直接传入 Anthropic API Key
anthropic-version string 当前文档示例为 2023-06-01
anthropic-beta string 可选 beta 头;如启用 1M 上下文需传 context-1m-2025-08-07

请求参数

参数 类型 必填 默认值 说明
model string - 模型 ID,填写 claude-sonnet-4-6
max_tokens integer - 最大输出 token 数;Sonnet 4.6 最高 64K
messages object[] - 对话消息列表;支持文本、图片、文档与工具结果内容块
system string / object[] - 系统提示,可传字符串或文本块数组
stream boolean false 是否使用 SSE 流式返回
stop_sequences string[] - 自定义停止序列
temperature number 1.0 采样温度,范围 0.0-1.0
top_p number - nucleus sampling 参数,范围 0-1
top_k integer - top-k 采样参数
thinking object - 扩展思考配置;Sonnet 4.6 支持 type:"enabled" + budget_tokens,也支持 type:"adaptive"
output_config object - 输出控制项,可设置 effortformat
tools object[] - 工具定义列表
tool_choice object auto 工具策略,可选 auto / any / tool / none
metadata object - 请求元数据,目前公开字段为 user_id
inference_geo string 工作区默认值 指定推理区域,如 globalus
service_tier string auto 服务层级选择,autostandard_only

请求示例(手动扩展思考)

curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 4096,
    "thinking": {
      "type": "enabled",
      "budget_tokens": 2048
    },
    "messages": [
      {
        "role": "user",
        "content": "请比较单体应用拆分为模块化单体与微服务的主要取舍,并给出迁移建议。"
      }
    ]
  }'

请求示例(结构化输出)

curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 2048,
    "output_config": {
      "format": {
        "type": "json_schema",
        "schema": {
          "type": "object",
          "properties": {
            "summary": {"type": "string"},
            "risks": {
              "type": "array",
              "items": {"type": "string"}
            }
          },
          "required": ["summary", "risks"]
        }
      }
    },
    "messages": [
      {
        "role": "user",
        "content": "请总结这段系统设计方案的优缺点。"
      }
    ]
  }'

响应示例

{
  "id": "msg_01XYZabc",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-6",
  "content": [
    {
      "type": "thinking",
      "thinking": "..."
    },
    {
      "type": "text",
      "text": "下面从架构复杂度、交付节奏和运维成本三个角度进行比较。"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 96,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 438
  }
}

注意事项

  • Sonnet 4.6 支持手动扩展思考(type:"enabled" + budget_tokens)以及自适应思考。
  • 若使用带工具的交错思考,Anthropic 文档说明 Sonnet 4.6 可通过手动思考配合 interleaved-thinking-2025-05-14 beta 头启用;使用自适应思考时会自动启用交错思考。
  • output_config.format 是结构化输出的当前参数位置;旧版 output_format 仍可用但已弃用。
  • 1M 上下文窗口为 beta,且仅对符合条件的组织开放。

计费

按美元 / 百万 token 计费。

项目 价格
输入 $3 / MTok
输出 $15 / MTok
5 分钟缓存写入 $3.75 / MTok
1 小时缓存写入 $6 / MTok
缓存读取 $0.30 / MTok
Batch API 输入 $1.50 / MTok
Batch API 输出 $7.50 / MTok

长上下文说明

  • Anthropic 官方上下文窗口文档明确写明 Claude Sonnet 4.6 支持 1M token 上下文窗口 beta。
  • 定价页对 Sonnet 长上下文高级费率的表格当前仍写为 “Claude Sonnet 4.5 / 4”;由于页面尚未单独列出 Sonnet 4.6 的这一行,这里不做额外推断,长上下文计费请以官方最新定价页为准。

数据来源

  • 模型概览:https://platform.claude.com/docs/zh-CN/about-claude/models/overview
  • Claude 4.6 新功能:https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-6
  • Create a Message:https://platform.claude.com/docs/en/api/messages/create
  • 定价:https://platform.claude.com/docs/zh-CN/about-claude/pricing
  • 上下文窗口:https://platform.claude.com/docs/zh-CN/build-with-claude/context-windows
  • 使用扩展思考进行构建:https://platform.claude.com/docs/zh-CN/build-with-claude/extended-thinking