Home / Function/ test_callable_api_key() — langchain Function Reference

test_callable_api_key() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 64–78

def test_callable_api_key(monkeypatch: pytest.MonkeyPatch) -> None:
    original_key = os.environ["OPENAI_API_KEY"]

    calls = {"sync": 0}

    def get_openai_api_key() -> str:
        calls["sync"] += 1
        return original_key

    monkeypatch.delenv("OPENAI_API_KEY")

    model = ChatOpenAI(model="gpt-4.1-mini", api_key=get_openai_api_key)
    response = model.invoke("hello")
    assert isinstance(response, AIMessage)
    assert calls["sync"] == 1

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free