LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    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
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdk

    langgraph-sdk

    Description

    LangGraph Python SDK

    This repository contains the Python SDK for interacting with the LangSmith Deployment REST API.

    Quick Start

    To get started with the Python SDK, install the package

    pip install -U langgraph-sdk

    You will need a running LangGraph API server. If you're running a server locally using langgraph-cli, SDK will automatically point at http://localhost:8123, otherwise you would need to specify the server URL when creating a client.

    from langgraph_sdk import get_client
    
    # If you're using a remote server, initialize the client with `get_client(url=REMOTE_URL)`
    client = get_client()
    
    # List all assistants
    assistants = await client.assistants.search()
    
    # We auto-create an assistant for each graph you register in config.
    agent = assistants[0]
    
    # Start a new thread
    thread = await client.threads.create()
    
    # Start a streaming run
    input = {"messages": [{"role": "human", "content": "what's the weather in la"}]}
    async for chunk in client.runs.stream(thread['thread_id'], agent['assistant_id'], input=input):
        print(chunk)

    Classes

    Class

    SWRResult

    Result wrapper returned by :func:swr.

    Class

    LangGraphError

    Class

    APIError

    Class

    APIResponseValidationError

    Class

    APIStatusError

    Class

    APIConnectionError

    Class

    APITimeoutError

    Class

    BadRequestError

    Class

    AuthenticationError

    Class

    PermissionDeniedError

    Class

    NotFoundError

    Class

    ConflictError

    Class

    UnprocessableEntityError

    Class

    RateLimitError

    Class

    InternalServerError

    Class

    BytesLineDecoder

    Handles incrementally reading lines from text.

    Class

    SSEDecoder

    Class

    LangSmithTracing

    Configuration for LangSmith tracing.

    Class

    Config

    Configuration options for a call.

    Class

    Checkpoint

    Represents a checkpoint in the execution process.

    Class

    GraphSchema

    Defines the structure and properties of a graph.

    Class

    AssistantBase

    Base model for an assistant.

    Class

    AssistantVersion

    Represents a specific version of an assistant.

    Class

    Assistant

    Represents an assistant with additional properties.

    Class

    AssistantsSearchResponse

    Paginated response for assistant search results.

    Class

    Interrupt

    Represents an interruption in the execution flow.

    Class

    Thread

    Represents a conversation thread.

    Class

    ThreadTask

    Represents a task within a thread.

    Class

    ThreadState

    Represents the state of a thread.

    Class

    ThreadUpdateStateResponse

    Represents the response from updating a thread's state.

    Class

    Run

    Represents a single execution run.

    Class

    Cron

    Represents a scheduled task.

    Class

    CronUpdate

    Payload for updating a cron job. All fields are optional.

    Class

    RunCreate

    Defines the parameters for initiating a background run.

    Class

    Item

    Represents a single document or data entry in the graph's Store.

    Class

    ListNamespaceResponse

    Response structure for listing namespaces.

    Class

    SearchItem

    Item with an optional relevance score from search operations.

    Class

    SearchItemsResponse

    Response structure for searching items.

    Class

    StreamPart

    Represents a part of a stream response.

    Class

    TaskPayload

    Payload for a task start event.

    Class

    TaskResultPayload

    Payload for a task result event.

    Class

    CheckpointTaskPayload

    A task entry within a CheckpointPayload.

    Class

    CheckpointPayload

    Payload for a checkpoint event.

    Class

    RunMetadataPayload

    Payload for the metadata control event.

    Class

    ValuesStreamPart

    Stream part emitted for stream_mode="values".

    Class

    UpdatesStreamPart

    Stream part emitted for stream_mode="updates".

    Class

    MessagesPartialStreamPart

    Stream part emitted for partial message chunks (messages/partial).

    Class

    MessagesCompleteStreamPart

    Stream part emitted for complete messages (messages/complete).

    Class

    MessagesMetadataStreamPart

    Stream part emitted for message metadata (messages/metadata).

    Class

    MessagesTupleStreamPart

    Stream part emitted for stream_mode="messages" (raw message+metadata pair).

    Class

    CustomStreamPart

    Stream part emitted for stream_mode="custom".

    Class

    CheckpointsStreamPart

    Stream part emitted for stream_mode="checkpoints".

    Class

    TasksStreamPart

    Stream part emitted for stream_mode="tasks".

    Class

    DebugStreamPart

    Stream part emitted for stream_mode="debug".

    Class

    MetadataStreamPart

    Control event with run_id and other run metadata.

    Class

    Send

    Represents a message to be sent to a specific node in the graph.

    Class

    Command

    Represents one or more commands to control graph execution flow and state.

    Class

    RunCreateMetadata

    Metadata for a run creation request.

    Class

    LangGraphBetaWarning

    Warning for beta features in LangGraph SDK.

    Class

    DuplicateHandlerError

    Raised when attempting to register a duplicate encryption/decryption handler.

    Class

    Encryption

    Add custom at-rest encryption to your LangGraph application.

    Class

    EncryptionContext

    Context passed to encryption/decryption handlers.

    Class

    SyncCronClient

    Synchronous client for managing cron jobs in LangGraph.

    Class

    SyncStoreClient

    A client for synchronous operations on a key-value store.

    Class

    SyncLangGraphClient

    Synchronous client for interacting with the LangGraph API.

    Class

    SyncThreadsClient

    Synchronous client for managing threads in LangGraph.

    Class

    SyncAssistantsClient

    Client for managing assistants in LangGraph synchronously.

    Class

    SyncHttpClient

    Handle synchronous requests to the LangGraph API.

    Class

    SyncRunsClient

    Synchronous client for managing runs in LangGraph.

    Class

    Auth

    Add custom authentication and authorization management to your LangGraph application.

    Class

    MinimalUser

    User objects must at least expose the identity property.

    Class

    MinimalUserDict

    The dictionary representation of a user.

    Class

    BaseUser

    The base ASGI user protocol

    Class

    StudioUser

    A user object that's populated from authenticated requests from the LangGraph studio.

    Class

    BaseAuthContext

    Base class for authentication context.

    Class

    AuthContext

    Complete authentication context with resource and action information.

    Class

    ThreadTTL

    Time-to-live configuration for a thread.

    Class

    ThreadsCreate

    Parameters for creating a new thread.

    Class

    ThreadsRead

    Parameters for reading thread state or run information.

    Class

    ThreadsUpdate

    Parameters for updating a thread or run.

    Class

    ThreadsDelete

    Parameters for deleting a thread.

    Class

    ThreadsSearch

    Parameters for searching threads.

    Class

    RunsCreate

    Payload for creating a run.

    Class

    AssistantsCreate

    Payload for creating an assistant.

    Class

    AssistantsRead

    Payload for reading an assistant.

    Class

    AssistantsUpdate

    Payload for updating an assistant.

    Class

    AssistantsDelete

    Payload for deleting an assistant.

    Class

    AssistantsSearch

    Payload for searching assistants.

    Class

    CronsCreate

    Payload for creating a cron job.

    Class

    CronsDelete

    Payload for deleting a cron job.

    Class

    CronsRead

    Payload for reading a cron job.

    Class

    CronsUpdate

    Payload for updating a cron job.

    Class

    CronsSearch

    Payload for searching cron jobs.

    Class

    StoreGet

    Operation to retrieve a specific item by its namespace and key.

    Class

    StoreSearch

    Operation to search for items within a specified namespace hierarchy.

    Class

    StoreListNamespaces

    Operation to list and filter namespaces in the store.

    Class

    StorePut

    Operation to store, update, or delete an item in the store.

    Class

    StoreDelete

    Operation to delete an item from the store.

    Class

    on

    Namespace for type definitions of different API operations.

    Class

    threads

    Types for thread-related operations.

    Class

    create

    Type for thread creation parameters.

    Class

    create_run

    Type for creating or streaming a run.

    Class

    read

    Type for thread read parameters.

    Class

    update

    Type for thread update parameters.

    Class

    delete

    Type for thread deletion parameters.

    Class

    search

    Type for thread search parameters.

    Class

    assistants

    Types for assistant-related operations.

    Class

    create

    Type for assistant creation parameters.

    Class

    read

    Type for assistant read parameters.

    Class

    update

    Type for assistant update parameters.

    Class

    delete

    Type for assistant deletion parameters.

    Class

    search

    Type for assistant search parameters.

    Class

    crons

    Types for cron-related operations.

    Class

    create

    Type for cron creation parameters.

    Class

    read

    Type for cron read parameters.

    Class

    update

    Type for cron update parameters.

    Class

    delete

    Type for cron deletion parameters.

    Class

    search

    Type for cron search parameters.

    Class

    store

    Types for store-related operations.

    Class

    put

    Type for store put parameters.

    Class

    get

    Type for store get parameters.

    Class

    search

    Type for store search parameters.

    Class

    delete

    Type for store delete parameters.

    Class

    list_namespaces

    Type for store list namespaces parameters.

    Class

    HTTPException

    HTTP exception that you can raise to return a specific HTTP error response.

    Class

    CronClient

    Client for managing recurrent runs (cron jobs) in LangGraph.

    Class

    StoreClient

    Client for interacting with the graph's shared storage.

    Class

    LangGraphClient

    Top-level client for LangGraph API.

    Class

    ThreadsClient

    Client for managing threads in LangGraph.

    Class

    AssistantsClient

    Client for managing assistants in LangGraph.

    Class

    HttpClient

    Handle async requests to the LangGraph API.

    Class

    RunsClient

    Client for managing runs in LangGraph.

    Functions

    Function

    cache_get

    Get a value from the cache.

    Function

    cache_set

    Set a value in the cache.

    Function

    swr

    Load a cached value using stale-while-revalidate semantics.

    Function

    aiter_lines_raw

    Function

    iter_lines_raw

    Function

    get_sync_client

    Get a synchronous LangGraphClient instance.

    Function

    is_studio_user

    Function

    get_client

    Create and configure a LangGraphClient.

    Function

    configure_loopback_transports

    Function

    get_asgi_transport

    Modules

    Types

    Module

    langgraph_sdk

    Module

    cache

    Key/value cache for use inside LangGraph deployments.

    Module

    client

    The LangGraph client implementations connect to the LangGraph API.

    Module

    runtime

    Module

    errors

    Module

    sse

    Adapted from httpx_sse to split lines on

    Module

    schema

    Data models for interacting with the LangGraph API.

    Module

    encryption

    Custom encryption support for LangGraph.

    Module

    types

    Encryption and decryption types for LangGraph.

    Module

    cron

    Synchronous cron client for LangGraph SDK.

    Module

    store

    Synchronous store client for LangGraph SDK.

    Module

    client

    Sync LangGraph client.

    Module

    threads

    Synchronous client for managing threads in LangGraph.

    Module

    assistants

    Synchronous client for managing assistants in LangGraph.

    Module

    http

    Synchronous HTTP client for LangGraph API.

    Module

    runs

    Synchronous client for managing runs in LangGraph.

    Module

    auth

    Module

    types

    Authentication and authorization types for LangGraph.

    Module

    exceptions

    Exceptions used in the auth system.

    Module

    cron

    Async client for managing recurrent runs (cron jobs) in LangGraph.

    Module

    store

    Async Store client for LangGraph SDK.

    Module

    client

    Async LangGraph client.

    Module

    threads

    Async client for managing threads in LangGraph.

    Module

    assistants

    Async client for managing assistants in LangGraph.

    Module

    http

    HTTP client for async operations.

    Module

    runs

    Async client for managing runs in LangGraph.

    Module

    types

    Type aliases and constants.

    Module

    utilities

    Shared utility functions for async and sync clients.

    Type

    BytesLike

    Type

    Json

    Represents a JSON-like structure, which can be None or a dictionary with string keys and any values.

    Type

    PrimitiveData

    Type

    QueryParamTypes

    Type

    DebugPayload

    Wrapper payload for debug events. Discriminate on type.

    Type

    StreamPartV2

    Discriminated union of all v2 stream part types.

    Type

    Input

    Type

    Context

    Type

    FilterType

    Response type for authorization handlers.

    Type

    HandlerResult

    The result of a handler can be:

    Type

    TimeoutTypes