Claude 接入 中转API 报错解决方案

由于Codex账号慌,好友也都用不了,想着自己搞个sub2api服务吧,跟朋友一起用,但是在接入Claude时,我用的AWS逆向渠道。 输入 cluade ,本想象着直接起飞,但是理想很丰满,现实很骨感,开局就给我来了个措手不及,直接报错如下: There’s an issue with the s...
Claude 接入 中转API 报错解决方案
Claude 接入 中转API 报错解决方案

由于Codex账号慌,好友也都用不了,想着自己搞个sub2api服务吧,跟朋友一起用,但是在接入Claude时,我用的AWS逆向渠道。

输入cluade,本想象着直接起飞,但是理想很丰满,现实很骨感,开局就给我来了个措手不及,直接报错如下:

There’s an issue with the selected model (claude-opus-4-7[1m]). It may not exist or you may not have access to it. Run –model to pick a different model.

接入any大善人的也是如此,最后我问了gpt才告诉我用/doctor命令查看问题所在

 /doctor                                                                                                               
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  Diagnostics
  ├ Currently running: npm-global (2.1.138)
  ├ Commit: d6d494651eb4
  ├ Platform: win32-x64
  ├ Path: C:\Users\xxx\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe
  ├ Config install method: native
  └ Search: OK (bundled)

  ⚠ Multiple installations found
  ├ npm-global at C:\Users\xxx\AppData\Roaming\npm\claude
  └ native at C:\Users\xxx\.local\share\claude

  Updates
  ├ Auto-updates: disabled (set by env: CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC)
  ├ Update permissions: Yes
  ├ Auto-update channel: latest
  ├ Stable version: 2.1.126
  └ Latest version: 2.1.138

    Skill listing will be truncated
      5 descriptions dropped (full descriptions kept for most-used skills) (1.2%/1% of context): xlsx, webapp-testing,
     security-review, +2 more
        run /skills to disable some, or raise skillListingBudgetFraction (currently 1%) in settings.json
      Opting in would cost ~2k tokens for skills every session and uses rate limits faster

  Still having issues? Run /feedback to report details.

好家伙,原来我当初既安装了npm版本的,也用官方的ps1脚本安装了一遍,相当于本机有两个客户端,一个是npm,一个是native,可能是我真的好几个月没用Claude了吧。 :rofl:

我最终全部卸载后,重新用npm命令安装才解决该问题

# 删除native
Remove-Item -Recurse -Force "$env:USERPROFILE\.local\share\claude"
# 删除native的缓存
Remove-Item -Recurse -Force "$env:USERPROFILE\.cache\claude" -ErrorAction SilentlyContinue
# 清除claude本地缓存
Remove-Item -Recurse -Force "$env:USERPROFILE\.claude"
# 卸载npm包
npm uninstall -g @anthropic-ai/claude-code
# 安装npm包
npm install -g @anthropic-ai/claude-code@latest

你如果怀疑你的中转行不行,可以先请求模型列表,将https://api.openai.com替换成你的中转地址

curl https://api.openai.com/v1/models `
  -H "Authorization: Bearer 你的新key"

我的cc-switch配置如下(不写真实中转,免得被说广告 :grimacing:):

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.openai.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1",
    "ENABLE_TOOL_SEARCH": "true",
    "API_TIMEOUT_MS": "3000000"
  },
  "effortLevel": "xhigh"
}

如果用的any大善人的中转,因为大善人开启了强制1M,所以不仅仅model写成1m,模型名称后面也需要,配置可以写成如下:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
    "ANTHROPIC_BASE_URL": "https://api.openai.com",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-opus-4-7[1m]",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-7[1m]",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-opus-4-7[1m]",
    "ANTHROPIC_MODEL": "claude-opus-4-7[1m]",
    "ANTHROPIC_REASONING_MODEL": "claude-opus-4-7[1m]",
    "ENABLE_TOOL_SEARCH": "true",
    "CLAUDE_CODE_1M_CONTEXT": "1",
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
  },
  "effortLevel": "xhigh",
  "model": "opus[1m]"
}

帮助真正需要的佬友,如果你遇到了其他问题,也可以贴出来,为后面的佬友解决烦恼 :bili_057:

1 个帖子 - 1 位参与者

阅读完整话题

来源: LinuxDo 最新话题查看原文