Skip to content

x-anthropic-billing-header breaks caching - CC Switch

Quick fix

Upgrade CC Switch to v3.15.0+, which fixes the dynamic billing header breaking prefix caching in openai_responses mode.

Error output
上次自动同步失败:Fetch is aborted
English translation

上次自动同步失败:Fetch is aborted

This cluster actually mixes several quite different CC Switch request conversion and proxy defects. This page addresses the fixed core problem (#2350): in `openai_responses` mode, CC Switch incorrectly injected an `x-anthropic-billing-header` containing a dynamic `cch` value at the start of the `instructions` field. Because OpenAI prompt caching matches on a prefix, that header changing on every request stopped a large, otherwise stable system prompt from ever hitting the cache.

The cluster also holds unfixed variants: Azure OpenAI `max_tokens` not being converted to `max_completion_tokens`, producing a 400 (#3185); `supports_reasoning_effort()` using `strip_prefix("gpt-")` so a model with a custom prefix never triggers reasoning mapping (#5343); Claude Desktop routing not reusing the Session ID, lowering the cache rate (#5388); and `<thinking>` tags leaking into the body on the Codex chat-completions route (#6116).

  1. 区分两类代理:供应商配置里的 env proxy 只作用于 Claude Code / Codex 等 CLI 的请求流量,cc-switch 自身的内部请求(会话刷新、配额刷新)不会使用它,需要单独配置。

  2. 如果内部请求需要走代理:在 cc-switch 应用设置中开启并配置软件级「出站代理」,或配置系统代理。应用级出站代理优先,未设置时回退到系统代理。

  3. 针对 models.dev 定价同步报「Fetch is aborted」:该请求由 WebView 发出、只跟随系统代理,临时办法是设置系统代理(或 TUN)让 WKWebView 能经代理访问 models.dev;应用内代理对此无效,根治需等待官方把该 fetch 移到 Rust 后端的修复版本发布。

  4. 验证:`~/.cc-switch/model-pricing.json` 中的 `lastSyncError` 不再为 `Fetch is aborted`,且 `lastSyncAt` 出现时间戳,说明同步成功。

    ~/.cc-switch/model-pricing.json(同步成功后应看到 lastSyncAt 有值、lastSyncError 为空)
    {
    "lastSyncAt": "<时间戳>",
    "lastSyncError": null
    }
Toolcc-switch(应用自身的会话刷新与使用统计/定价同步功能)
Versionmodels.dev 同步失败确认存在于 3.20.0 且未修复;会话刷新走应用级出站代理/系统代理的行为自 3.13.0 起被用户观察到
PlatformsmacOSWindows
会话刷新走的是配置文件环境变量里的 proxy,还是软件里的出站 proxy?
根据维护者答复:会话刷新使用 cc-switch 的 HTTP 客户端,设置了应用级出站代理就走该代理,否则走系统代理;供应商 env 里的 proxy 设置不被使用。
如果配置文件设置了 env proxy,能否自动填充到软件单独设置的 proxy 处?
输入的 issue 中官方未回应该建议;目前两者是相互独立的配置,内部请求只认应用级出站代理或系统代理,需要手动单独设置。
我已在 cc-switch 里配置了代理,为什么 models.dev 定价同步还是失败?
定价同步在 WebView 内用浏览器原生 fetch 直连 models.dev,不经过 Rust 后端的全局代理客户端,WKWebView 只跟随系统代理,不读应用内代理配置。临时办法是设置系统代理;根治修复(把 fetch 挪到 Rust 后端)截至 v3.20.0 尚未发布。
「从 models.dev 导入」定价对话框也失败,是同一个问题吗?
是。导入对话框与自动同步共用同一条 fetch 路径,同样不走应用内代理,会报同样的 Fetch is aborted。

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.