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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
chore: mark the new API payload literals for the type-discipline budget
mateo-berri68bda9499533
diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.pyindex 3e55c3c637e..cf227cfa7d1 100644--- a/litellm/completion_extras/litellm_responses_transformation/transformation.py+++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py@@ -94,13 +94,14 @@ def _reasoning_input_items(msg: "AllMessageValues") -> list[dict[str, object]]:Stored reasoning items win because they carry an id the Responses API minted; thinkingblocks are the fallback for turns that arrived over another API surface."""- stored: Final = [_reasoning_item_to_response_input(r_item) for r_item in _get_reasoning_items(msg)]+ items: Final = _get_reasoning_items(msg)+ stored: Final = [_reasoning_item_to_response_input(item) for item in items] # mutable-ok: API message payloadif stored:return storedraw_blocks: Final = msg.get("thinking_blocks") or ()blocks: Final = cast("Iterable[ChatCompletionThinkingBlock]", raw_blocks) # cast-ok: untyped client jsonfrom_thinking: Final = responses_reasoning_item_from_thinking_blocks(blocks)- return [] if from_thinking is None else [dict(from_thinking)]+ return [] if from_thinking is None else [dict(from_thinking)] # mutable-ok: API message payloaddef _build_reasoning_item(@@ -393,7 +394,7 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):input_items.extend(_reasoning_input_items(msg))if content:input_items.append(- {+ { # mutable-ok: API message payload"type": "message","role": "assistant","content": self._convert_content_to_responses_format(content, "assistant"),diff --git a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.pyindex 5577d4a9c2d..292d2622c7f 100644--- a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py+++ b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py@@ -152,7 +152,10 @@ class AnthropicResponsesStreamWrapper:if block_idx < 0:if not delta:return- block_idx = self._open_block(item_id, {"type": "thinking", "thinking": "", "signature": ""})+ block_idx = self._open_block(+ item_id,+ {"type": "thinking", "thinking": "", "signature": ""}, # mutable-ok: API message payload+ )self._chunk_queue.append({"type": "content_block_delta",diff --git a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.pyindex 1a6b0498a52..23a9a60d810 100644--- a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py+++ b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py@@ -148,13 +148,13 @@ class LiteLLMAnthropicToResponsesAPIAdapter:if btype == "thinking":blocks: Final = cast(tuple[ChatCompletionThinkingBlock, ...], group) # cast-ok: untrusted client payloadreasoning_item: Final = responses_reasoning_item_from_thinking_blocks(blocks)- return None if reasoning_item is None else dict(reasoning_item)+ return None if reasoning_item is None else dict(reasoning_item) # mutable-ok: API message payloadif btype == "tool_use":return { # mutable-ok: API message payload"type": "function_call","call_id": first.get("id", ""),"name": first.get("name", ""),- "arguments": json.dumps(first.get("input", {})),+ "arguments": json.dumps(first.get("input", {})), # mutable-ok: API message payload}return None