litellm/tests/test_litellm/proxy/client/cli
ryan-crabbe-berri 581f5c319e
feat(cli): read base_url from persistent config file (#35015)
* feat(cli): read base_url from persistent config file

Adds a lite config command group (set/get/unset) backed by
~/.litellm/config.json so users no longer need to export
LITELLM_PROXY_URL in every shell session. Resolution order is
--base-url flag, then LITELLM_PROXY_URL, then the config file,
then the localhost default. A config-file base_url counts as an
explicit server choice for lite auth print-token, matching the
env var semantics it replaces.

* fix(cli): harden config persistence after review feedback

Rejects base_url values containing a query string or fragment,
including bare trailing ? or # which parse as empty but still
corrupt every joined request URL. Writes config.json and token.json
atomically through a shared write_private_json helper (0600 at
creation, fsync, os.replace) so an interrupted save can no longer
truncate the file or leave it world-readable. Warns on stderr when
an existing config file is invalid instead of silently ignoring it,
including invalid UTF-8. Resolves the eager --version flag through
the same env, config file, default chain as every other command,
and reads the config file once per invocation so base_url and
base_url_explicit always come from the same snapshot.

* fix(cli): resolve --version after option parsing

The eager --version callback ran before --base-url and --api-key were
parsed, so it could not see an explicitly named server. Combined with
the env fallback added for config-file support, that sent the resolved
API key to whichever server the config file pointed at even when the
user named a different one on the command line. Making the flag a
normal option and handling it in the group callback gives the version
request the same flag, env, config, default precedence as every other
command, and lets the stored-token lookup stay origin-checked.
2026-07-29 18:25:05 -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 feat(cli): per-agent lite claude / codex / opencode commands that wrap coding agents through the proxy (#29850) 2026-06-10 13:52:26 -07:00
test_auth_commands.py feat(cli): read base_url from persistent config file (#35015) 2026-07-29 18:25:05 -07:00
test_config_commands.py feat(cli): read base_url from persistent config file (#35015) 2026-07-29 18:25:05 -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 feat(cli): read base_url from persistent config file (#35015) 2026-07-29 18:25:05 -07: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 up/down to ambiently route Claude Code through the proxy (#33231) 2026-07-15 21:46:02 -07:00
test_users_commands.py sys.path.insert for cli tests 2025-07-03 15:58:49 -07:00