Skip to content

fix(cli): let the apiKeyHelper supply Claude Code's key under lite claude - #40489

Merged
mateo-berri merged 5 commits into
litellm_internal_stagingfrom
litellm_lite_claude_apikeyhelper_conflict
Sep 10, 2026
Merged

mateo-berri merged 5 commits into
litellm_internal_stagingfrom
litellm_lite_claude_apikeyhelper_conflict

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • lite login --config-claude writes an apiKeyHelper into ~/.claude/settings.json
  • lite claude then also exports ANTHROPIC_AUTH_TOKEN into Claude Code's env
  • Claude Code warns "Both ANTHROPIC_AUTH_TOKEN and apiKeyHelper set" on every start
  • The env token wins, so the helper never runs and never refreshes the key

How it solves it:

  • lite claude checks whether settings.json carries the helper lite wrote for this proxy
  • If it does and the key came from lite login, the token stays out of the env
  • Claude Code then asks the helper for its key, exactly as --config-claude intended
  • Both commands read the settings.json Claude Code reads: $CLAUDE_CONFIG_DIR/settings.json when set, else ~/.claude/settings.json
  • An explicit --api-key or LITELLM_PROXY_API_KEY still exports the token as before
  • A helper for another proxy, a hand-written helper, or no settings file: unchanged

