Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_post_call_policy_pipeline

mateo-berri95af93af3790
diff --cc litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py
index 89527c05eb6,46b00829b74..37a84195e76
--- a/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/unified_guardrail/unified_guardrail.py
@@@ -616,7 -607,15 +637,15 @@@ class UnifiedLLMGuardrails(CustomLogger
yield block_chunk
raise _StreamTerminated()
except HTTPException as e:
- async for error_item in self.emit_streaming_http_error(e, call_type, responses_so_far, request_data):
- async for error_item in self._emit_streaming_http_error(
++ async for error_item in self.emit_streaming_http_error(
+ e,
+ call_type,
+ responses_so_far,
+ request_data,
+ endpoint_translation=endpoint_translation,
+ stream_started=bool(responses_yielded),
+ responses_yielded=responses_yielded,
+ ):
yield error_item
raise _StreamTerminated()
@@@ -1099,11 -1099,17 +1128,17 @@@
return
except HTTPException as e:
# Response already started (we already yielded chunks); cannot send 400.
- # For A2A, yield an in-stream JSON-RPC error so the client sees it.
- if call_type is not None and CallTypes(call_type) in A2A_CALL_TYPES:
- yield _a2a_jsonrpc_error_chunk(e, _get_a2a_request_id(responses_so_far, request_data))
- return
- raise
- async for error_item in self._emit_streaming_http_error(
++ async for error_item in self.emit_streaming_http_error(
+ e,
+ call_type,
+ responses_so_far,
+ request_data,
+ endpoint_translation=endpoint_translation,
+ stream_started=chunks_yielded,
+ responses_yielded=responses_yielded,
+ ):
+ yield error_item
+ return
chunks_yielded = True
responses_yielded.append(original_item)
yield original_item
@@@ -1162,7 -1168,13 +1197,13 @@@
yield block_chunk
return
except HTTPException as e:
- if call_type is not None and CallTypes(call_type) in A2A_CALL_TYPES:
- yield _a2a_jsonrpc_error_chunk(e, _get_a2a_request_id(responses_so_far, request_data))
- else:
- raise
- async for error_item in self._emit_streaming_http_error(
++ async for error_item in self.emit_streaming_http_error(
+ e,
+ call_type,
+ responses_so_far,
+ request_data,
+ endpoint_translation=endpoint_translation,
+ stream_started=bool(responses_yielded),
+ responses_yielded=responses_yielded,
+ ):
+ yield error_item