litellm/tests/test_litellm/proxy/client
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
..
cli feat(cli): read base_url from persistent config file (#35015) 2026-07-29 18:25:05 -07:00
test_chat.py build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
test_client.py sys.path.insert for cli tests 2025-07-03 15:58:49 -07:00
test_credentials.py Change credential encryption to only affect db credentials 2025-12-09 13:36:40 -08:00
test_http_client.py fix delete callbacks 2025-11-06 17:06:34 -08:00
test_http_commands.py fix delete callbacks 2025-11-06 17:06:34 -08:00
test_keys.py fix(proxy/client): redact api key from key/info client error messages (#31342) 2026-06-25 17:35:15 -07:00
test_model_groups.py fix delete callbacks 2025-11-06 17:06:34 -08:00
test_models.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_users.py sys.path.insert for cli tests 2025-07-03 15:58:49 -07:00