diff --git a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py index 32c981ed09..26027ed320 100644 --- a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py +++ b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py @@ -107,6 +107,7 @@ class AnthropicChatGenerator: "top_k", "extra_headers", "thinking", + "output_config", ] def __init__( @@ -144,6 +145,7 @@ def __init__( - `thinking`: A dictionary of thinking parameters to be passed to the model. The `budget_tokens` passed for thinking should be less than `max_tokens`. For more details and supported models, see: [Anthropic Extended Thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking) + - `output_config`: A dictionary of output configuration options to be passed to the model. :param ignore_tools_thinking_messages: Anthropic's approach to tools (function calling) resolution involves a "chain of thought" messages before returning the actual function names and parameters in a message. If diff --git a/integrations/anthropic/tests/test_chat_generator.py b/integrations/anthropic/tests/test_chat_generator.py index e7b5c8256e..6dca51f4a5 100644 --- a/integrations/anthropic/tests/test_chat_generator.py +++ b/integrations/anthropic/tests/test_chat_generator.py @@ -328,6 +328,20 @@ def test_run_with_params(self, chat_messages, mock_anthropic_completion): assert response["replies"][0].meta["model"] == "claude-sonnet-4-5" assert response["replies"][0].meta["finish_reason"] == "stop" + def test_run_with_output_config(self, chat_messages, mock_anthropic_completion): + """ + Test that output_config is passed to the Anthropic API. + """ + output_config = {"effort": "medium"} + component = AnthropicChatGenerator( + api_key=Secret.from_token("test-api-key"), + generation_kwargs={"max_tokens": 10, "output_config": output_config}, + ) + component.run(chat_messages) + + _, kwargs = mock_anthropic_completion.call_args + assert kwargs["output_config"] == output_config + @pytest.mark.parametrize( "generation_kwargs,expected_kwargs", [