fix(realtime): keep transcription validation compatible with cost map guard

This commit is contained in:
Emerson Gomes 2026-09-22 19:16:22 -05:00
parent e0ae1d2925
commit 3fb2252376
No known key found for this signature in database
GPG key ID: D3DF28AB5D1B5E17
5 changed files with 4 additions and 40 deletions

View file

@ -23,7 +23,7 @@ from collections.abc import AsyncIterator, Callable, Coroutine, Iterable, Mappin
from concurrent import futures
from concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, wait
from copy import deepcopy
from functools import lru_cache, partial
from functools import partial
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Final, Literal, Optional, Protocol, Union, cast, get_args
@ -8248,23 +8248,6 @@ async def atranscription(
)
@lru_cache(maxsize=1)
def _bundled_transcription_response_formats() -> Mapping[str, tuple[str, ...]]:
from litellm.litellm_core_utils.get_model_cost_map import GetModelCostMap
catalog: Final = TypeAdapter(dict[str, dict[str, object]]).validate_python(
GetModelCostMap.load_local_model_cost_map()
)
formats_adapter: Final = TypeAdapter(tuple[str, ...])
return MappingProxyType(
{
model: formats_adapter.validate_python(entry["supported_transcription_response_formats"])
for model, entry in catalog.items()
if "supported_transcription_response_formats" in entry
}
)
def _validate_gpt_transcription_request(
model: str,
custom_llm_provider: str,
@ -8275,9 +8258,6 @@ def _validate_gpt_transcription_request(
) -> str | None:
model_info: Final = get_model_info(model=model) if model in litellm.model_cost else {}
supported_endpoints: Final = model_info.get("supported_endpoints")
supported_formats: Final = model_info.get("supported_transcription_response_formats") or (
_bundled_transcription_response_formats().get(model)
)
if language is not None and languages is not None:
raise litellm.UnsupportedParamsError(
message="language and languages cannot be used together",
@ -8290,13 +8270,13 @@ def _validate_gpt_transcription_request(
model=model,
llm_provider=custom_llm_provider,
)
if supported_formats is not None and response_format is not None and response_format not in supported_formats:
if model == "gpt-transcribe" and response_format not in (None, "json"):
raise litellm.UnsupportedParamsError(
message=f"{model} only supports response_format={', '.join(repr(fmt) for fmt in supported_formats)}",
message="gpt-transcribe only supports response_format='json'",
model=model,
llm_provider=custom_llm_provider,
)
if custom_llm_provider == "azure" and supported_formats is not None:
if custom_llm_provider == "azure" and model == "gpt-transcribe":
if api_version in (None, "v1", "latest", "preview"):
return litellm.AZURE_DEFAULT_API_VERSION
return api_version

View file

@ -214,9 +214,6 @@
"/v1/realtime",
"/v1/realtime/transcription_sessions"
],
"supported_transcription_response_formats": [
"json"
],
"supported_modalities": [
"audio",
"text"
@ -63374,9 +63371,6 @@
"/v1/audio/transcriptions",
"/v1/realtime/transcription_sessions"
],
"supported_transcription_response_formats": [
"json"
],
"supported_modalities": [
"text",
"audio"

View file

@ -465,7 +465,6 @@ class ModelInfoBase(ProviderSpecificModelInfo, total=False):
]
]
supported_endpoints: list[str] | None
supported_transcription_response_formats: ReadOnly[Sequence[str] | None]
use_openai_responses_path: bool | None
tpm: int | None
rpm: int | None

View file

@ -6940,9 +6940,6 @@ def get_model_info_helper(
litellm_provider=_model_info.get("litellm_provider", custom_llm_provider),
mode=_model_info.get("mode"),
supported_endpoints=_model_info.get("supported_endpoints", None),
supported_transcription_response_formats=_model_info.get(
"supported_transcription_response_formats", None
),
supports_system_messages=_model_info.get("supports_system_messages", None),
supports_response_schema=_model_info.get("supports_response_schema", None),
supports_vision=_model_info.get("supports_vision", None),

View file

@ -214,9 +214,6 @@
"/v1/realtime",
"/v1/realtime/transcription_sessions"
],
"supported_transcription_response_formats": [
"json"
],
"supported_modalities": [
"audio",
"text"
@ -63374,9 +63371,6 @@
"/v1/audio/transcriptions",
"/v1/realtime/transcription_sessions"
],
"supported_transcription_response_formats": [
"json"
],
"supported_modalities": [
"text",
"audio"