Home / Function/ test_openai_response_headers_async() — langchain Function Reference

test_openai_response_headers_async() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 683–703

async def test_openai_response_headers_async(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 = await chat_openai.ainvoke(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
    async for chunk in chat_openai.astream(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_async() do?
test_openai_response_headers_async() 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_async() defined?
test_openai_response_headers_async() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py at line 683.

Analyze Your Own Codebase

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

Try Supermodel Free