Home / Function/ test_parse_adds_structured_outputs_beta_header() — anthropic-sdk-python Function Reference

test_parse_adds_structured_outputs_beta_header() — anthropic-sdk-python Function Reference

Architecture documentation for the test_parse_adds_structured_outputs_beta_header() function in test_output_format_conversion.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  810805ee_0bad_061b_3d83_a44520475e52["test_parse_adds_structured_outputs_beta_header()"]
  91bf20e2_262e_34e5_0c93_658022fb45df["TestStructuredOutputsBetaHeader"]
  810805ee_0bad_061b_3d83_a44520475e52 -->|defined in| 91bf20e2_262e_34e5_0c93_658022fb45df
  style 810805ee_0bad_061b_3d83_a44520475e52 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/api_resources/beta/test_output_format_conversion.py lines 384–416

    def test_parse_adds_structured_outputs_beta_header(self, client: Anthropic, respx_mock: MockRouter) -> None:
        """Verify .parse() auto-adds structured-outputs-2025-12-15 beta header."""

        class DataModel(BaseModel):
            value: int

        respx_mock.post("/v1/messages?beta=true").mock(
            return_value=httpx.Response(
                200,
                json={
                    "id": "msg_123",
                    "type": "message",
                    "role": "assistant",
                    "model": "claude-sonnet-4-5",
                    "content": [{"text": '{"value": 42}', "type": "text"}],
                    "stop_reason": "end_turn",
                    "usage": {"input_tokens": 10, "output_tokens": 20},
                },
            )
        )

        with warnings.catch_warnings(record=True):
            warnings.simplefilter("always")
            client.beta.messages.parse(
                max_tokens=1024,
                messages=[{"role": "user", "content": "Test"}],
                model="claude-sonnet-4-5",
                output_format=DataModel,
            )

        request = respx_mock.calls.last.request
        assert "anthropic-beta" in request.headers
        assert "structured-outputs-2025-12-15" in request.headers["anthropic-beta"]

Subdomains

Frequently Asked Questions

What does test_parse_adds_structured_outputs_beta_header() do?
test_parse_adds_structured_outputs_beta_header() is a function in the anthropic-sdk-python codebase, defined in tests/api_resources/beta/test_output_format_conversion.py.
Where is test_parse_adds_structured_outputs_beta_header() defined?
test_parse_adds_structured_outputs_beta_header() is defined in tests/api_resources/beta/test_output_format_conversion.py at line 384.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free