Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/read_model_list.py: 0%
7 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
1"""Resolve a proxy config's ``model_list`` for the Rust AI gateway.
3The Rust gateway calls this once at load time (via an embedded interpreter) and
4builds its own (Rust) router from the returned ``model_list``. We do NOT call
5``ProxyConfig.load_config`` here: that returns a *Python* ``litellm.Router`` (not
6usable from Rust) and boots the whole proxy (callbacks, cache, DB, auth) as side
7effects.
9Instead we reuse ``ProxyConfig.get_config`` — the actual config reader — so the
10gateway inherits the same heavy lifting the proxy does: ``include:`` merging,
11``os.environ/`` + secret-manager resolution, and DB-stored models (when a DB is
12configured). Its only proxy-setup side effect is bringing up the configured
13secret manager, which is what makes that resolution work. Returns the resolved
14``model_list``; the Rust side deserializes each entry into its ``Deployment``.
15"""
17from __future__ import annotations
19import asyncio
20from typing import Any, Final
23def read_model_list(config_path: str) -> list[dict[str, Any]]:
24 """Load ``config_path`` via the proxy's own reader and return its
25 resolved ``model_list``."""
26 from litellm.proxy.proxy_server import ProxyConfig
28 config: Final = asyncio.run(ProxyConfig().get_config(config_file_path=config_path))
29 return config.get("model_list") or []