Decisions made here, with the alternatives considered:

  • Match the helper string exactly against what lite login --config-claude writes for this base URL, rather than parsing any helper that looks lite-shaped. Exact match means only a lite-installed helper changes behavior; the cost is that a helper written by a different lite binary keeps the old behavior
  • An explicit --api-key or LITELLM_PROXY_API_KEY keeps exporting the env token even when a helper matches, because that key is what the user asked for and the helper would hand Claude Code the stored login key instead. That case still shows Claude Code's banner; the alternative (drop the token there too) would silently ignore the explicit key
  • In helper mode an inherited ANTHROPIC_AUTH_TOKEN from the parent shell is dropped, the same way ANTHROPIC_API_KEY already is, because Claude Code would prefer it over the helper and the launch key would no longer be the one lite verified
  • lite login --config-claude and lite claude resolve the settings file through CLAUDE_CONFIG_DIR the way Claude Code itself does, so a user who keeps Claude Code's config outside ~/.claude gets the helper written to, and read from, the file Claude Code actually loads. The alternative (keep the fixed ~/.claude/settings.json) would make lite claude export the token whenever the helper lives in the alternate file, bringing the banner back. lite up and lite autoroute stay on the default file: they take temporary ownership of it with a backup and restore, which is separate behavior and out of scope here
  • The lite up / lite autoroute up backup check on --config-claude only applies when the target is the default ~/.claude/settings.json, since those commands only ever manage that file. Checking it for an alternate CLAUDE_CONFIG_DIR would refuse a write nothing is going to undo
  • --config-claude runs that backup check before the browser login starts, so a refused configure never leaves a Login successful! behind it. The alternative (log in first, then fail the configure) is what this branch did before merging the lite configure claude work from feat(cli): add lite configure claude and lite unconfigure claude #40319, and it left users logged in with a half-applied setup
  • lite configure claude and lite unconfigure claude (from feat(cli): add lite configure claude and lite unconfigure claude #40319) follow CLAUDE_CONFIG_DIR the same way, and each settings file keeps its own undo receipt: the default file keeps ~/.litellm/claude_configure_state.json, and any other file gets ~/.litellm/claude_configure_state/<sha256 of its resolved path>.json. One shared receipt was rejected because unconfiguring under CLAUDE_CONFIG_DIR would restore the default file's previous values (and its file-existed flag) into the wrong file; a receipt beside the settings file was rejected because that puts a lite artifact inside Claude Code's config dir, which people keep in dotfile repos

User Flow

Before: a developer who ran lite login --config-claude starts lite claude and Claude Code opens with an auth warning banner on every launch, with the helper never used

  1. They run lite login --config-claude, finish the browser login, and see Configured Claude Code: ~/.claude/settings.json now routes through https://litellm-domain
  2. They run lite claude and see litellm: routing Claude Code through proxy at https://litellm-domain
  3. Claude Code opens and shows ⚠ Both ANTHROPIC_AUTH_TOKEN and apiKeyHelper set · auth may not work as expected, telling them to unset one or the other
  4. Prompts still go to POST https://litellm-domain/v1/messages and answer, but with the token from the env, so once the login expires the helper cannot renew it and they have to relaunch after another lite login
  5. Back in their shell, printenv | grep ANTHROPIC_AUTH_TOKEN prints nothing, which reads like the token was never set
  6. A developer with CLAUDE_CONFIG_DIR set sees --config-claude write ~/.claude/settings.json, a file their Claude Code never reads, so Claude Code opens without the proxy wiring at all

After: the same developer starts lite claude and Claude Code opens clean, reading its key from the helper lite login --config-claude installed

  1. They run lite login --config-claude, finish the browser login, and see Configured Claude Code: ~/.claude/settings.json now routes through https://litellm-domain (with CLAUDE_CONFIG_DIR set, the path shown is $CLAUDE_CONFIG_DIR/settings.json)
  2. They run lite claude and see litellm: routing Claude Code through proxy at https://litellm-domain followed by litellm: Claude Code reads its key from the apiKeyHelper in ~/.claude/settings.json, naming the same file the login step wrote
  3. Claude Code opens with no warning banner
  4. Prompts go to POST https://litellm-domain/v1/messages and answer, with the key coming from lite auth print-token each time Claude Code asks for it
  5. Inside the session, ! env | grep -c '^ANTHROPIC_AUTH_TOKEN=' prints 0 and ANTHROPIC_BASE_URL still points at https://litellm-domain

Relevant issues

Linear ticket

Resolves LIT-7395

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

Shared setup: one proxy from this branch on a random free port (25588, confirmed free with lsof -nP -iTCP:25588 -sTCP:LISTEN before boot), anthropic/claude-haiku-4-5 in the model list, real Anthropic spend. The change is entirely in the lite CLI, so the same proxy serves both legs and only the lite checkout differs. Claude Code v2.1.267 is driven interactively under tmux (tmux new-session -d -s lit7395 -x 160 -y 45, keystrokes via tmux send-keys, output via tmux capture-pane) with an isolated HOME so the run's ~/.claude/settings.json and ~/.litellm/token.json are its own. Login is lite login --pkce --config-claude with the proxy's own login form, which ends in the same settings write as the SSO device flow the ticket used. --model claude-haiku-4-5 is passed because the rig's proxy does not serve Claude Code's default model

Before (db7ca65, the merge base)

  1. Log in and configure Claude Code

    $ lite --base-url http://localhost:25588 login --pkce --config-claude
    Login successful!
    Keychain storage is off (LITELLM_CLI_DISABLE_KEYRING). Credential stored in ~/.litellm/token.json (owner-only).
    Configured Claude Code: ~/.claude/settings.json now routes through http://localhost:25588.
    Your other Claude Code settings were left untouched. Restart Claude Code to pick this up. Undo with `lite unconfigure claude`; `lite configure claude --model` sets the /model picker's default row, the model Claude Code starts on.
    $ cat ~/.claude/settings.json
    {"env": {"ENABLE_TOOL_SEARCH": "true", "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1", "ANTHROPIC_BASE_URL": "http://localhost:25588"},
     "apiKeyHelper": "/Users/mateo/Development/litellm-wt-lit7395/.venv/bin/lite --base-url http://localhost:25588 auth print-token"}
    
  2. Start Claude Code through lite

    $ lite --base-url http://localhost:25588 claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:25588
     ▐▛███▛█   Claude Code v2.1.267
    ▝▜██████▀  Haiku 4.5 · API Usage Billing
    ⚠ Both ANTHROPIC_AUTH_TOKEN and apiKeyHelper set · auth may not work as expected
      · to use ANTHROPIC_AUTH_TOKEN: Unset the apiKeyHelper setting.
      · to use apiKeyHelper: Unset the ANTHROPIC_AUTH_TOKEN environment variable.
    
  3. Inside the session, the env token is what Claude Code has

    ! env | grep -c '^ANTHROPIC_AUTH_TOKEN='
      ⎿  1
    
  4. Precedence check: with a bogus token in the env and the valid helper still in settings.json, Claude Code uses the env token and gets 401 Authentication Error, Invalid proxy server token passed. Received API Key = sk-...7395, so the helper never runs while the token is exported (this step exercises Claude Code's own precedence rather than lite, so it was run once, at 2c836f4, and not repeated at the merge base)

Claude Code before the fix: auth banner, ANTHROPIC_AUTH_TOKEN count 1

After (ab9dc75)

  1. Log in and configure Claude Code (same command, same settings.json written)

    $ lite --base-url http://localhost:25588 login --pkce --config-claude
    Login successful!
    Configured Claude Code: ~/.claude/settings.json now routes through http://localhost:25588.
    
  2. Start Claude Code through lite

    $ lite --base-url http://localhost:25588 claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:25588
    litellm: Claude Code reads its key from the apiKeyHelper in ~/.claude/settings.json
     ▐▛███▛█   Claude Code v2.1.267
    ▝▜██████▀  Haiku 4.5 · API Usage Billing
    

    No banner

  3. Inside the session, no env token, and a real prompt goes through the proxy with the key coming from the helper

    ! env | grep -c '^ANTHROPIC_AUTH_TOKEN='
      ⎿  0
    ❯ Reply with the single word pong
    ⏺ pong
    

    Proxy log for that turn: POST /v1/messages?beta=true HTTP/1.1" 200 OK

Claude Code after the fix: no banner, ANTHROPIC_AUTH_TOKEN count 0

  1. Same flow with Claude Code's config kept outside ~/.claude: both commands follow CLAUDE_CONFIG_DIR

    $ export CLAUDE_CONFIG_DIR=~/.claude-work
    $ lite --base-url http://localhost:25588 login --pkce --config-claude
    Login successful!
    Configured Claude Code: ~/.claude-work/settings.json now routes through http://localhost:25588.
    $ lite --base-url http://localhost:25588 claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:25588
    litellm: Claude Code reads its key from the apiKeyHelper in ~/.claude-work/settings.json
    

    No banner; inside the session the token count is 0 and pong comes back the same way

Claude Code after the fix with CLAUDE_CONFIG_DIR set: no banner, helper read from the alternate dir

  1. CLAUDE_CONFIG_DIR pointing at a directory with no settings.json: lite claude keeps exporting the token, since there is no helper for Claude Code to call

    $ CLAUDE_CONFIG_DIR=$(mktemp -d) lite --base-url http://localhost:25588 claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:25588
    ! env | grep -c '^ANTHROPIC_AUTH_TOKEN='
      ⎿  1
    
  2. lite up backup present (~/.litellm/claude_settings_backup.json): --config-claude still writes the alternate file, and refuses the default one before the login starts (no browser tab opens, no Login successful!), also when the default dir is reached through a symlinked CLAUDE_CONFIG_DIR

    $ CLAUDE_CONFIG_DIR=~/.claude-work lite --base-url http://localhost:25588 login --pkce --config-claude
    Login successful!
    Configured Claude Code: ~/.claude-work/settings.json now routes through http://localhost:25588.
    $ lite --base-url http://localhost:25588 login --pkce --config-claude
    Error: Cannot configure Claude Code, so not logging in: `lite up` is currently managing ~/.claude/settings.json (backup at ~/.litellm/claude_settings_backup.json) and will restore it when it stops. Run `lite down` first, then retry.
    $ ln -s ~/.claude ~/claude-alias
    $ CLAUDE_CONFIG_DIR=~/claude-alias lite --base-url http://localhost:25588 login --pkce --config-claude
    Error: Cannot configure Claude Code, so not logging in: `lite up` is currently managing ~/.claude/settings.json (backup at ~/.litellm/claude_settings_backup.json) and will restore it when it stops. Run `lite down` first, then retry.
    
  3. lite unconfigure claude under CLAUDE_CONFIG_DIR undoes only that file: the alternate file (created by step 4's login) is removed, its receipt under ~/.litellm/claude_configure_state/ goes with it, and the default file plus its own receipt are untouched

    $ cp ~/.claude/settings.json /tmp/default_before
    $ ls ~/.litellm | grep claude_configure_state
    claude_configure_state
    claude_configure_state.json
    $ CLAUDE_CONFIG_DIR=~/.claude-work lite unconfigure claude
    No settings file remains at ~/.claude-work/settings.json; it held nothing but `lite configure claude`'s own keys.
    $ cmp ~/.claude/settings.json /tmp/default_before && echo "default settings.json unchanged"
    default settings.json unchanged
    $ ls ~/.claude-work/settings.json
    ls: ~/.claude-work/settings.json: No such file or directory
    $ ls ~/.litellm/claude_configure_state/ | wc -l
    0
    

Observations from the run:

  • Reporter's empty printenv in the parent shell is expected: token lives in the child env only
  • Ticket title's "missing token" is the banner misread; requests did go through before too
  • Explicit --api-key plus a matching helper still shows the banner (by design, see decisions)

Type

🐛 Bug Fix

Caveats (if any)

Low

  • lite up and lite autoroute up still manage only ~/.claude/settings.json, ignoring CLAUDE_CONFIG_DIR

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

  • ab9dc75 passes /live-pr-risk

…aude

`lite login --config-claude` writes an apiKeyHelper into ~/.claude/settings.json,
and `lite claude` then also exported ANTHROPIC_AUTH_TOKEN, so Claude Code opened
with its "Both ANTHROPIC_AUTH_TOKEN and apiKeyHelper set" banner and, because the
env token wins, never ran the helper that was meant to refresh the key.

When the launch key is the stored login key and settings.json carries exactly
the helper lite wrote for this base URL, `lite claude` now leaves the token out
of the env (dropping an inherited one) so Claude Code asks the helper. An
explicit --api-key or LITELLM_PROXY_API_KEY, a helper for another proxy, a
hand-written helper, or no settings file keep the previous behavior.
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@codspeed

codspeed Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_lite_claude_apikeyhelper_conflict (ab9dc75) with litellm_internal_staging (db7ca65)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR lets Claude Code use LiteLLM's configured apiKeyHelper instead of exporting a competing token, while respecting CLAUDE_CONFIG_DIR and preserving explicit-key behavior

  • Resolves Claude Code settings paths at command execution time
  • Adds persistent configure and unconfigure receipts with guarded credential restoration
  • Canonicalizes settings paths before applying default-file ownership checks
  • Adds regression coverage for helper selection, alternate config directories, path aliases, and undo behavior

Confidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness, security, or repository-rule failures

The current code resolves Claude Code's active settings file, recognizes aliases before ownership decisions, preserves explicit-key precedence, and safely records and restores configuration changes. All previous findings were manually resolved and are addressed by the current implementation

Important Files Changed

Filename Overview
litellm/proxy/client/cli/commands/agents.py Detects the matching LiteLLM helper and suppresses inherited or generated Anthropic tokens only for stored-login Claude launches
litellm/proxy/client/cli/commands/auth.py Configures the active Claude settings file and records an undo receipt after checking file ownership
litellm/proxy/client/cli/commands/claude_settings.py Centralizes path resolution, canonical ownership checks, helper detection, transactional configuration, and conservative restoration
litellm/proxy/client/cli/commands/configure.py Adds persistent Claude configuration and unconfiguration commands with explicit versus stored credential handling
tests/test_litellm/proxy/client/cli/test_agents.py Covers helper-based launch environments, explicit-key precedence, alternate settings paths, and unaffected agent profiles
tests/test_litellm/proxy/client/cli/test_claude_settings.py Exercises canonical paths, separate receipts, transactional failures, user edits, credential withholding, and restoration

Reviews (5): Last reviewed commit: "merge: origin/litellm_internal_staging i..." | Re-trigger Greptile

@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Devin e2e QA

Tested at: 7e13795
Session: https://app.devin.ai/sessions/6c3402c74e1f4474af382887ec4b6339

Shared setup: one proxy built from this branch (7e13795) on port 45052, confirmed free before boot with ss -ltnp | grep :45052 (no output). anthropic/claude-haiku-4-5 in the model list with a real Anthropic key, so every prompt below is real spend. The change lives entirely in the lite CLI, so the same proxy serves both legs and only the lite checkout and the isolated HOME differ. Claude Code v2.1.267 driven interactively in tmux (tmux send-keys / tmux capture-pane), keychain off via LITELLM_CLI_DISABLE_KEYRING=1, login through the proxy's own login form with lite login --pkce --config-claude

Proxy launch:

$ ss -ltnp | grep :45052
$ python litellm/proxy/proxy_cli.py --config /home/ubuntu/qa-after-config.yaml --port 45052 --host 127.0.0.1 --detailed_debug 2>&1 | tee -a qa-proxy.log
INFO:     Uvicorn running on http://127.0.0.1:45052 (Press CTRL+C to quit)

Before (2c836f4)

Worktree /home/ubuntu/wt-before, HOME=/home/ubuntu/qa-home-before

  1. Log in and configure Claude Code

    $ lite --base-url http://localhost:45052 login --pkce --config-claude
    Opening browser to: http://localhost:45052/authorize?response_type=code&client_id=llm_dcrc_...&redirect_uri=http%3A%2F%2F127.0.0.1%3A40267%2Fcallback&...
    Approve the sign-in in your browser. Waiting...
    Login successful!
    Keychain storage is off (LITELLM_CLI_DISABLE_KEYRING). Credential stored in /home/ubuntu/qa-home-before/.litellm/token.json (owner-only).
    Configured Claude Code: /home/ubuntu/qa-home-before/.claude/settings.json now routes through http://localhost:45052.
    $ cat ~/.claude/settings.json
    {"env": {"ENABLE_TOOL_SEARCH": "true", "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1", "ANTHROPIC_BASE_URL": "http://localhost:45052"},
     "apiKeyHelper": "/home/ubuntu/wt-before/.venv/bin/lite --base-url http://localhost:45052 auth print-token"}
    
  2. Start Claude Code through lite

    $ lite --base-url http://localhost:45052 claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:45052
     ▐▛███▛█   Claude Code v2.1.267
    ▝▜██████▀  Haiku 4.5 · API Usage Billing
      ▝▝ ▝▝    /home/ubuntu/wt-before
    ⚠ Both ANTHROPIC_AUTH_TOKEN and apiKeyHelper set · auth may not work as expected
      · to use ANTHROPIC_AUTH_TOKEN: Unset the apiKeyHelper setting.
      · to use apiKeyHelper: Unset the ANTHROPIC_AUTH_TOKEN environment variable.
    

    Before: Claude Code opens with the auth banner

  3. Inside the session, the env token is what Claude Code has

    ! env | grep -c '^ANTHROPIC_AUTH_TOKEN='; env | grep '^ANTHROPIC_BASE_URL='
      ⎿  1
         ANTHROPIC_BASE_URL=http://localhost:45052
    
  4. A real prompt through the proxy

    ❯ Reply with exactly the text LIT-7395 before and nothing else
    ⏺ I'm ready to help with your work on the litellm repository. What task would you like me to tackle?
    

    Haiku ignored the instruction but the request went through: proxy log POST /v1/messages?beta=true HTTP/1.1" 200 OK

  5. Explicit key path still exports the token

    $ lite --base-url http://localhost:45052 --api-key <master-key> claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:45052
    ⚠ Both ANTHROPIC_AUTH_TOKEN and apiKeyHelper set · auth may not work as expected
    ! env | grep -c '^ANTHROPIC_AUTH_TOKEN='
      ⎿  1
    

After (7e13795)

Worktree /home/ubuntu/wt-after, HOME=/home/ubuntu/qa-home-after

  1. Log in and configure Claude Code

    $ lite --base-url http://localhost:45052 login --pkce --config-claude
    Opening browser to: http://localhost:45052/authorize?response_type=code&client_id=llm_dcrc_...&redirect_uri=http%3A%2F%2F127.0.0.1%3A36837%2Fcallback&...
    Approve the sign-in in your browser. Waiting...
    Login successful!
    Keychain storage is off (LITELLM_CLI_DISABLE_KEYRING). Credential stored in /home/ubuntu/qa-home-after/.litellm/token.json (owner-only).
    Configured Claude Code: /home/ubuntu/qa-home-after/.claude/settings.json now routes through http://localhost:45052.
    $ cat ~/.claude/settings.json
    {"env": {"ENABLE_TOOL_SEARCH": "true", "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1", "ANTHROPIC_BASE_URL": "http://localhost:45052"},
     "apiKeyHelper": "/home/ubuntu/wt-after/.venv/bin/lite --base-url http://localhost:45052 auth print-token"}
    
  2. Start Claude Code through lite

    $ lite --base-url http://localhost:45052 claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:45052
    litellm: Claude Code reads its key from the apiKeyHelper in /home/ubuntu/qa-home-after/.claude/settings.json
     ▐▛███▛█   Claude Code v2.1.267
    ▝▜██████▀  Haiku 4.5 · API Usage Billing
      ▝▝ ▝▝    /home/ubuntu/wt-after
    

    No banner

    After: Claude Code opens clean, no banner

  3. Inside the session, no env token and the base URL still set

    ! env | grep -c '^ANTHROPIC_AUTH_TOKEN='; env | grep '^ANTHROPIC_BASE_URL='
      ⎿  0
         ANTHROPIC_BASE_URL=http://localhost:45052
    
  4. A real prompt through the proxy, with the key coming from the helper

    ❯ Reply with exactly the text LIT-7395 after and nothing else
    ⏺ LIT-7395
    

    Proxy log for this session: POST /v1/messages?beta=true HTTP/1.1" 200 OK (count went from 6 to 9 across the env check and the prompt)

    After: env check and prompt answered through the proxy

  5. Explicit key path still exports the token

    $ lite --base-url http://localhost:45052 --api-key <master-key> claude --model claude-haiku-4-5
    litellm: routing Claude Code through proxy at http://localhost:45052
    ⚠ Both ANTHROPIC_AUTH_TOKEN and apiKeyHelper set · auth may not work as expected
    ! env | grep -c '^ANTHROPIC_AUTH_TOKEN='
      ⎿  1
    

    Same as before, by design: the explicit key wins and the banner shows

Verdict: the fix works as described. Login mode drops the env token and Claude Code takes its key from the helper with no banner; the explicit key path is unchanged

Claude Code reads settings.json from CLAUDE_CONFIG_DIR when it is set,
while lite login --config-claude wrote to ~/.claude/settings.json and
lite claude checked that same file for its apiKeyHelper. With the
override set, lite could drop ANTHROPIC_AUTH_TOKEN because the helper
lives in a file Claude Code never reads, leaving it with no key at all.

claude_settings_path(environ) now picks the file the way Claude Code
does, and both commands go through it. The CLI test directory gets an
autouse conftest that isolates HOME, USERPROFILE, and CLAUDE_CONFIG_DIR
per test and fails any test that writes the developer's real
settings.json, restoring it first.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…yhelper_conflict

Resolves the conflicts with the lite configure claude work from #40319: every persistent
writer and reader of Claude Code's settings file now resolves it through CLAUDE_CONFIG_DIR,
the lite up backup check only guards the default file, and each settings file keeps its own
undo receipt (the default file keeps ~/.litellm/claude_configure_state.json, any other file
gets ~/.litellm/claude_configure_state/<sha256 of its resolved path>.json).
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 10, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ab9dc75. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit c005431 into litellm_internal_staging Sep 10, 2026
128 of 132 checks passed
@mateo-berri
mateo-berri deleted the litellm_lite_claude_apikeyhelper_conflict branch September 10, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant