test(provider): add tests for chuizi provider routing + fix prefix handling

- Add chuizi provider block in _get_openai_compatible_provider_info
  for prefix routing (chuizi/model-name -> api_base + api_key)
- Add 2 tests: prefix routing and API key env var resolution

This fixes codecov patch coverage for the chuizi provider addition.
This commit is contained in:
Honam 2026-04-02 06:00:14 -07:00
parent 86bb05a400
commit 55ebc4f51e
2 changed files with 31 additions and 0 deletions

View file

@ -683,6 +683,15 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915
) = litellm.LMStudioChatConfig()._get_openai_compatible_provider_info(
api_base, api_key
)
elif custom_llm_provider == "chuizi":
# chuizi is openai compatible, unified AI gateway
api_base = (
api_base
or get_secret("CHUIZI_API_BASE")
or "https://api.chuizi.ai/v1"
) # type: ignore
dynamic_api_key = api_key or get_secret_str("CHUIZI_API_KEY")
elif custom_llm_provider == "deepseek":
# deepseek is openai compatible, we just need to set this to custom_openai and have the api_base be https://api.deepseek.com/v1
api_base = (

View file

@ -420,3 +420,25 @@ def test_get_llm_provider_use_proxy_arg_true_with_direct_args():
assert provider == "litellm_proxy"
assert key == arg_api_key # Should use the argument key
assert base == arg_api_base # Should use the argument base
def test_get_llm_provider_chuizi():
"""Test that chuizi/ prefix routes to chuizi provider."""
model, custom_llm_provider, dynamic_api_key, api_base = litellm.get_llm_provider(
model="chuizi/anthropic/claude-sonnet-4-6",
)
assert custom_llm_provider == "chuizi"
assert model == "anthropic/claude-sonnet-4-6"
assert api_base == "https://api.chuizi.ai/v1"
def test_get_llm_provider_chuizi_with_api_key():
"""Test that chuizi provider resolves CHUIZI_API_KEY from env."""
os.environ["CHUIZI_API_KEY"] = "test-chuizi-key"
model, custom_llm_provider, dynamic_api_key, api_base = litellm.get_llm_provider(
model="chuizi/openai/gpt-4.1",
)
assert custom_llm_provider == "chuizi"
assert model == "openai/gpt-4.1"
assert dynamic_api_key == "test-chuizi-key"
os.environ.pop("CHUIZI_API_KEY", None)