Home / Function/ test_openai_response_headers() — langchain Function Reference

test_openai_response_headers() — langchain Function Reference

Architecture documentation for the test_openai_response_headers() function in test_base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  0835a65d_0597_78b6_ee28_1a5f443c230d["test_openai_response_headers()"]
  bd382a4e_442c_13ae_530c_6e34bc43623d["test_base.py"]
  0835a65d_0597_78b6_ee28_1a5f443c230d -->|defined in| bd382a4e_442c_13ae_530c_6e34bc43623d
  style 0835a65d_0597_78b6_ee28_1a5f443c230d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 659–679

def test_openai_response_headers(use_responses_api: bool) -> None:
    """Test ChatOpenAI response headers."""
    chat_openai = ChatOpenAI(
        include_response_headers=True, use_responses_api=use_responses_api
    )
    query = "I'm Pickle Rick"
    result = chat_openai.invoke(query, max_tokens=MAX_TOKEN_COUNT)  # type: ignore[call-arg]
    headers = result.response_metadata["headers"]
    assert headers
    assert isinstance(headers, dict)
    assert "content-type" in headers

    # Stream
    full: BaseMessageChunk | None = None
    for chunk in chat_openai.stream(query, max_tokens=MAX_TOKEN_COUNT):  # type: ignore[call-arg]
        full = chunk if full is None else full + chunk
    assert isinstance(full, AIMessage)
    headers = full.response_metadata["headers"]
    assert headers
    assert isinstance(headers, dict)
    assert "content-type" in headers

Domain

Subdomains

Frequently Asked Questions

What does test_openai_response_headers() do?
test_openai_response_headers() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py.
Where is test_openai_response_headers() defined?
test_openai_response_headers() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py at line 659.

Analyze Your Own Codebase

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

Try Supermodel Free