FAQ
Claude Code
The most common errors when Claude Code connects to 2api, and how to fix them.
Keeps asking you to sign in, or shows Not logged in · Please run /login
Section titled “Keeps asking you to sign in, or shows Not logged in · Please run /login”Other common errors are Unable to connect to Anthropic services and Claude Code might not be available in your country. The cause is that the first-run setup didn’t pick up your config and connected to the official service instead.
- Write
ANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENintoenvin~/.claude/settings.json(see Claude Code for the format). Don’t put them only in the project’s.claude/settings.json. - Open
~/.claude.json(notsettings.json) and add"hasCompletedOnboarding": trueat the top level. - Reopen your terminal and start
claude. Type/status. If you see both the Anthropic base URL and Auth token lines, it is correct.
Shows Invalid API key · Please run /login, or API Error: 401
Section titled “Shows Invalid API key · Please run /login, or API Error: 401”2api rejected the key. Check these in order:
- Run the self-check command first. If curl also returns 401, the key itself is the problem. Copy it again from the console and don’t include spaces.
- If curl works but Claude Code reports an error, Claude Code isn’t reading this key. When the same variable is set both in
envinsettings.jsonand withexportin the terminal,settings.jsonwins. Check whether it holds an old key. - A malformed
settings.json(comments, an extra comma) means only part of it is read. Check it withjq . ~/.claude/settings.json. - Too many wrong attempts in a short time cause a temporary block with
Too many invalid authentication attempts. Wait a few minutes, then try again with the correct key.
Shows Auth conflict, or the key you set has no effect
Section titled “Shows Auth conflict, or the key you set has no effect”Both ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY are set, or you signed in to an official account before.
- Keep only
ANTHROPIC_AUTH_TOKEN. Rununset ANTHROPIC_API_KEYand remove it from~/.zshrc,~/.bashrcor the Windows environment variables. - If you only use 2api, run
/logoutin Claude Code to sign out of the official account. - To go back to the official service, delete
ANTHROPIC_BASE_URLand both key variables.
Shows There’s an issue with the selected model
Section titled “Shows There’s an issue with the selected model”The model named in the error isn’t in your group. It is often the small model, such as haiku, that is used for background tasks. Look up the models your group has with /v1/models, then set ANTHROPIC_DEFAULT_HAIKU_MODEL and CLAUDE_CODE_SUBAGENT_MODEL as described on the Claude Code page.
Balance drops fast, and caching doesn’t seem to work
Section titled “Balance drops fast, and caching doesn’t seem to work”Old versions of Claude Code have a much lower cache hit rate with a custom address. Run claude update to upgrade to the latest version first. If that doesn’t help, add "CLAUDE_CODE_ATTRIBUTION_HEADER": "0" to env in settings.json. You can check the cache-related columns in Usage Records (使用记录) to confirm the effect.
Timeouts, or the reply stops halfway
Section titled “Timeouts, or the reply stops halfway”Errors look like Request timed out, No response from API or Server error mid-response.
- Raise the timeout in
env:"API_TIMEOUT_MS": "900000". - If a reply stops partway, just reply with “continue”.
- Check your proxy settings. See Network and error codes.
- If a large request returns 504 every time, it is a server-side timeout. Contact support and include the time.
400 error: Extra inputs are not permitted, or anthropic-beta related
Section titled “400 error: Extra inputs are not permitted, or anthropic-beta related”Add "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1" to env in settings.json and restart.
WebFetch fails with Unable to verify if domain is safe to fetch
Section titled “WebFetch fails with Unable to verify if domain is safe to fetch”Before Claude Code fetches a web page, it first runs a check against the official service. If your network can’t reach the official service, the check fails. Add "skipWebFetchPreflight": true at the top level of ~/.claude/settings.json (not inside env).
After changing keys or providers, every request fails with Invalid signature in thinking block
Section titled “After changing keys or providers, every request fails with Invalid signature in thinking block”The session history contains thinking content signed by another upstream. Run /clear or start a new session.
PowerShell says it can’t find the claude command
Section titled “PowerShell says it can’t find the claude command”Claude Code isn’t installed, or the install path hasn’t taken effect yet. Run irm https://claude.ai/install.ps1 | iex to install it, then reopen PowerShell and run claude --version.
The VS Code extension keeps asking you to sign in
Section titled “The VS Code extension keeps asking you to sign in”See Claude Code extension. Add claudeCode.environmentVariables and claudeCode.disableLoginPrompt to the editor settings.