mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
`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. |
||
|---|---|---|
| .. | ||
| cli | ||
| test_chat.py | ||
| test_client.py | ||
| test_credentials.py | ||
| test_http_client.py | ||
| test_http_commands.py | ||
| test_keys.py | ||
| test_model_groups.py | ||
| test_models.py | ||
| test_users.py | ||