LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdk_asyncclientget_client
    Function●Since v0.3

    get_client

    Copy
    get_client(
      *,
      url: str | None = None,
      api_key: str | None =

    Used in Docs

    • Add encryption at rest
    • Call agents from code
    • Configure LangSmith Agent Server for scale
    • Connect an authentication provider
    • Distributed tracing with Agent Server
    View source on GitHub
    NOT_PROVIDED
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    timeout
    :
    TimeoutTypes
    |
    None
    =
    None
    )
    ->
    LangGraphClient

    Parameters

    NameTypeDescription
    urlstr | None
    Default:None

    Base URL of the LangGraph API.

    • If None, the client first attempts an in-process connection via ASGI transport. If that fails, it defers registration until after app initialization. This only works if the client is used from within the Agent server.
    api_keystr | None
    Default:NOT_PROVIDED

    API key for authentication. Can be:

    • A string: use this exact API key
    • None: explicitly skip loading from environment variables
    • Not provided (default): auto-load from environment in this order:
      1. LANGGRAPH_API_KEY
      2. LANGSMITH_API_KEY
      3. LANGCHAIN_API_KEY
    headersMapping[str, str] | None
    Default:None
    timeoutTimeoutTypes | None
    Default:None

    Create and configure a LangGraphClient.

    The client provides programmatic access to LangSmith Deployment. It supports both remote servers and local in-process connections (when running inside a LangGraph server).

    Connect to a remote server:
    from langgraph_sdk import get_client
    
    # get top-level LangGraphClient
    client = get_client(url="http://localhost:8123")
    
    # example usage: client.<model>.<method_name>()
    assistants = await client.assistants.get(assistant_id="some_uuid")
    Connect in-process to a running LangGraph server:
    from langgraph_sdk import get_client
    
    client = get_client(url=None)
    
    async def my_node(...):
        subagent_result = await client.runs.wait(
            thread_id=None,
            assistant_id="agent",
            input={"messages": [{"role": "user", "content": "Foo"}]},
        )
    Skip auto-loading API key from environment:
    from langgraph_sdk import get_client
    
    # Don't load API key from environment variables
    client = get_client(
        url="http://localhost:8123",
        api_key=None
    )

    Additional HTTP headers to include in requests. Merged with authentication headers.

    HTTP timeout configuration. May be:

    • httpx.Timeout instance
    • float (total seconds)
    • tuple (connect, read, write, pool) in seconds Defaults: connect=5, read=300, write=300, pool=5.