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 39ac30122e
commit 34d0773076
No known key found for this signature in database
GPG key ID: D3DF28AB5D1B5E17
7 changed files with 5 additions and 53 deletions

View file

@ -116,11 +116,6 @@ ARRAY_KEYS: dict[str, JsonSchema] = {
"description": "OpenAI-style API routes this model can be called through, e.g. /v1/chat/completions.",
"items": STRING,
},
"supported_transcription_response_formats": {
"type": "array",
"description": "Response formats accepted by the model for file transcription.",
"items": STRING,
},
"supported_modalities": {
"type": "array",
"description": "Input modalities the model accepts.",

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
from urllib.parse import urlsplit
@ -39,7 +39,7 @@ import httpx
import openai
from openai import AsyncStream, Stream
from openai.types.audio import TranscriptionStreamEvent
from pydantic import BaseModel, TypeAdapter
from pydantic import BaseModel
from typing_extensions import overload
import litellm
@ -7871,23 +7871,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,
@ -7898,9 +7881,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",
@ -7913,13 +7893,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"
@ -57558,9 +57555,6 @@
"/v1/audio/transcriptions",
"/v1/realtime/transcription_sessions"
],
"supported_transcription_response_formats": [
"json"
],
"supported_modalities": [
"text",
"audio"

View file

@ -396,7 +396,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

@ -6235,9 +6235,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"
@ -57558,9 +57555,6 @@
"/v1/audio/transcriptions",
"/v1/realtime/transcription_sessions"
],
"supported_transcription_response_formats": [
"json"
],
"supported_modalities": [
"text",
"audio"

View file

@ -864,13 +864,6 @@
"type": "string"
}
},
"supported_transcription_response_formats": {
"type": "array",
"description": "Response formats accepted by the model for file transcription.",
"items": {
"type": "string"
}
},
"supports_adaptive_thinking": {
"type": "boolean"
},