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]

(feat) Anthropic - support Structured Outputs `output_format` for Claude 4.5 sonnet and Opus 4.1 + Arize Phoenix - root span logging (#16949)

Krish Dholakiaac3aa74c22e1
diff --git a/docs/my-website/docs/observability/arize_integration.md b/docs/my-website/docs/observability/arize_integration.md
index a654a1b4de3..0b457f08687 100644
--- a/docs/my-website/docs/observability/arize_integration.md
+++ b/docs/my-website/docs/observability/arize_integration.md
@@ -7,13 +7,6 @@ import TabItem from '@theme/TabItem';
AI Observability and Evaluation Platform
-:::tip
-
-This is community maintained, Please make an issue if you run into a bug
-https://github.com/BerriAI/litellm
-
-:::
-
<Image img={require('../../img/arize.png')} />
@@ -53,7 +46,7 @@ response = litellm.completion(
)
```
-### Using with LiteLLM Proxy
+## Using with LiteLLM Proxy
1. Setup config.yaml
```yaml
@@ -71,7 +64,7 @@ general_settings:
master_key: "sk-1234" # can also be set as an environment variable
environment_variables:
- ARIZE_SPACE_KEY: "d0*****"
+ ARIZE_SPACE_ID: "d0*****"
ARIZE_API_KEY: "141a****"
ARIZE_ENDPOINT: "https://otlp.arize.com/v1" # OPTIONAL - your custom arize GRPC api endpoint
ARIZE_HTTP_ENDPOINT: "https://otlp.arize.com/v1" # OPTIONAL - your custom arize HTTP api endpoint. Set either this or ARIZE_ENDPOINT or Neither (defaults to https://otlp.arize.com/v1 on grpc)
@@ -96,7 +89,8 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \
Supported parameters:
- `arize_api_key`
-- `arize_space_key`
+- `arize_space_key` *(deprecated, use `arize_space_id` instead)*
+- `arize_space_id`
<Tabs>
<TabItem value="sdk" label="SDK">
@@ -117,8 +111,8 @@ response = litellm.completion(
messages=[
{"role": "user", "content": "Hi 👋 - i'm openai"}
],
- arize_api_key=os.getenv("ARIZE_SPACE_2_API_KEY"),
- arize_space_key=os.getenv("ARIZE_SPACE_2_KEY"),
+ arize_api_key=os.getenv("ARIZE_API_KEY"),
+ arize_space_id=os.getenv("ARIZE_SPACE_ID"),
)
```
@@ -159,8 +153,8 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hi 👋 - i'm openai"}],
- "arize_api_key": "ARIZE_SPACE_2_API_KEY",
- "arize_space_key": "ARIZE_SPACE_2_KEY"
+ "arize_api_key": "ARIZE_API_KEY",
+ "arize_space_id": "ARIZE_SPACE_ID"
}'
```
</TabItem>
@@ -183,8 +177,8 @@ response = client.chat.completions.create(
}
],
extra_body={
- "arize_api_key": "ARIZE_SPACE_2_API_KEY",
- "arize_space_key": "ARIZE_SPACE_2_KEY"
+ "arize_api_key": "ARIZE_API_KEY",
+ "arize_space_id": "ARIZE_SPACE_ID"
}
)
@@ -199,5 +193,5 @@ print(response)
- [Schedule Demo 👋](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version)
- [Community Discord 💭](https://discord.gg/wuPM9dRgDw)
-- Our numbers 📞 +1 (770) 8783-106 / ‭+1 (412) 618-6238‬
+- Our numbers 📞 +1 (770) 8783-106 / +1 (412) 618-6238
- Our emails ✉️ [email protected] / [email protected]
diff --git a/docs/my-website/docs/providers/anthropic.md b/docs/my-website/docs/providers/anthropic.md
index afcb6a34d9c..dea7918feda 100644
--- a/docs/my-website/docs/providers/anthropic.md
+++ b/docs/my-website/docs/providers/anthropic.md
@@ -45,10 +45,112 @@ Check this in code, [here](../completion/input.md#translated-openai-params)
:::info
-Anthropic API fails requests when `max_tokens` are not passed. Due to this litellm passes `max_tokens=4096` when no `max_tokens` are passed.
+**Notes:**
+- Anthropic API fails requests when `max_tokens` are not passed. Due to this litellm passes `max_tokens=4096` when no `max_tokens` are passed.
+- `response_format` is fully supported for Claude Sonnet 4.5 and Opus 4.1 models (see [Structured Outputs](#structured-outputs) section)
:::
+## **Structured Outputs**
+
+LiteLLM supports Anthropic's [structured outputs feature](https://platform.claude.com/docs/en/build-with-claude/structured-outputs) for Claude Sonnet 4.5 and Opus 4.1 models. When you use `response_format` with these models, LiteLLM automatically:
+- Adds the required `structured-outputs-2025-11-13` beta header
+- Transforms OpenAI's `response_format` to Anthropic's `output_format` format
+
+### Supported Models
+- `sonnet-4-5` or `sonnet-4.5` (all Sonnet 4.5 variants)
+- `opus-4-1` or `opus-4.1` (all Opus 4.1 variants)
+
+### Example Usage
+
+<Tabs>
+<TabItem value="sdk" label="LiteLLM SDK">
+
+```python
+from litellm import completion
+
+response = completion(
+ model="claude-sonnet-4-5-20250929",
+ messages=[{"role": "user", "content": "What is the capital of France?"}],
+ response_format={
+ "type": "json_schema",
+ "json_schema": {
+ "name": "capital_response",
+ "strict": True,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "country": {"type": "string"},
+ "capital": {"type": "string"}
+ },
+ "required": ["country", "capital"],
+ "additionalProperties": False
+ }
+ }
+ }
+)
+
+print(response.choices[0].message.content)
+# Output: {"country": "France", "capital": "Paris"}
+```
+
+</TabItem>
+<TabItem value="proxy" label="LiteLLM Proxy">
+
+1. Setup config.yaml
+
+```yaml
+model_list:
+ - model_name: claude-sonnet-4-5
+ litellm_params:
+ model: anthropic/claude-sonnet-4-5-20250929
+ api_key: os.environ/ANTHROPIC_API_KEY
+```
+
+2. Start proxy
+
+```bash
+litellm --config /path/to/config.yaml
+```
+
+3. Test it!
+
+```bash
+curl http://0.0.0.0:4000/v1/chat/completions \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer $LITELLM_KEY" \
+ -d '{
+ "model": "claude-sonnet-4-5",
+ "messages": [{"role": "user", "content": "What is the capital of France?"}],
+ "response_format": {
+ "type": "json_schema",
+ "json_schema": {
+ "name": "capital_response",
+ "strict": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "country": {"type": "string"},
+ "capital": {"type": "string"}
+ },
+ "required": ["country", "capital"],
+ "additionalProperties": false
+ }
+ }
+ }
+ }'
+```
+
+</TabItem>
+</Tabs>
+
+:::info
+When using structured outputs with supported models, LiteLLM automatically:
+- Converts OpenAI's `response_format` to Anthropic's `output_schema`
+- Adds the `anthropic-beta: structured-outputs-2025-11-13` header
+- Creates a tool with the schema and forces the model to use it
+:::
+
## API Keys
```python
diff --git a/litellm/integrations/arize/arize.py b/litellm/integrations/arize/arize.py
index 9d587dcfa0e..6e0201bf5b7 100644
--- a/litellm/integrations/arize/arize.py
+++ b/litellm/integrations/arize/arize.py
@@ -48,6 +48,7 @@ class ArizeLogger(OpenTelemetry):
Raises:
ValueError: If required environment variables are not set.
"""
+ space_id = os.environ.get("ARIZE_SPACE_ID")
space_key = os.environ.get("ARIZE_SPACE_KEY")
api_key = os.environ.get("ARIZE_API_KEY")
@@ -68,6 +69,7 @@ class ArizeLogger(OpenTelemetry):
endpoint = "https://otlp.arize.com/v1"
return ArizeConfig(
+ space_id=space_id,
space_key=space_key,
api_key=api_key,
protocol=protocol,
@@ -115,10 +117,10 @@ class ArizeLogger(OpenTelemetry):
try:
config = self.get_arize_config()
- if not config.space_key:
+ if not config.space_id or not config.space_key:
return {
"status": "unhealthy",
- "error_message": "ARIZE_SPACE_KEY environment variable not set",
+ "error_message": "ARIZE_SPACE_ID environment variable not set",
}
if not config.api_key:
diff --git a/litellm/integrations/arize/arize_phoenix.py b/litellm/integrations/arize/arize_phoenix.py
index 666d322cb2e..ab70dd9d0e2 100644
--- a/litellm/integrations/arize/arize_phoenix.py
+++ b/litellm/integrations/arize/arize_phoenix.py
@@ -89,6 +89,11 @@ class ArizePhoenixLogger:
"PHOENIX_API_KEY must be set when using Phoenix Cloud (app.phoenix.arize.com)."
)
+ project_name = os.environ.get("PHOENIX_PROJECT_NAME", "litellm-project")
+
return ArizePhoenixConfig(
- otlp_auth_headers=otlp_auth_headers, protocol=protocol, endpoint=endpoint
+ otlp_auth_headers=otlp_auth_headers,
+ protocol=protocol,
+ endpoint=endpoint,
+ project_name=project_name,
)
diff --git a/litellm/integrations/callback_configs.json b/litellm/integrations/callback_configs.json
index d8a96e71769..7d452d9ef01 100644
--- a/litellm/integrations/callback_configs.json
+++ b/litellm/integrations/callback_configs.json
@@ -11,10 +11,10 @@
"description": "Arize API key for authentication",
"required": true
},
- "arize_space_key": {
+ "arize_space_id": {
"type": "password",
- "ui_name": "Space Key",
- "description": "Arize Space key to identify your workspace",
+ "ui_name": "Space ID",
+ "description": "Arize Space ID to identify your workspace",
"required": true
}
},
diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py
index 468fbc91408..590f5c18d84 100644
--- a/litellm/integrations/opentelemetry.py
+++ b/litellm/integrations/opentelemetry.py
@@ -515,9 +515,9 @@ class OpenTelemetry(CustomLogger):
def _get_dynamic_otel_headers_from_kwargs(self, kwargs) -> Optional[dict]:
"""Extract dynamic headers from kwargs if available."""
- standard_callback_dynamic_params: Optional[
- StandardCallbackDynamicParams
- ] = kwargs.get("standard_callback_dynamic_params")
+ standard_callback_dynamic_params: Optional[StandardCallbackDynamicParams] = (
+ kwargs.get("standard_callback_dynamic_params")
+ )
if not standard_callback_dynamic_params:
return None
@@ -1078,7 +1078,9 @@ class OpenTelemetry(CustomLogger):
span=span, key="hidden_params", value=safe_dumps(hidden_params)
)
# Cost breakdown tracking
- cost_breakdown: Optional[CostBreakdown] = standard_logging_payload.get("cost_breakdown")
+ cost_breakdown: Optional[CostBreakdown] = standard_logging_payload.get(
+ "cost_breakdown"
+ )
if cost_breakdown:
for key, value in cost_breakdown.items():
if value is not None:
@@ -1773,7 +1775,7 @@ class OpenTelemetry(CustomLogger):
"""
Create a span for the received proxy server request.
"""
- # don't create proxy parent spans for arize phoenix
+ # don't create proxy parent spans for arize phoenix - [TODO]: figure out a better way to handle this
if self.callback_name == "arize_phoenix":
return None
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py
index 6a36eb6dc3b..5fca5cba5e2 100644
--- a/litellm/litellm_core_utils/litellm_logging.py
+++ b/litellm/litellm_core_utils/litellm_logging.py
@@ -690,7 +690,7 @@ class Logging(LiteLLMLoggingBaseClass):
except Exception:
# If check fails, continue to next logger
continue
-
+
return None
def get_custom_logger_for_prompt_management(
@@ -3533,7 +3533,7 @@ def _init_custom_logger_compatible_class( # noqa: PLR0915
)
os.environ["OTEL_EXPORTER_OTLP_TRACES_HEADERS"] = (
- f"space_id={arize_config.space_key},api_key={arize_config.api_key}"
+ f"space_id={arize_config.space_key or arize_config.space_id},api_key={arize_config.api_key}"
)
for callback in _in_memory_loggers:
if (
@@ -3556,6 +3556,17 @@ def _init_custom_logger_compatible_class( # noqa: PLR0915
endpoint=arize_phoenix_config.endpoint,
headers=arize_phoenix_config.otlp_auth_headers,
)
+ if arize_phoenix_config.project_name:
+ existing_attrs = os.environ.get("OTEL_RESOURCE_ATTRIBUTES", "")
+ # Add openinference.project.name attribute
+ if existing_attrs:
+ os.environ["OTEL_RESOURCE_ATTRIBUTES"] = (
+ f"{existing_attrs},openinference.project.name={arize_phoenix_config.project_name}"
+ )
+ else:
+ os.environ["OTEL_RESOURCE_ATTRIBUTES"] = (
+ f"openinference.project.name={arize_phoenix_config.project_name}"
+ )
# Set Phoenix project name from environment variable
phoenix_project_name = os.environ.get("PHOENIX_PROJECT_NAME", None)
@@ -3964,8 +3975,6 @@ def get_custom_logger_compatible_class( # noqa: PLR0915
if isinstance(callback, OpenTelemetry):
return callback
elif logging_integration == "arize":
- if "ARIZE_SPACE_KEY" not in os.environ:
- raise ValueError("ARIZE_SPACE_KEY not found in environment variables")
if "ARIZE_API_KEY" not in os.environ:
raise ValueError("ARIZE_API_KEY not found in environment variables")
for callback in _in_memory_loggers:
diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py
index 0e956b10f3f..623a98c132f 100644
--- a/litellm/llms/anthropic/chat/transformation.py
+++ b/litellm/llms/anthropic/chat/transformation.py
@@ -30,6 +30,7 @@ from litellm.types.llms.anthropic import (
AnthropicMcpServerTool,
AnthropicMessagesTool,
AnthropicMessagesToolChoice,
+ AnthropicOutputSchema,
AnthropicSystemMessageContent,
AnthropicThinkingParam,
AnthropicWebSearchTool,
@@ -129,7 +130,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
"parallel_tool_calls",
"response_format",
"user",
- "web_search_options"
+ "web_search_options",
]
if "claude-3-7-sonnet" in model or supports_reasoning(
@@ -384,6 +385,32 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
else:
raise ValueError(f"Unmapped reasoning effort: {reasoning_effort}")
+ def _extract_json_schema_from_response_format(
+ self, value: Optional[dict]
+ ) -> Optional[dict]:
+ if value is None:
+ return None
+ json_schema: Optional[dict] = None
+ if "response_schema" in value:
+ json_schema = value["response_schema"]
+ elif "json_schema" in value:
+ json_schema = value["json_schema"]["schema"]
+
+ return json_schema
+
+ def map_response_format_to_anthropic_output_format(
+ self, value: Optional[dict]
+ ) -> Optional[AnthropicOutputSchema]:
+ json_schema: Optional[dict] = self._extract_json_schema_from_response_format(
+ value
+ )
+ if json_schema is None:
+ return None
+ return AnthropicOutputSchema(
+ type="json_schema",
+ schema=json_schema,
+ )
+
def map_response_format_to_anthropic_tool(
self, value: Optional[dict], optional_params: dict, is_thinking_enabled: bool
) -> Optional[AnthropicMessagesTool]:
@@ -393,11 +420,11 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
): # value is a no-op
return None
- json_schema: Optional[dict] = None
- if "response_schema" in value:
- json_schema = value["response_schema"]
- elif "json_schema" in value:
- json_schema = value["json_schema"]["schema"]
+ json_schema: Optional[dict] = self._extract_json_schema_from_response_format(
+ value
+ )
+ if json_schema is None:
+ return None
"""
When using tools in this way: - https://docs.anthropic.com/en/docs/build-with-claude/tool-use#json-mode
- You usually want to provide a single tool
@@ -487,18 +514,37 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
if param == "top_p":
optional_params["top_p"] = value
if param == "response_format" and isinstance(value, dict):
- _tool = self.map_response_format_to_anthropic_tool(
- value, optional_params, is_thinking_enabled
- )
- if _tool is None:
- continue
- if not is_thinking_enabled:
- _tool_choice = {"name": RESPONSE_FORMAT_TOOL_NAME, "type": "tool"}
- optional_params["tool_choice"] = _tool_choice
+ if any(
+ substring in model
+ for substring in {
+ "sonnet-4.5",
+ "sonnet-4-5",
+ "opus-4.1",
+ "opus-4-1",
+ }
+ ):
+ _output_format = (
+ self.map_response_format_to_anthropic_output_format(value)
+ )
+ if _output_format is not None:
+ optional_params["output_format"] = _output_format
+ else:
+ _tool = self.map_response_format_to_anthropic_tool(
+ value, optional_params, is_thinking_enabled
+ )
+ if _tool is None:
+ continue
+ if not is_thinking_enabled:
+ _tool_choice = {
+ "name": RESPONSE_FORMAT_TOOL_NAME,
+ "type": "tool",
+ }
+ optional_params["tool_choice"] = _tool_choice
+
+ optional_params = self._add_tools_to_optional_params(
+ optional_params=optional_params, tools=[_tool]
+ )
optional_params["json_mode"] = True
- optional_params = self._add_tools_to_optional_params(
- optional_params=optional_params, tools=[_tool]
- )
if (
param == "user"
and value is not None
@@ -660,6 +706,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
self, headers: dict, optional_params: dict
) -> dict:
"""Update headers with optional anthropic beta."""
+
_tools = optional_params.get("tools", [])
for tool in _tools:
if tool.get("type", None) and tool.get("type").startswith(
@@ -671,11 +718,15 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
elif tool.get("type", None) and tool.get("type").startswith(
ANTHROPIC_HOSTED_TOOLS.MEMORY.value
):
- headers[
- "anthropic-beta"
- ] = ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value
+ headers["anthropic-beta"] = (
+ ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value
+ )
if optional_params.get("context_management") is not None:
self._ensure_context_management_beta_header(headers)
+ if optional_params.get("output_format") is not None:
+ headers["anthropic-beta"] = (
+ ANTHROPIC_BETA_HEADER_VALUES.STRUCTURED_OUTPUT_2025_09_25.value
+ )
return headers
def transform_request(
diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py
index cde1f25a032..8d63485be0e 100644
--- a/litellm/proxy/_experimental/mcp_server/server.py
+++ b/litellm/proxy/_experimental/mcp_server/server.py
@@ -1237,9 +1237,9 @@ if MCP_AVAILABLE:
"litellm_logging_obj", None
)
if litellm_logging_obj:
- litellm_logging_obj.model_call_details[
- "mcp_tool_call_metadata"
- ] = standard_logging_mcp_tool_call
+ litellm_logging_obj.model_call_details["mcp_tool_call_metadata"] = (
+ standard_logging_mcp_tool_call
+ )
litellm_logging_obj.model = f"MCP: {name}"
# Check if tool exists in local registry first (for OpenAPI-based tools)
# These tools are registered with their prefixed names
@@ -1740,16 +1740,14 @@ if MCP_AVAILABLE:
)
auth_context_var.set(auth_user)
- def get_auth_context() -> (
- Tuple[
- Optional[UserAPIKeyAuth],
- Optional[str],
- Optional[List[str]],
- Optional[Dict[str, Dict[str, str]]],
- Optional[Dict[str, str]],
- Optional[Dict[str, str]],
- ]
- ):
+ def get_auth_context() -> Tuple[
+ Optional[UserAPIKeyAuth],
+ Optional[str],
+ Optional[List[str]],
+ Optional[Dict[str, Dict[str, str]]],
+ Optional[Dict[str, str]],
+ Optional[Dict[str, str]],
+ ]:
"""
Get the UserAPIKeyAuth from the auth context variable.
diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml
index 8c3dcbaea92..29d325b8e66 100644
--- a/litellm/proxy/_new_secret_config.yaml
+++ b/litellm/proxy/_new_secret_config.yaml
@@ -11,33 +11,5 @@ model_list:
model: openai/gpt-4o-mini-transcribe
api_key: os.environ/OPENAI_API_KEY
-agent_list:
- - agent_name: my_custom_agent
- agent_card_params:
- protocolVersion: '1.0'
- name: 'Hello World Agent'
- description: Just a hello world agent
- url: http://localhost:9999/
- version: 1.0.0
- defaultInputModes: ['text']
- defaultOutputModes: ['text']
- capabilities:
- streaming: true
- skills:
- - id: 'hello_world'
- name: 'Returns hello world'
- description: 'just returns hello world'
- tags: ['hello world']
- examples: ['hi', 'hello world']
- supportsAuthenticatedExtendedCard: true
- litellm_params:
- make_public: true
-
litellm_settings:
- callbacks: ["prometheus"]
-
-mcp_servers:
- # HTTP Streamable Server
- deepwiki_mcp_1234:
- url: "https://mcp.deepwiki.com/mcp"
- server_id: deepwiki_mcp_id
\ No newline at end of file
+ callbacks: ["arize"]
\ No newline at end of file
diff --git a/litellm/types/integrations/arize.py b/litellm/types/integrations/arize.py
index e1ec1755f82..be4df30e794 100644
--- a/litellm/types/integrations/arize.py
+++ b/litellm/types/integrations/arize.py
@@ -9,6 +9,7 @@ else:
class ArizeConfig(BaseModel):
+ space_id: Optional[str] = None
space_key: Optional[str] = None
api_key: Optional[str] = None
protocol: Protocol
diff --git a/litellm/types/integrations/arize_phoenix.py b/litellm/types/integrations/arize_phoenix.py
index a8a1fed5a6b..a5da31f56c3 100644
--- a/litellm/types/integrations/arize_phoenix.py
+++ b/litellm/types/integrations/arize_phoenix.py
@@ -9,3 +9,4 @@ class ArizePhoenixConfig(BaseModel):
otlp_auth_headers: Optional[str] = None
protocol: Protocol
endpoint: str
+ project_name: Optional[str] = None
diff --git a/litellm/types/llms/anthropic.py b/litellm/types/llms/anthropic.py
index a6963c1a4c1..fc210a7d084 100644
--- a/litellm/types/llms/anthropic.py
+++ b/litellm/types/llms/anthropic.py
@@ -6,8 +6,8 @@ from typing_extensions import Literal, Required, TypedDict
from .openai import (
ChatCompletionCachedContent,
- ChatCompletionThinkingBlock,
ChatCompletionRedactedThinkingBlock,
+ ChatCompletionThinkingBlock,
)
@@ -31,6 +31,11 @@ AnthropicInputSchema = TypedDict(
)
+class AnthropicOutputSchema(TypedDict, total=False):
+ type: Required[Literal["json_schema"]]
+ schema: Required[dict]
+
+
class AnthropicMessagesTool(TypedDict, total=False):
name: Required[str]
description: str
@@ -463,7 +468,7 @@ class AnthropicResponseContentBlockToolUse(BaseModel):
name: str
input: dict
provider_specific_fields: Optional[Dict[str, Any]] = None
-
+
class Config:
extra = "allow" # Allow provider_specific_fields
@@ -559,3 +564,4 @@ class ANTHROPIC_BETA_HEADER_VALUES(str, Enum):
WEB_FETCH_2025_09_10 = "web-fetch-2025-09-10"
CONTEXT_MANAGEMENT_2025_06_27 = "context-management-2025-06-27"
+ STRUCTURED_OUTPUT_2025_09_25 = "structured-outputs-2025-11-13"
diff --git a/tests/llm_translation/test_anthropic_completion.py b/tests/llm_translation/test_anthropic_completion.py
index accb536afb1..7c849650bf6 100644
--- a/tests/llm_translation/test_anthropic_completion.py
+++ b/tests/llm_translation/test_anthropic_completion.py
@@ -1304,7 +1304,12 @@ def test_anthropic_websearch(optional_params: dict):
litellm._turn_on_debug()
params = {
"model": "anthropic/claude-sonnet-4-5-20250929",
- "messages": [{"role": "user", "content": "What is the current weather in Tokyo right now?. Make sure to search the web for an answer"}],
+ "messages": [
+ {
+ "role": "user",
+ "content": "What is the current weather in Tokyo right now?. Make sure to search the web for an answer",
+ }
+ ],
**optional_params,
}
@@ -1331,7 +1336,9 @@ def test_anthropic_text_editor():
"content": "There'''s a syntax error in my primes.py file. Can you help me fix it?",
}
],
- "tools": [{"type": "text_editor_20250728", "name": "str_replace_based_edit_tool"}],
+ "tools": [
+ {"type": "text_editor_20250728", "name": "str_replace_based_edit_tool"}
+ ],
}
try:
@@ -1692,6 +1699,7 @@ def test_anthropic_via_responses_api():
print(f"✓ All {len(events_seen)} events matched expected structure")
print(f"✓ Received {text_delta_count} text delta chunks")
+
def test_anthropic_strict_parameter_passthrough():
"""Test that the strict parameter in tool parameters is passed through to Anthropic input_schema"""
args = {
@@ -1730,6 +1738,7 @@ def test_anthropic_strict_parameter_passthrough():
assert "input_schema" in tool
assert tool["input_schema"]["strict"] is True
+
def test_anthropic_strict_not_present():
"""Test that the strict parameter in tool parameters is passed through to Anthropic input_schema"""
args = {
@@ -1766,3 +1775,29 @@ def test_anthropic_strict_not_present():
tool = mapped_params["tools"][0]
assert "input_schema" in tool
assert "strict" not in tool["input_schema"]
+
+
+def test_anthropic_structured_output_chat_completion_api():
+ response = litellm.completion(
+ model="claude-sonnet-4-5-20250929",
+ messages=[{"role": "user", "content": "What is the capital of France?"}],
+ response_format={
+ "type": "json_schema",
+ "json_schema": {
+ "name": "final_output",
+ "strict": True,
+ "schema": {
+ "description": 'Progress report for the thinking process\n\nThis model represents a snapshot of the agent\'s current progress during\nthe thinking process, providing a brief description of the current activity.\n\nAttributes:\n agent_doing: Brief description of what the agent is currently doing.\n Should be kept under 10 words. Example: "Learning about home automation"',
+ "properties": {
+ "agent_doing": {"title": "Agent Doing", "type": "string"}
+ },
+ "required": ["agent_doing"],
+ "title": "ThinkingStep",
+ "type": "object",
+ "additionalProperties": False,
+ },
+ },
+ },
+ )
+ assert response is not None
+ print(f"response: {response}")
diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py
index 785ef56e23b..8ff2f0a4474 100644
--- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py
+++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py
@@ -469,6 +469,7 @@ def test_anthropic_chat_transform_request_includes_context_management():
def test_transform_parsed_response_includes_context_management_metadata():
import httpx
+
from litellm.types.utils import ModelResponse
config = AnthropicConfig()
@@ -513,4 +514,45 @@ def test_transform_parsed_response_includes_context_management_metadata():
assert result.__dict__.get("context_management") == context_management_payload
provider_fields = result.choices[0].message.provider_specific_fields
- assert provider_fields and provider_fields["context_management"] == context_management_payload
+ assert (
+ provider_fields
+ and provider_fields["context_management"] == context_management_payload
+ )
+
+
+def test_anthropic_structured_output_beta_header():
+ from litellm.types.utils import CallTypes
+ from litellm.utils import return_raw_request
+
+ response = return_raw_request(
+ endpoint=CallTypes.completion,
+ kwargs={
+ "model": "claude-sonnet-4-5-20250929",
+ "messages": [{"role": "user", "content": "What is the capital of France?"}],
+ "response_format": {
+ "type": "json_schema",
+ "json_schema": {
+ "name": "final_output",
+ "strict": True,
+ "schema": {
+ "description": 'Progress report for the thinking process\n\nThis model represents a snapshot of the agent\'s current progress during\nthe thinking process, providing a brief description of the current activity.\n\nAttributes:\n agent_doing: Brief description of what the agent is currently doing.\n Should be kept under 10 words. Example: "Learning about home automation"',
+ "properties": {
+ "agent_doing": {"title": "Agent Doing", "type": "string"}
+ },
+ "required": ["agent_doing"],
+ "title": "ThinkingStep",
+ "type": "object",
+ "additionalProperties": False,
+ },
+ },
+ },
+ },
+ )
+
+ assert response is not None
+ print(f"response: {response}")
+ print(f"raw_request_headers: {response['raw_request_headers']}")
+ assert (
+ "structured-outputs-2025-11-13"
+ in response["raw_request_headers"]["anthropic-beta"]
+ )
diff --git a/ui/litellm-dashboard/src/components/callback_info_helpers.tsx b/ui/litellm-dashboard/src/components/callback_info_helpers.tsx
index e7e7cc078b7..187c05a468d 100644
--- a/ui/litellm-dashboard/src/components/callback_info_helpers.tsx
+++ b/ui/litellm-dashboard/src/components/callback_info_helpers.tsx
@@ -17,7 +17,7 @@ export const CALLBACK_CONFIGS: CallbackConfig[] = [
supports_key_team_logging: true,
dynamic_params: {
arize_api_key: "password",
- arize_space_key: "password",
+ arize_space_id: "password",
},
description: "Arize Logging Integration",
},