What is the exact message?
Your apiKeyHelper script is failing · This usually means you need to re-authenticate with your provider · Run /status to see the script's error outputThe rest of the line points at the fix: re-authenticate with the provider that issues the key, then read the script's own error in /status.
What does it mean?
apiKeyHelper is a settings key whose value is a shell command. Claude Code runs that command to produce the credential it sends with every model request, and it caches the result for five minutes by default, or for the interval you set with CLAUDE_CODE_API_KEY_HELPER_TTL_MS.
This message means the command did not produce a usable key. Without one, the request still goes to the API carrying a placeholder credential, and the API rejects it with 401. So the error you notice is an authentication failure, but the thing to fix is the script.
Claude Code's Authentication panel in the terminal shows which of the three failures happened; on Claude Code v2.1.274 and later, /status repeats the last failure's detail. Claude Code re-runs the script and retries the request up to two more times before it shows the message, so the failure surfaces within three attempts.
Which of the three failures is it?
- The command exited with an error or timed out. The script itself is broken, or the service it calls is unreachable. Running it by hand reproduces this one immediately.
- The command printed nothing to stdout. A silent success is still a failure here. The key has to be printed, not saved to a file and not exported into the shell.
- The command printed something besides the key. A login banner or a log line before the key makes the output unusable. The message
returned output that cannot be used as an API keyappears with what is wrong, without repeating your output.
All three are local failures. Nothing about them involves your Claude subscription, so re-running /login cannot clear any of them.
How do I fix it?
- Find the command, then run it yourself. Its text is the value of the
apiKeyHelperkey in one of your settings files, and/statusnamesapiKeyHelperas the active credential source when it is the one in use. Paste the command into a terminal: that reproduces the failure outside Claude Code, where you can see the whole output and the exit code. - If it reports an expired session, re-authenticate with your credential provider. That is usually your SSO or your secrets vault, which is where the short-lived key comes from.
- Make the command print only the key. Anthropic's requirement is a single token of printable ASCII up to 16,384 characters followed by exit code 0. Move banners and log lines to stderr or behind a flag.
- Re-run the helper and check the result. On Claude Code v2.1.274 and later,
/statuslistsapiKeyHelperas the active credential source and shows aFailingrow with the last failure's detail until the next successful run. - Send one more request. A request that fails with
401or403makes Claude Code rerun the helper straight away, so a script you have just fixed is picked up without waiting for the five-minute cache.
In a non-interactive run (-p) the same reason appears on stderr, prefixed apiKeyHelper failed:, which is the line to put in a CI log.
How do I know it is fixed?
- The command prints the key and nothing else, and its exit code is 0.
/statusshows noFailingrow after the next successful run.- A normal request in the session succeeds instead of returning
401.
Where these answers come from
- The message, the three failure causes, the 16,384-character single-token rule, the two retries, the precedence over a saved login, and the
/statusand non-interactive detail: Anthropic's error reference, read November 18, 2026. - What
apiKeyHelperis, how the command is run, the five-minute cache and theCLAUDE_CODE_API_KEY_HELPER_TTL_MSoverride: Anthropic's settings reference, read November 18, 2026.
Common questions
Why doesn't /login fix this?
Because the helper's output takes precedence over a saved login for as long as the apiKeyHelper setting is present. Signing in again changes nothing while the script still fails; fix the script, or remove the setting.
What does the helper have to print?
Only the key, as a single token of printable ASCII up to 16,384 characters, followed by a zero exit code. A login banner, a log line or a warning printed before the key makes the output unusable as an API key.
How do I see the script's own error?
Run /status. On Claude Code v2.1.274 and later, the apiKeyHelper row shows Failing with the last failure's detail, such as the exit code and the command's error output, and it disappears after the next successful run. In a non-interactive run, stderr carries the specific reason, prefixed apiKeyHelper failed:.
How many times does Claude Code retry before showing this?
Claude Code re-runs the script and retries the request up to two more times, so the failure surfaces within three attempts rather than after the full retry budget.