BeansAI
模型文档
登录注册
模型文档
登录注册

快速接入

  • 概览

客户端

  • Claude Code
  • CC Switch
  • OpenClaw
  • Roo Code
  • OpenCode
  • Codex CLI
  • GPT Image 2
  • Seedance 2.0
  • SkyReels V4
  • Mureka Song
  • Cursor
  • Cherry Studio

参考

  • Claude 模型
  • 原生 API
← 返回文档首页

Claude 模型

通过 BeansAI 调用 Claude Opus、Sonnet、Haiku 和 Thinking 模型。

概览

Claude 模型既可以走 OpenAI 兼容的 POST /chat/completions,也可以走 Anthropic 原生的 POST /messages。两种方式都使用同一个 BeansAI API Key。

大多数应用先从 claude-sonnet-4-6 开始。复杂推理或长文档用 Fable 或 Opus,高频后台任务用 Haiku。

模型选择

ModelID适合场景上下文 / 输出
Claude Fable 5claude-fable-5Anthropic 最强的广泛发布模型,适合高难度推理、长周期 Agent 和大上下文任务。1M / 128K
Claude Opus 4.8claude-opus-4-8能力最强的 Claude,适合深度研究、大型代码库、长文档和高风险审查。1M / 128K
Claude Opus 4.7claude-opus-4-7高能力 Opus,适合复杂推理、自适应思考和长上下文 Agent 工作。1M / 128K
Claude Opus 4.6claude-opus-4-6需要 Opus 级推理和写作质量,同时希望保持稳定通用表现时使用。1M / 128K
Claude Opus 4.6 (Thinking)claude-opus-4-6-thinking适合需要显式思考预算的复杂推理任务,例如调试、规划和多步骤分析。200K / 64K
Claude Sonnet 4.6claude-sonnet-4-6默认 Claude 选择,适合编码、Agent、聊天产品、工具调用,以及延迟和成本均衡的场景。200K / 64K
Claude Haiku 4.5claude-haiku-4-5-20251001快速、低成本的 Claude,适合分类、抽取、轻量客服回复和后台任务。200K / 64K

OpenAI-compatible

可以直接用 OpenAI 官方 SDK 或原始 HTTP。切换 Claude 模型时只需要替换 model 字段。

shell
curl https://api.beansai.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-beans-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "user", "content": "Write a small TypeScript utility and tests."}
    ],
    "stream": false
  }'
python
from openai import OpenAI

client = OpenAI(
    api_key="sk-beans-...",
    base_url="https://api.beansai.dev/v1",
)

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[
        {"role": "user", "content": "Explain this error and propose a fix."}
    ],
    max_tokens=4096,
)

print(response.choices[0].message.content)

Anthropic Messages

Anthropic 原生客户端可以调用 POST /messages。推荐用 x-api-key 传 BeansAI Key;Authorization: Bearer 也可用。

shell
curl https://api.beansai.dev/v1/messages \
  -H "x-api-key: sk-beans-..." \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-fable-5",
    "max_tokens": 4096,
    "messages": [
      {"role": "user", "content": "Analyze this design and list the top risks."}
    ]
  }'

Thinking

需要显式推理预算时使用 claude-opus-4-6-thinking。OpenAI 兼容请求可以传 reasoning_effort;Anthropic 原生请求可以传 thinking 块。

shell
curl https://api.beansai.dev/v1/messages \
  -H "x-api-key: sk-beans-..." \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6-thinking",
    "max_tokens": 12000,
    "thinking": {
      "type": "enabled",
      "budget_tokens": 8192
    },
    "messages": [
      {"role": "user", "content": "Debug this incident from logs and propose the safest rollback."}
    ]
  }'

各模型示例

下面这些 JSON body 可以直接替换到上面的 curl 示例中。

Claude Fable 5

claude-fable-5

Anthropic 最强的广泛发布模型,适合高难度推理、长周期 Agent 和大上下文任务。

json
{
  "model": "claude-fable-5",
  "messages": [
    {
      "role": "user",
      "content": "Analyze this multi-month migration, identify hidden risks, and produce an execution plan with fallback points."
    }
  ],
  "max_tokens": 4096,
  "stream": false
}

Claude Opus 4.8

claude-opus-4-8

能力最强的 Claude,适合深度研究、大型代码库、长文档和高风险审查。

json
{
  "model": "claude-opus-4-8",
  "messages": [
    {
      "role": "user",
      "content": "Review this architecture, identify failure modes, and propose a phased migration plan."
    }
  ],
  "max_tokens": 4096,
  "stream": false
}

Claude Opus 4.7

claude-opus-4-7

高能力 Opus,适合复杂推理、自适应思考和长上下文 Agent 工作。

json
{
  "model": "claude-opus-4-7",
  "messages": [
    {
      "role": "user",
      "content": "Compare these migration options, identify risks, and recommend the safest sequence."
    }
  ],
  "max_tokens": 4096,
  "stream": false
}

Claude Opus 4.6

claude-opus-4-6

需要 Opus 级推理和写作质量,同时希望保持稳定通用表现时使用。

json
{
  "model": "claude-opus-4-6",
  "messages": [
    {
      "role": "user",
      "content": "Turn these product notes into a precise technical spec with risks and acceptance criteria."
    }
  ],
  "max_tokens": 4096,
  "stream": false
}

Claude Opus 4.6 (Thinking)

claude-opus-4-6-thinking

适合需要显式思考预算的复杂推理任务,例如调试、规划和多步骤分析。

json
{
  "model": "claude-opus-4-6-thinking",
  "messages": [
    {
      "role": "user",
      "content": "Trace this production bug from symptoms to root cause. Show assumptions, tests, and the smallest safe fix."
    }
  ],
  "max_tokens": 4096,
  "stream": false,
  "reasoning_effort": "high"
}

Claude Sonnet 4.6

claude-sonnet-4-6

默认 Claude 选择,适合编码、Agent、聊天产品、工具调用,以及延迟和成本均衡的场景。

json
{
  "model": "claude-sonnet-4-6",
  "messages": [
    {
      "role": "user",
      "content": "Implement this feature, keep the API contract stable, and summarize the changed files."
    }
  ],
  "max_tokens": 4096,
  "stream": false
}

Claude Haiku 4.5

claude-haiku-4-5-20251001

快速、低成本的 Claude,适合分类、抽取、轻量客服回复和后台任务。

json
{
  "model": "claude-haiku-4-5-20251001",
  "messages": [
    {
      "role": "user",
      "content": "Extract company name, contact email, urgency, and requested action from this message."
    }
  ],
  "max_tokens": 1024,
  "stream": false
}

Claude Code

Claude Code 配好 BeansAI 后,可以在 CLI 内用 /model 切换模型。

Claude Code
/model claude-fable-5
/model claude-opus-4-8
/model claude-opus-4-7
/model claude-opus-4-6
/model claude-opus-4-6-thinking
/model claude-sonnet-4-6
/model claude-haiku-4-5-20251001

使用技巧

  • Claude 长输出建议开启 stream: true,客户端可以边生成边接收。
  • Claude Fable 5 使用始终开启的自适应 thinking;需要控制深度时调 effort,不要传手动 thinking 预算。
  • 请求费用会通过 X-Request-Cost-Micro-Usd 返回;上游提供的 Anthropic 限速头也会转发。