litellm/tests/test_litellm/proxy/client/cli
Yassin Kortam 6ca48efc8b
feat(cli): add lite login --config-claude to wire Claude Code at login (#37507)
`lite up` already patches ~/.claude/settings.json, but only for as long as it
runs in the foreground, and it restores the original file on exit. Users
proxying Claude Code through LiteLLM therefore have to re-wire it by hand after
every login.

--config-claude makes that write persistent. It reuses the settings shape
`lite up` writes (env.ANTHROPIC_BASE_URL plus an apiKeyHelper invocation),
preserves every unrelated key, creates the file when missing, and writes it
atomically with owner-only permissions. Plain `lite login` is unchanged.

Reaching the credential through apiKeyHelper rather than copying it into the
file means a later login refreshes it with no further action, and keeps the
short-lived CLI token out of settings.json entirely.

The shared parts of the settings-file handling move from up.py into a new
claude_settings.py, since up.py imports auth.py and so auth.py cannot import
up.py back. That module now also owns the registry of commands that can be
temporarily managing the file, so the persistent write refuses while either
`lite up` or `lite autoroute up` holds a backup it would later restore over
this write.

Because this write has no backup and no `lite down`, it is stricter than
`lite up` about the user's file: it writes through a symlinked settings.json
rather than replacing the link with a regular file, and it refuses rather than
silently discarding a non-object `env` value.

Also fixes the apiKeyHelper command itself: --base-url belongs to the
top-level `lite` group, so `lite auth print-token --base-url X` is rejected by
click with "No such option". Every settings file `lite up` has written carries
that malformed command, which makes the helper return nothing and every Claude
Code request lose its token. The existing tests only string-matched the
generated command, so the new tests parse it through the real CLI instead.
2026-08-19 15:32:14 -07:00
..
autoroute fix(autoroute): discover models via /v1/models so an AI-API-only key works (#34259) 2026-07-22 20:50:14 -07:00
__init__.py Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
test_agents.py fix(cli): launch agents as a child process on Windows (#36822) 2026-08-13 17:06:25 -07:00
test_auth_commands.py feat(cli): add lite login --config-claude to wire Claude Code at login (#37507) 2026-08-19 15:32:14 -07:00
test_claude_settings.py feat(cli): add lite login --config-claude to wire Claude Code at login (#37507) 2026-08-19 15:32:14 -07:00
test_config_commands.py feat(cli): make the hidden lite command list configurable (#36816) 2026-08-13 17:23:03 -07:00
test_credentials_commands.py test fix creds test 2025-07-03 22:01:52 -07:00
test_encryption_commands.py feat(proxy): add AES-256-GCM at-rest credential encryption with versioned format and re-encryption migration (#31215) 2026-06-29 20:14:22 +02:00
test_global_options.py test(cli): use example.com placeholder host in base-url trailing slash test (#37240) 2026-08-18 00:52:10 +00:00
test_keys_commands.py fix(cli): make CLI output ASCII-only so it doesn't crash legacy Windows consoles (#33465) 2026-07-16 10:35:06 -07:00
test_model_groups_commands.py feat(cli): add lite up/down to ambiently route Claude Code through the proxy (#33231) 2026-07-15 21:46:02 -07:00
test_models_commands.py sys.path.insert for cli tests 2025-07-03 15:58:49 -07:00
test_up_commands.py feat(cli): add lite login --config-claude to wire Claude Code at login (#37507) 2026-08-19 15:32:14 -07:00
test_users_commands.py sys.path.insert for cli tests 2025-07-03 15:58:49 -07:00