Missing API key.:Claude Desktop OpenCode Go
Quick fix
Change the upstream authentication field from ANTHROPIC_AUTH_TOKEN to ANTHROPIC_API_KEY so requests are sent through x-api-key.
Symptom
Section titled “Symptom”{"type":"error","error":{"type":"AuthError","message":"Missing API key."}}The Claude Desktop OpenCode Go preset does not specify apiKeyField, so the form writes ANTHROPIC_AUTH_TOKEN by default. When cc-switch sees this field, it sends Authorization: Bearer to the OpenCode Go Anthropic Messages endpoint. That endpoint accepts only x-api-key, so it returns 401 Missing API key. After the field name is changed to ANTHROPIC_API_KEY, cc-switch sends x-api-key according to Anthropic semantics.
The same mechanism previously affected Claude Code proxy mode, but the maintainer confirmed that the authentication header logic supports ANTHROPIC_API_KEY→x-api-key and ANTHROPIC_AUTH_TOKEN→Bearer. The Claude Desktop preset issue was reported in 3.20.0, 3.20.4, and 4.0.5. As of the latest replies in these issues, PR #8056 was still under review.
Fully quit cc-switch first, and back up its SQLite database.
In providers.settings_config for the existing Claude Desktop OpenCode Go provider, change only the authentication field name from ANTHROPIC_AUTH_TOKEN to ANTHROPIC_API_KEY. Keep the API key value unchanged.
~/.cc-switch/cc-switch.db "ANTHROPIC_AUTH_TOKEN": "sk-***""ANTHROPIC_API_KEY": "sk-***"Restart cc-switch, then start Claude Desktop and retry the request. The reported verification result was that upstream requests returned HTTP 200 again.
Do not recreate the provider from the OpenCode Go preset. Until the relevant fix is merged, creating it again will write ANTHROPIC_AUTH_TOKEN again.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 4 real issues
- #2368Claude proxy should support x-api-key auth header for Anthropic-compatible providers
- #6258Claude Desktop provider 无法选择认证字段,OpenCode Go 使用 Anthropic Messages 协议时 401 Missing API key.
- #6605Claude Desktop Anthropic协议报错
- #8026Claude Desktop: OpenCode Go returns 401 "Missing API key" with Model Mapping on v4.0.5
- Same question—has this been resolved?
- A workaround is available: quit cc-switch and back up the database, change ANTHROPIC_AUTH_TOKEN to ANTHROPIC_API_KEY in this provider's settings_config, and restart cc-switch. The permanent fix, PR #8056, was still under review in the latest reply.
- Why does the same API key work in Claude Code but return 401 in Claude Desktop?
- The Claude Code OpenCode Go preset explicitly uses ANTHROPIC_API_KEY, so it sends x-api-key. The Claude Desktop preset does not specify apiKeyField, so it defaults to ANTHROPIC_AUTH_TOKEN and sends Authorization: Bearer, which the OpenCode Go Anthropic endpoint does not accept.
- Why does an X-Opencode-Session error appear after changing the authentication field?
- A user reported in the issue that adding the corresponding request header in settings resolved it. The original post did not provide the exact header value, so no more specific configuration can be given.
Related problems
Section titled “Related problems”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.