BerriAI/litellm · error · Exception
Unmapped response type. Got type: {type(result)}
Error message
Unmapped response type. Got type: {type(result)} What it means
Raised in SpeechToCompletionBridgeHandler.speech (handler.py:123) when the internal litellm.completion() call returns something that is not a ModelResponse — e.g. a streaming iterator (CustomStreamWrapper) or an executor/future. The bridge can only convert a complete ModelResponse containing an audio part into HttpxBinaryResponseContent, so any other result type is treated as a programming/configuration error.
Source
Thrown at litellm/endpoints/speech/speech_to_completion_bridge/handler.py:123
input=input,
optional_params=optional_params,
litellm_params=litellm_params,
headers=headers,
litellm_logging_obj=logging_obj,
custom_llm_provider=custom_llm_provider,
voice=voice,
)
result: Final = completion(
**request_data,
)
if isinstance(result, ModelResponse):
return self.transformation_handler.transform_response(
model_response=result,
)
else:
raise Exception(f"Unmapped response type. Got type: {type(result)}")
speech_to_completion_bridge_handler = SpeechToCompletionBridgeHandler()
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Remove stream=True from the speech/TTS call — the bridge requires a non-streaming response
- Inspect optional_params and litellm_params forwarded to the bridge and strip any 'stream' key
- If you patched litellm.completion in tests, make the mock return a ModelResponse instance
Example fix
# before resp = litellm.audio_speech(model="gpt-4o-audio-preview", input="hi", voice="alloy", stream=True) # after resp = litellm.audio_speech(model="gpt-4o-audio-preview", input="hi", voice="alloy")
Defensive patterns
Strategy: validation
Validate before calling
optional_params = {k: v for k, v in (optional_params or {}).items() if k != "stream"}
# ensure the bridge receives a non-streaming completion call Type guard
from litellm.types.utils import ModelResponse
def is_model_response(result: object) -> bool:
return isinstance(result, ModelResponse) Try / catch
try:
audio = litellm.audio_speech(model=model, input=text, voice=voice)
except Exception as e:
if "Unmapped response type" in str(e):
logger.error("completion() returned %s; disable streaming for speech calls", e)
raise Prevention
- Never pass stream=True to audio/speech endpoints routed through the chat bridge
- Strip 'stream' from optional_params before they reach TTS calls
- Test mocks of litellm.completion must return ModelResponse instances
When it happens
Trigger: The transformed request data includes stream=True (optional_params leaking a stream flag into the completion call), so completion() returns a stream wrapper instead of ModelResponse; or a mocked/patched completion returning a different type.
Common situations: Passing stream=True (or a router/deployment default that sets stream) to an audio/speech call routed through the bridge; providers or custom callbacks that alter the completion return type; tests monkeypatching litellm.completion with a plain dict.
Related errors
- prompt_characters must be provided for tts calls. prompt_cha
- model is required
- input is required
- logging_obj is required
- No audio part found in the response
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/2b75b5b5791ecf61.
Report an issue: GitHub.