Claude Opus 4.6

Anthropic Claude Opus 4.6 旗舰推理模型。原生 /v1/messages 协议,支持流式输出、工具调用和可选的扩展思考(thinking)。

模型

模型名称上下文窗口推理
claude-opus-4-6200K tokens是(可选 thinkingFlag

定价

按 token 计费:

类型积分 / 百万 tokens价格 / 百万 tokens
输入 (Input)500 credits$2.50
输出 (Output)2500 credits$12.50

接口地址

POST https://api.aivideoapi.ai/v1/messages

兼容 Anthropic Messages API 协议。可直接使用 @anthropic-ai/sdk,将 baseURL 指向 https://api.aivideoapi.ai/v1

创建对话

curl -X POST https://api.aivideoapi.ai/v1/messages \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "messages": [
      { "role": "user", "content": "用简单的语言解释量子计算" }
    ],
    "stream": false
  }'

请求体

字段类型必填说明
modelstring必须为 claude-opus-4-6
messagesarray对话消息列表
streamboolean是否流式输出(默认 true
toolsarray可调用工具,每项含 name/description/input_schema
thinkingFlagboolean是否开启扩展思考

Messages

{
  "role": "user",
  "content": "你好"
}

或多模态内容块数组:

{
  "role": "user",
  "content": [
    { "type": "text", "text": "这张图是什么?" },
    { "type": "image", "source": { "type": "url", "url": "https://example.com/photo.jpg" } }
  ]
}

响应(非流式)

{
  "role": "assistant",
  "type": "message",
  "id": "msg_bbb32326-155e-4dec-aa49-9899e2cada52",
  "model": "claude-opus-4-6",
  "stop_reason": "end_turn",
  "content": [
    { "type": "text", "text": "量子计算使用量子比特..." }
  ],
  "usage": {
    "input_tokens": 20,
    "output_tokens": 661
  },
  "credits_consumed": 1.66
}
字段类型说明
idstring消息唯一 ID
typestring固定为 message
rolestring固定为 assistant
modelstring实际响应模型
stop_reasonstring终止原因(end_turn / max_tokens / stop_sequence / tool_use
contentarray响应内容块数组(texttool_use
usage.input_tokensint输入 token 数
usage.output_tokensint输出 token 数
credits_consumednumber本次实际扣费积分(按本平台单价计算,与上游内部值无关)

响应(流式)

stream: true 时返回 SSE 事件流:

event: message_start
data: {"type":"message_start","message":{"id":"msg_...","usage":{"input_tokens":12,"output_tokens":1}}}

event: content_block_delta
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"量子"}}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":86}}

event: message_stop
data: {"type":"message_stop"}

示例

函数调用

curl -X POST https://api.aivideoapi.ai/v1/messages \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "messages": [
      { "role": "user", "content": "波士顿今天天气怎么样?" }
    ],
    "tools": [
      {
        "name": "get_current_weather",
        "description": "获取指定城市的当前天气",
        "input_schema": {
          "type": "object",
          "properties": {
            "location": { "type": "string", "description": "城市,例如 Boston, MA" }
          },
          "required": ["location"]
        }
      }
    ],
    "stream": false
  }'

开启扩展思考

curl -X POST https://api.aivideoapi.ai/v1/messages \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "messages": [
      { "role": "user", "content": "证明:素数有无穷多个" }
    ],
    "thinkingFlag": true
  }'

常见错误码

请求失败时,API 返回 JSON 格式的错误响应:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your credit balance is too low. Please top up.",
    "type": "billing_error"
  }
}

错误码一览

HTTP 状态码错误码类型说明
400invalid_requestinvalid_request_error缺少必填参数或参数无效
401invalid_api_keyauthentication_errorAPI Key 无效、已禁用或已删除
402insufficient_creditsbilling_error积分余额不足,请充值
403ip_not_allowedpermission_error请求 IP 不在 Key 的白名单中
404model_not_foundinvalid_request_error模型不存在或已停用
404task_not_foundinvalid_request_error任务 ID 不存在
429rate_limit_exceededrate_limit_error请求过于频繁,请降低频率
429spend_limit_exceededbilling_error达到 Key 的消费限额(每小时/每天/总量)
500internal_errorapi_error服务器内部错误
503upstream_errorupstream_error上游 AI 服务返回错误

常见场景

invalid_request (400)

缺少必填字段或参数格式错误时返回。

{
  "error": {
    "code": "invalid_request",
    "message": "'model' is required.",
    "type": "invalid_request_error"
  }
}

insufficient_credits (402)

积分不足。可通过 GET /v1/credits 查询余额,前往 Dashboard > Billing 充值。

invalid_api_key (401)

可能原因:

  • Key 不以 sk- 开头
  • Key 已被禁用或删除
  • 用户账户已被封禁

upstream_error (503)

上游 AI 服务返回错误,可能原因:

  • 输入内容包含敏感或违规信息
  • 上游服务暂时不可用
  • 请求参数不被上游支持

因上游错误导致任务失败时,预扣积分会自动退还。