Home / Function/ _ensure_sync_client_available() — langchain Function Reference

_ensure_sync_client_available() — langchain Function Reference

Architecture documentation for the _ensure_sync_client_available() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6086a2e4_e2cd_389e_0d61_cb83485f9aef["_ensure_sync_client_available()"]
  2a683305_667b_3567_cab9_9f77e29d4afa["BaseChatOpenAI"]
  6086a2e4_e2cd_389e_0d61_cb83485f9aef -->|defined in| 2a683305_667b_3567_cab9_9f77e29d4afa
  ad60e96a_ba3b_fa9d_754c_16ef8861396c["_stream_responses()"]
  ad60e96a_ba3b_fa9d_754c_16ef8861396c -->|calls| 6086a2e4_e2cd_389e_0d61_cb83485f9aef
  eee344d5_cb34_d6fa_ca18_010bbd1e6cd0["_stream()"]
  eee344d5_cb34_d6fa_ca18_010bbd1e6cd0 -->|calls| 6086a2e4_e2cd_389e_0d61_cb83485f9aef
  ab5f2298_5c1f_3b25_f23a_6b16e835aba5["_generate()"]
  ab5f2298_5c1f_3b25_f23a_6b16e835aba5 -->|calls| 6086a2e4_e2cd_389e_0d61_cb83485f9aef
  style 6086a2e4_e2cd_389e_0d61_cb83485f9aef fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/langchain_openai/chat_models/base.py lines 1154–1162

    def _ensure_sync_client_available(self) -> None:
        """Check that sync client is available, raise error if not."""
        if self.client is None:
            msg = (
                "Sync client is not available. This happens when an async callable "
                "was provided for the API key. Use async methods (ainvoke, astream) "
                "instead, or provide a string or sync callable for the API key."
            )
            raise ValueError(msg)

Domain

Subdomains

Frequently Asked Questions

What does _ensure_sync_client_available() do?
_ensure_sync_client_available() is a function in the langchain codebase, defined in libs/partners/openai/langchain_openai/chat_models/base.py.
Where is _ensure_sync_client_available() defined?
_ensure_sync_client_available() is defined in libs/partners/openai/langchain_openai/chat_models/base.py at line 1154.
What calls _ensure_sync_client_available()?
_ensure_sync_client_available() is called by 3 function(s): _generate, _stream, _stream_responses.

Analyze Your Own Codebase

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

Try Supermodel Free