mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix: wildcard model expansion (openai)
This commit is contained in:
parent
4fffd33ccf
commit
39602c34dc
1 changed files with 10 additions and 2 deletions
|
|
@ -710,14 +710,22 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig):
|
|||
if api_key is None:
|
||||
api_key = get_secret_str("OPENAI_API_KEY")
|
||||
|
||||
# Strip api_base to just the base URL (scheme + host + port)
|
||||
# Strip api_base to just the base URL (scheme + host + port + path)
|
||||
parsed_url = httpx.URL(api_base)
|
||||
base_url = f"{parsed_url.scheme}://{parsed_url.host}"
|
||||
if parsed_url.port:
|
||||
base_url += f":{parsed_url.port}"
|
||||
|
||||
# Preserve the path from api_base to handle subdomains and custom endpoints
|
||||
if parsed_url.path and parsed_url.path != "/":
|
||||
base_url += parsed_url.path.rstrip("/")
|
||||
|
||||
response = litellm.module_level_client.get(
|
||||
url=f"{base_url}/v1/models",
|
||||
url=(
|
||||
f"{base_url}/models"
|
||||
if base_url.endswith("/v1") or base_url.endswith("/v1/")
|
||||
else f"{base_url}/v1/models"
|
||||
),
|
||||
headers={"Authorization": f"Bearer {api_key}"},
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue