BerriAI/litellm · error · ValueError
api_base is required for Azure WebSocket
Error message
api_base is required for Azure WebSocket
What it means
Error "api_base is required for Azure WebSocket" thrown in BerriAI/litellm.
Solutions
- Pass api_base or set AZURE_API_BASE for the responses WebSocket call.
When it happens
Trigger: Thrown at litellm/llms/azure/responses/transformation.py:189 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/3740b09fe47bea0e.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure/responses/transformation.py:189
route="/openai/responses",
default_api_version=AZURE_DEFAULT_RESPONSES_API_VERSION,
)
def supports_native_websocket(self) -> bool:
return True
def get_websocket_url(
self,
api_base: str | None,
litellm_params: dict,
) -> str:
"""
Azure Responses WebSocket endpoint is at /openai/v1/responses with no
api-version query param. Auth is via Authorization header, model is sent
in the response.create body — not the URL.
"""
if api_base is None:
raise ValueError("api_base is required for Azure WebSocket")
parsed_url: Final = httpx.URL(api_base)
path = parsed_url.path.rstrip("/")
# Strip existing /openai/responses path if the api_base already contains it
for suffix in ("/openai/v1/responses", "/openai/responses"):
if path.endswith(suffix):
path = path[: -len(suffix)]
break
scheme: Final = "wss" if parsed_url.scheme == "https" else "ws"
return str(parsed_url.copy_with(scheme=scheme, path=f"{path}/openai/v1/responses", query=None))
def model_in_websocket_url(self) -> bool:
# Azure sends the model in the response.create body, not the URL
return False
#########################################################
########## DELETE RESPONSE API TRANSFORMATION ##############
#########################################################View on GitHub (pinned to 77b7c6c40c)