### mount_prefix Example Usage Source: https://reference.langchain.com/python/langgraph-cli/schemas/HttpConfig/mount_prefix Illustrates an example value for the mount_prefix, which is a URL path. ```text "/api" ``` -------------------------------- ### Example Dockerfile Lines Configuration Source: https://reference.langchain.com/python/langgraph-cli/schemas/Config/dockerfile_lines Append custom Docker instructions to your base Dockerfile. Useful for installing OS packages or setting environment variables. ```python dockerfile_lines=[ "RUN apt-get update && apt-get install -y libmagic-dev", "ENV MY_CUSTOM_VAR=hello_world" ] ``` -------------------------------- ### start Source: https://reference.langchain.com/python/langgraph-sdk/_sync/stream/SyncRunModule Starts a run. This method is part of the SyncRunModule and is used to initiate a process. ```APIDOC ## start() ### Description Starts a run. This method is part of the SyncRunModule and is used to initiate a process. ### Method Not specified (likely a method call within the SDK) ### Parameters This method does not appear to take any explicit parameters beyond `self`. ### Response No specific response details are provided in the source text. ``` -------------------------------- ### Cache Keys Example Source: https://reference.langchain.com/python/langgraph-cli/schemas/CacheConfig/cache_keys Provides an example of how to define a list of header keys for caching. ```python cache_keys: list[str] ``` ```text ["user_id", "workspace_id"] ``` -------------------------------- ### Encryption Path Example Source: https://reference.langchain.com/python/langgraph-cli/schemas/EncryptionConfig/path Example configuration showing the required format for the 'path' attribute, pointing to a custom encryption handler file and class. ```json { "encryption": { "path": "./encryption.py:my_encryption" } } ``` -------------------------------- ### Example Run Output Source: https://reference.langchain.com/python/langgraph-sdk/_async/runs/RunsClient/wait This is an example of the final state of a run after it has completed, showing the message history. ```json { 'messages': [ { 'content': 'how are you?', 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'human', 'name': None, 'id': 'f51a862c-62fe-4866-863b-b0863e8ad78a', 'example': False }, { 'content': "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.", 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'ai', 'name': None, 'id': 'run-bf1cd3c6-768f-4c16-b62d-ba6f17ad8b36', 'example': False, 'tool_calls': [], 'invalid_tool_calls': [], 'usage_metadata': None } ] } ``` -------------------------------- ### AssistantsCreate Payload Example Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/AssistantsCreate This example demonstrates the structure of the payload used when creating an assistant. It includes all necessary parameters for defining a new assistant. ```python create_params = { "assistant_id": UUID("123e4567-e89b-12d3-a456-426614174000"), "graph_id": "graph123", "config": {"tags": ["tag1", "tag2"]}, "context": {"key": "value"}, "metadata": {"owner": "user123"}, "if_exists": "do_nothing", "name": "Assistant 1" } ``` -------------------------------- ### Get Assistant Schemas Source: https://reference.langchain.com/python/langgraph-sdk/_async/assistants/AssistantsClient/get_schemas Example of how to use the `get_schemas` method to retrieve the schema for a specific assistant. Requires an initialized client and an assistant ID. ```python client = get_client(url="http://localhost:2024") schema = await client.assistants.get_schemas( assistant_id="my_assistant_id" ) print(schema) ``` -------------------------------- ### Get Thread History Example Source: https://reference.langchain.com/python/langgraph-sdk/_async/threads/ThreadsClient/get_history This example demonstrates how to fetch the state history for a given thread ID, limiting the results to 5 states. Ensure you have initialized the client with the correct URL. ```python client = get_client(url="http://localhost:2024) thread_state = await client.threads.get_history( thread_id="my_thread_id", limit=5, ) ``` -------------------------------- ### Example Usage of SyncThreadsClient.get Source: https://reference.langchain.com/python/langgraph-sdk/_sync/threads/SyncThreadsClient/get Demonstrates how to retrieve a thread by its ID using the `get` method. Ensure you have initialized the `SyncThreadsClient` with the correct URL. ```python client = get_sync_client(url="http://localhost:2024") thread = client.threads.get( thread_id="my_thread_id" ) print(thread) ``` -------------------------------- ### Example Usage of SyncStoreClient.get_item Source: https://reference.langchain.com/python/langgraph-sdk/_sync/store/SyncStoreClient/get_item Demonstrates how to retrieve a single item from the store using the `get_item` method. This example shows the necessary import and client initialization, followed by a call to `get_item` with a namespace and key, and finally prints the retrieved item. ```python client = get_sync_client(url="http://localhost:8123") item = client.store.get_item( ["documents", "user123"], key="item456", ) print(item) ``` -------------------------------- ### Async RunModule Start Method Signature Source: https://reference.langchain.com/python/langgraph-sdk/_async/stream/RunModule/start This is the signature for the asynchronous `start` method. It accepts optional input, configuration, and metadata, returning a dictionary containing the run ID. ```python start( self, *, input: Any = None, config: dict[str, Any] | None = None, metadata: dict[str, Any] | None = None, ) -> dict[str, Any] ``` -------------------------------- ### ThreadsCreate Example Parameters Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/ThreadsCreate Demonstrates how to define the parameters for creating a new thread using ThreadsCreate. ```python create_params = { "thread_id": UUID("123e4567-e89b-12d3-a456-426614174000"), "metadata": {"owner": "user123"}, "if_exists": "do_nothing" } ``` -------------------------------- ### Example Usage of ThreadsClient.prune Source: https://reference.langchain.com/python/langgraph-sdk/_async/threads/ThreadsClient/prune Demonstrates how to prune multiple threads by their IDs. This example initializes the client and calls the prune method, then prints the count of pruned threads. ```python client = get_client(url="http://localhost:2024") result = await client.threads.prune( thread_ids=["thread_1", "thread_2"], ) print(result) # {'pruned_count': 2} ``` -------------------------------- ### Example Usage of join_stream Source: https://reference.langchain.com/python/langgraph-sdk/_sync/runs/SyncRunsClient/join_stream Demonstrates how to use the join_stream method to stream run output in real-time. This example shows how to initialize the client and call join_stream with specific thread and run IDs, and a desired stream mode. ```python client = get_sync_client(url="http://localhost:2024") client.runs.join_stream( thread_id="thread_id_to_join", run_id="run_id_to_join", stream_mode=["values", "debug"] ) ``` -------------------------------- ### Example CronsCreate Payload Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/CronsCreate This example shows how to construct the payload for creating a cron job. It includes all optional and required fields. ```python create_params = { "payload": {"key": "value"}, "schedule": "0 0 * * *", "cron_id": UUID("123e4567-e89b-12d3-a456-426614174000"), "thread_id": UUID("123e4567-e89b-12d3-a456-426614174001"), "user_id": "user123", "end_time": datetime(2024, 3, 16, 10, 0, 0) } ``` -------------------------------- ### Example Metadata Dictionary Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/MetadataInput Demonstrates how to create a metadata dictionary with string keys and various JSON-serializable value types. ```python metadata = { "created_by": "user123", "priority": 1, "tags": ["important", "urgent"] } ``` -------------------------------- ### AssistantsUpdate Payload Example Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/AssistantsUpdate This example demonstrates the structure of the payload used when updating an assistant. It includes all configurable parameters for an assistant update. ```python update_params = { "assistant_id": UUID("123e4567-e89b-12d3-a456-426614174000"), "graph_id": "graph123", "config": {"tags": ["tag1", "tag2"]}, "context": {"key": "value"}, "metadata": {"owner": "user123"}, "name": "Assistant 1", "version": 1 } ``` -------------------------------- ### Example Usage of SyncThreadsClient.copy Source: https://reference.langchain.com/python/langgraph-sdk/_sync/threads/SyncThreadsClient/copy Demonstrates how to copy a thread using the SyncThreadsClient. Ensure you have initialized the client with the correct URL. ```python client = get_sync_client(url="http://localhost:2024") client.threads.copy( thread_id="my_thread_id" ) ``` -------------------------------- ### Instantiate SerializerProtocol Source: https://reference.langchain.com/python/langgraph/checkpoint/serde/base/SerializerProtocol Instantiates the SerializerProtocol. This is a basic example showing how to create an instance of the protocol. ```python SerializerProtocol() ``` -------------------------------- ### Example Thread State Output Source: https://reference.langchain.com/python/langgraph-sdk/_async/threads/ThreadsClient/get_state This is an example of the JSON structure returned by the `get_state` method, showing the thread's values, checkpoint information, metadata, and other related details. ```json { "values": { "messages": [ { "content": "how are you?", "additional_kwargs": {}, "response_metadata": {}, "type": "human", "name": null, "id": "fe0a5778-cfe9-42ee-b807-0adaa1873c10", "example": false }, { "content": "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.", "additional_kwargs": {}, "response_metadata": {}, "type": "ai", "name": null, "id": "run-159b782c-b679-4830-83c6-cef87798fe8b", "example": false, "tool_calls": [], "invalid_tool_calls": [], "usage_metadata": null } ] }, "next": [], "checkpoint": { "thread_id": "e2496803-ecd5-4e0c-a779-3226296181c2", "checkpoint_ns": "", "checkpoint_id": "1ef4a9b8-e6fb-67b1-8001-abd5184439d1" } "metadata": { "step": 1, "run_id": "1ef4a9b8-d7da-679a-a45a-872054341df2", "source": "loop", "writes": { "agent": { "messages": [ { "id": "run-159b782c-b679-4830-83c6-cef87798fe8b", "name": null, "type": "ai", "content": "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.", "example": false, "tool_calls": [], "usage_metadata": null, "additional_kwargs": {}, "response_metadata": {}, "invalid_tool_calls": [] } ] } }, "user_id": null, "graph_id": "agent", "thread_id": "e2496803-ecd5-4e0c-a779-3226296181c2", "created_by": "system", "assistant_id": "fe096781-5601-53d2-b2f6-0d3403f7e9ca"}, "created_at": "2024-07-25T15:35:44.184703+00:00", "parent_config": { "thread_id": "e2496803-ecd5-4e0c-a779-3226296181c2", "checkpoint_ns": "", "checkpoint_id": "1ef4a9b8-d80d-6fa7-8000-9300467fad0f" } } ``` -------------------------------- ### Example Usage of StoreClient Source: https://reference.langchain.com/python/langgraph-sdk/_async/store/StoreClient Demonstrates how to initialize a StoreClient and put an item into storage. Requires a running LangGraph instance at the specified URL. ```python client = get_client(url="http://localhost:2024") await client.store.put_item(["users", "user123"], "mem-123451342", {"name": "Alice", "score": 100}) ``` -------------------------------- ### Example Usage of SyncStoreClient Source: https://reference.langchain.com/python/langgraph-sdk/_sync/store/SyncStoreClient Demonstrates how to initialize a SyncStoreClient and store an item in the key-value store. Requires a running service at the specified URL. ```python client = get_sync_client(url="http://localhost:2024")) client.store.put_item(["users", "profiles"], "user123", {"name": "Alice", "age": 30}) ``` -------------------------------- ### Example RunsCreate Parameters Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/RunsCreate Demonstrates how to construct a dictionary representing the parameters for creating a run. This includes essential identifiers, status, metadata, and execution control options. ```python create_params = { "assistant_id": UUID("123e4567-e89b-12d3-a456-426614174000"), "thread_id": UUID("123e4567-e89b-12d3-a456-426614174001"), "run_id": UUID("123e4567-e89b-12d3-a456-426614174002"), "status": "pending", "metadata": {"owner": "user123"}, "prevent_insert_if_inflight": True, "multitask_strategy": "reject", "if_not_exists": "create", "after_seconds": 10, "kwargs": {"key": "value"}, "action": "interrupt" } ``` -------------------------------- ### LangGraph Send Example: Map-Reduce Workflow Source: https://reference.langchain.com/python/langgraph/types/Send Demonstrates how to use the Send class to create a map-reduce workflow. This example dynamically invokes the 'generate_joke' node multiple times with different subjects, then aggregates the results. ```python from typing import Annotated from langgraph.types import Send from langgraph.graph import END, START from langgraph.graph import StateGraph import operator class OverallState(TypedDict): subjects: list[str] jokes: Annotated[list[str], operator.add] def continue_to_jokes(state: OverallState): return [Send("generate_joke", {"subject": s}) for s in state["subjects"]] builder = StateGraph(OverallState) builder.add_node("generate_joke", lambda state: {"jokes": [f"Joke about {state['subject']}"]}) builder.add_conditional_edges(START, continue_to_jokes) builder.add_edge("generate_joke", END) graph = builder.compile() # Invoking with two subjects results in a generated joke for each graph.invoke({"subjects": ["cats", "dogs"]}) # {'subjects': ['cats', 'dogs'], 'jokes': ['Joke about cats', 'Joke about dogs']} ``` -------------------------------- ### HostBackendClient Initialization Source: https://reference.langchain.com/python/langgraph-cli/host_backend/HostBackendClient Shows how to initialize the HostBackendClient with base URL, API key, and an optional tenant ID. ```python __init__( self, base_url: str, api_key: str, tenant_id: str | None = None, ) ``` -------------------------------- ### LangSmithTracing Constructor Source: https://reference.langchain.com/python/langgraph-sdk/schema/LangSmithTracing Initializes LangSmithTracing with project name and example ID. ```python LangSmithTracing( project_name: str, example_id: str, ) ``` -------------------------------- ### Example Usage of ThreadsClient.copy Source: https://reference.langchain.com/python/langgraph-sdk/_async/threads/ThreadsClient/copy Demonstrates how to use the copy method to duplicate a thread. Ensure you have initialized the client with the correct URL. ```python client = get_client(url="http://localhost:2024) await client.threads.copy( thread_id="my_thread_id" ) ``` -------------------------------- ### SyncRunModule.start Source: https://reference.langchain.com/python/langgraph-sdk/_sync/stream/SyncRunModule/start Starts a synchronous run of a module. This method sends a 'run.start' command to the server and returns the run ID. ```APIDOC ## SyncRunModule.start ### Description Starts a synchronous run of a module. This method sends a 'run.start' command to the server and returns the run ID. ### Method `start` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **input** (Any) - Optional - The input to the run. - **config** (dict[str, Any] | None) - Optional - Configuration for the run. - **metadata** (dict[str, Any] | None) - Optional - Metadata for the run. ### Request Example ```json { "input": null, "config": null, "metadata": null } ``` ### Response #### Success Response (200) - **run_id** (str) - The ID of the run. #### Response Example ```json { "run_id": "some_run_id" } ``` ``` -------------------------------- ### Get Sync Client and Assistant Source: https://reference.langchain.com/python/langgraph-sdk/_sync/client/SyncLangGraphClient Instantiate the synchronous client and retrieve an assistant by its ID. ```python client = get_sync_client(url="http://localhost:2024") assistant = client.assistants.get("asst_123") ``` -------------------------------- ### Get Thread State Example Source: https://reference.langchain.com/python/langgraph-sdk/_sync/threads/SyncThreadsClient/get_state Demonstrates how to retrieve the state of a thread by providing its ID and an optional checkpoint ID. This is useful for inspecting the history and current status of a conversation or process managed by LangGraph. ```python client = get_sync_client(url="http://localhost:2024") thread_state = client.threads.get_state( thread_id="my_thread_id", checkpoint_id="my_checkpoint_id" ) print(thread_state) ``` -------------------------------- ### List Namespaces Example Source: https://reference.langchain.com/python/langgraph-sdk/_sync/store/SyncStoreClient/list_namespaces Demonstrates how to list namespaces using the `list_namespaces` method with prefix, max depth, and limit parameters. Ensure you have a running `SyncStoreClient` instance. ```python client = get_sync_client(url="http://localhost:8123") namespaces = client.store.list_namespaces( prefix=["documents"], max_depth=3, limit=10, offset=0 ) print(namespaces) ``` -------------------------------- ### debugger_compose Source: https://reference.langchain.com/python/langgraph-cli/docker/debugger_compose The debugger_compose function is used to configure and start the debugger service within a Docker Compose setup. It accepts optional port and base URL parameters to customize the debugger's network accessibility. ```APIDOC ## debugger_compose ### Description Configures and starts the debugger service for Docker Compose. ### Signature ```python debugger_compose( *, port: int | None = None, base_url: str | None = None, ) -> dict ``` ### Parameters #### Keyword Arguments - **port** (int | None) - Optional. The port to expose the debugger on. - **base_url** (str | None) - Optional. The base URL for the debugger service. ``` -------------------------------- ### RunModule.start Source: https://reference.langchain.com/python/langgraph-sdk/_async/stream/RunModule Starts a run module. This method is part of the command dispatcher for run.start. ```APIDOC ## start() ### Description Starts a run module. This method is part of the command dispatcher for run.start. ### Method (Not specified in source, likely a method call within the SDK) ### Endpoint (Not applicable for SDK method) ### Parameters (No parameters specified for this method in the source) ### Request Example (Not applicable for SDK method) ### Response (No response details specified in the source) ``` -------------------------------- ### Create Supervisor with Specialized Agents Source: https://reference.langchain.com/python/langgraph-supervisor/supervisor/create_supervisor This example shows how to define individual agents with specific tools and then use `create_supervisor` to orchestrate them. It sets up a math agent and a research agent, then creates a supervisor to handle a user query that requires both research and calculation. ```python from langchain_openai import ChatOpenAI from langgraph_supervisor import create_supervisor from langgraph.prebuilt import create_react_agent # Create specialized agents def add(a: float, b: float) -> float: """Add two numbers.""" return a + b def web_search(query: str) -> str: """Search the web for information.""" return 'Here are the headcounts for each of the FAANG companies in 2024...' math_agent = create_react_agent( model="openai:gpt-4o", tools=[add], name="math_expert", ) research_agent = create_react_agent( model="openai:gpt-4o", tools=[web_search], name="research_expert", ) # Create supervisor workflow workflow = create_supervisor( [research_agent, math_agent], model=ChatOpenAI(model="gpt-4o"), ) # Compile and run app = workflow.compile() result = app.invoke({ "messages": [ { "role": "user", "content": "what's the combined headcount of the FAANG companies in 2024?" } ] }) ``` -------------------------------- ### Using Overwrite to Replace Channel Value Source: https://reference.langchain.com/python/langgraph/types/Overwrite Demonstrates how to use the Overwrite type to replace the entire value of a channel, bypassing the default reducer. This example shows a graph where node_b overwrites the messages channel, resulting in a final state of ['b'] instead of ['START', 'a', 'b']. ```python from typing import Annotated import operator from langgraph.graph import StateGraph from langgraph.types import Overwrite class State(TypedDict): messages: Annotated[list, operator.add] def node_a(state: TypedDict): # Normal update: uses the reducer (operator.add) return {"messages": ["a"]} def node_b(state: State): # Overwrite: bypasses the reducer and replaces the entire value return {"messages": Overwrite(value=["b"])} builder = StateGraph(State) builder.add_node("node_a", node_a) builder.add_node("node_b", node_b) builder.set_entry_point("node_a") builder.add_edge("node_a", "node_b") graph = builder.compile() # Without Overwrite in node_b, messages would be ["START", "a", "b"] # With Overwrite, messages is just ["b"] result = graph.invoke({"messages": ["START"]}) assert result == {"messages": ["b"]} ``` -------------------------------- ### Example Usage of list_namespaces Source: https://reference.langchain.com/python/langgraph-sdk/_async/store/StoreClient/list_namespaces Demonstrates how to list namespaces with specified prefix, max_depth, limit, and offset. Ensure you have a client initialized with the correct URL. ```python client = get_client(url="http://localhost:2024") namespaces = await client.store.list_namespaces( prefix=["documents"], max_depth=3, limit=10, offset=0 ) print(namespaces) ``` -------------------------------- ### get() Source: https://reference.langchain.com/python/langgraph-sdk/_sync/http/SyncHttpClient Performs a GET request. ```APIDOC ## get() ### Description Performs a GET request. ### Method GET ### Endpoint [Endpoint not specified in source] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get an Assistant Source: https://reference.langchain.com/python/langgraph-sdk/_async/assistants/AssistantsClient Instantiate the client and retrieve a specific assistant by its ID. Ensure the client is correctly configured with the server URL. ```python client = get_client(url="http://localhost:2024") assistant = await client.assistants.get("assistant_id_123") ``` -------------------------------- ### Functional API Initialization with Store Source: https://reference.langchain.com/python/langgraph/config/get_store Shows how to initialize a functional API entrypoint with a store, enabling get_store() usage within tasks. ```python # or with entrypoint @entrypoint(store=store) def workflow(inputs): ... ``` -------------------------------- ### up Source: https://reference.langchain.com/python/langgraph-cli/cli/up Starts a LangGraph application using the specified configuration. This command can manage Docker Compose, port mappings, and debugging configurations. ```APIDOC ## up ### Description Starts a LangGraph application using the specified configuration. This command can manage Docker Compose, port mappings, and debugging configurations. ### Method CLI Command ### Signature ```python up( config: pathlib.Path, docker_compose: pathlib.Path | None, port: int, recreate: bool, pull: bool, watch: bool, wait: bool, verbose: bool, debugger_port: int | None, debugger_base_url: str | None, postgres_uri: str | None, api_version: str | None, engine_runtime_mode: str, image: str | None, base_image: str | None, ) ``` ### Parameters #### Path Parameters - **config** (pathlib.Path) - Required - Path to the configuration file. - **docker_compose** (pathlib.Path | None) - Optional - Path to the Docker Compose file. #### Query Parameters - **port** (int) - Required - The port to expose the application on. - **recreate** (bool) - Required - Whether to recreate Docker containers. - **pull** (bool) - Required - Whether to pull the latest Docker images. - **watch** (bool) - Required - Whether to watch for file changes and restart. - **wait** (bool) - Required - Whether to wait for the application to become available. - **verbose** (bool) - Required - Whether to enable verbose output. - **debugger_port** (int | None) - Optional - The port for the debugger. - **debugger_base_url** (str | None) - Optional - The base URL for the debugger. - **postgres_uri** (str | None) - Optional - The PostgreSQL connection URI. - **api_version** (str | None) - Optional - The API version to use. - **engine_runtime_mode** (str) - Required - The runtime mode for the engine. - **image** (str | None) - Optional - The Docker image to use for the application. - **base_image** (str | None) - Optional - The base Docker image to use. ``` -------------------------------- ### start Source: https://reference.langchain.com/python/langgraph-sdk/_async/stream/RunModule/start Initiates a run module by sending a `run.start` command to the server. It accepts input, configuration, and metadata, and returns a dictionary containing the run ID. ```APIDOC ## start ### Description Sends `run.start` to the server. Returns the result (`{"run_id": ...}`). ### Method `start` ### Signature ```python start( self, *, input: Any = None, config: dict[str, Any] | None = None, metadata: dict[str, Any] | None = None, ) -> dict[str, Any] ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **input** (Any) - Optional - The input for the run. - **config** (dict[str, Any] | None) - Optional - Configuration for the run. - **metadata** (dict[str, Any] | None) - Optional - Metadata for the run. ### Request Example ```json { "input": null, "config": null, "metadata": null } ``` ### Response #### Success Response (200) - **run_id** (str) - The ID of the run. #### Response Example ```json { "run_id": "some_run_id" } ``` ``` -------------------------------- ### Initialize BackgroundExecutor Source: https://reference.langchain.com/python/langgraph/pregel/_executor/BackgroundExecutor/executor Use this to get an executor instance for a given configuration. It must be entered as a context manager. ```python executor = self.stack.enter_context(get_executor_for_config(config)) ``` -------------------------------- ### Example Usage of SyncRunsClient.stream Source: https://reference.langchain.com/python/langgraph-sdk/_sync/runs/SyncRunsClient/stream Demonstrates how to use the stream method to create a run and receive streamed output. It shows how to configure stream modes, metadata, context, interruption points, feedback keys, webhooks, and multitask strategy. ```python client = get_sync_client(url="http://localhost:2024") async for chunk in client.runs.stream( thread_id=None, assistant_id="agent", input={"messages": [{"role": "user", "content": "how are you?"}]}, stream_mode=["values","debug"], metadata={"name":"my_run"}, context={"model_name": "anthropic"}, interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"], interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"], feedback_keys=["my_feedback_key_1","my_feedback_key_2"], webhook="https://my.fake.webhook.com", multitask_strategy="interrupt" ): print(chunk) ``` -------------------------------- ### create() Source: https://reference.langchain.com/python/langgraph-sdk/_sync/runs/SyncRunsClient Creates a new run for a given thread and assistant. This is the entry point for starting a new graph execution. ```APIDOC ## create() ### Description Creates a new run for a given thread and assistant. This is the entry point for starting a new graph execution. ### Method POST ### Endpoint /runs ### Parameters #### Query Parameters - **thread_id** (string) - Required - The ID of the thread to associate with the run. - **assistant_id** (string) - Required - The ID of the assistant to use for the run. ### Response #### Success Response (200) - **run** (object) - The created run object. - **id** (string) - The unique identifier for the run. - **thread_id** (string) - The ID of the thread. - **assistant_id** (string) - The ID of the assistant. - **status** (string) - The current status of the run (e.g., 'queued', 'running', 'completed'). - **created_at** (string) - The timestamp when the run was created. #### Response Example ```json { "id": "run_abc123", "thread_id": "thread_123", "assistant_id": "asst_456", "status": "queued", "created_at": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### LangGraph Configuration for Encryption Source: https://reference.langchain.com/python/langgraph-sdk/encryption/Encryption Example `langgraph.json` file showing how to configure a custom encryption path. ```json { "dependencies": ["."], "graphs": { "agent": "./my_agent/agent.py:graph" }, "env": ".env", "encryption": { "path": "./encryption.py:my_encryption" } } ``` -------------------------------- ### aget_graph Source: https://reference.langchain.com/python/langgraph/pregel/remote/RemoteGraph/aget_graph Get graph by graph name. This method calls `GET /assistants/{assistant_id}/graph`. ```APIDOC ## aget_graph ### Description Retrieves the graph information for a given assistant ID. It allows for optional inclusion of subgraph representations, controlled by the `xray` parameter. ### Method GET ### Endpoint `/assistants/{assistant_id}/graph` ### Parameters #### Query Parameters - **xray** (int | bool) - Optional - Include graph representation of subgraphs. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included. (default: `False`) ### Response #### Success Response (200) - **DrawableGraph** - The graph information for the assistant in JSON format. ``` -------------------------------- ### DeltaChannel get Method Signature Source: https://reference.langchain.com/python/langgraph/channels/delta/DeltaChannel/get This is the signature for the get method of the DeltaChannel class. It returns any type. ```python get( self, ) -> Any ``` -------------------------------- ### Example max_size Value Source: https://reference.langchain.com/python/langgraph-cli/schemas/CacheConfig/max_size This snippet provides an example of a valid integer value for the max_size attribute. ```text 100 ``` -------------------------------- ### Create a New Thread Source: https://reference.langchain.com/python/langgraph-sdk/_async/threads/ThreadsClient/create Demonstrates how to create a new thread using the `create` method. This example shows setting metadata, a specific thread ID, and the conflict resolution strategy. ```python client = get_client(url="http://localhost:2024") thread = await client.threads.create( metadata={"number":1}, thread_id="my-thread-id", if_exists="raise" ) ``` -------------------------------- ### AssistantsSearch Parameters Example Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/AssistantsSearch Defines the parameters for searching assistants, including graph ID, metadata, limit, and offset. ```python search_params = { "graph_id": "graph123", "metadata": {"owner": "user123"}, "limit": 10, "offset": 0 } ``` -------------------------------- ### PregelScratchpad __init__ Method Source: https://reference.langchain.com/python/langgraph/_internal/_scratchpad/PregelScratchpad The initialization method for PregelScratchpad. It sets up the internal state using provided counters and resume lists. ```python __init__( self, step: int, stop: int, call_counter: Callable[[], int], interrupt_counter: Callable[[], int], get_null_resume: Callable[[bool], Any], resume: list[Any], subgraph_counter: Callable[[], int], ) -> None ``` -------------------------------- ### Get Channel Value Signature Source: https://reference.langchain.com/python/langgraph/channels/base/BaseChannel/get This is the signature for the get() method in BaseChannel. It returns the current value of the channel. ```python get( self, ) -> Value ``` -------------------------------- ### get Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/on/store/get Represents the parameters for a store get operation. This type is used to specify what information to retrieve from a store. ```APIDOC ## get ### Description Type for store get parameters. This class is used to define the parameters for retrieving data from a store. ### Method ```python get() ``` ### Properties - `value` (any) - The value associated with the store get operation. ``` -------------------------------- ### Example ttl_seconds Value Source: https://reference.langchain.com/python/langgraph-cli/schemas/CacheConfig/ttl_seconds An example value for ttl_seconds, representing a time-to-live of 3600 seconds (1 hour). ```text 3600 ``` -------------------------------- ### Initialize SyncAssistantsClient Source: https://reference.langchain.com/python/langgraph-sdk/_sync/client/SyncLangGraphClient/assistants Instantiate the SyncAssistantsClient by passing the HTTP client instance. ```python assistants = SyncAssistantsClient(self.http) ``` -------------------------------- ### StateGraph Initialization with Store Source: https://reference.langchain.com/python/langgraph/config/get_store Demonstrates how to initialize a StateGraph with a store, which is necessary for using get_store() within graph nodes. ```python # with StateGraph graph = ( StateGraph(...) ... .compile(store=store) ) ``` -------------------------------- ### Get Parameters Signature Source: https://reference.langchain.com/python/langgraph-sdk/auth/types/on/store/get This is the signature for the get parameters type. It indicates the available properties for retrieving store values. ```python get() ``` -------------------------------- ### START Constant Definition Source: https://reference.langchain.com/python/langgraph/constants/START Defines the START constant, which represents the first node in a graph. This is a system-interned string for performance. ```python START = sys.intern('__start__') ``` -------------------------------- ### Cache Configuration Example Source: https://reference.langchain.com/python/langgraph-cli/schemas/AuthConfig/cache This JSON object demonstrates how to configure cache settings, specifying keys to use for caching, the time-to-live in seconds, and the maximum number of items to store. ```json { "cache_keys": ["user_id", "workspace_id"], "ttl_seconds": 3600, "max_size": 100 } ``` -------------------------------- ### Get SyncQueue Size Source: https://reference.langchain.com/python/langgraph/_internal/_queue/SyncQueue/qsize Use the `qsize()` method to get an approximate count of items in the queue. Note that this value may not be reliable. ```python qsize( self, ) ``` -------------------------------- ### Instantiate BaseStore Source: https://reference.langchain.com/python/langgraph/store/base/BaseStore This snippet shows how to instantiate the BaseStore. It serves as a base class for persistent key-value stores. ```python BaseStore() ``` -------------------------------- ### StateGraph Example with Reducer and Context Source: https://reference.langchain.com/python/langgraph/graph/state/StateGraph Demonstrates creating a StateGraph with a custom reducer for state aggregation and using runtime context within nodes. The graph is then compiled and invoked. ```python from langchain_core.runnables import RunnableConfig from typing_extensions import Annotated, TypedDict from langgraph.checkpoint.memory import InMemorySaver from langgraph.graph import StateGraph from langgraph.runtime import Runtime def reducer(a: list, b: int | None) -> list: if b is not None: return a + [b] return a class State(TypedDict): x: Annotated[list, reducer] class Context(TypedDict): r: float graph = StateGraph(state_schema=State, context_schema=Context) def node(state: State, runtime: Runtime[Context]) -> dict: r = runtime.context.get("r", 1.0) x = state["x"][-1] next_value = x * r * (1 - x) return {"x": next_value} graph.add_node("A", node) graph.set_entry_point("A") graph.set_finish_point("A") compiled = graph.compile() step1 = compiled.invoke({"x": 0.5}, context={"r": 3.0}) # {'x': [0.5, 0.75]} ``` -------------------------------- ### Get Output from AsyncThreadStream Source: https://reference.langchain.com/python/langgraph-sdk/_async/stream/AsyncThreadStream/output Use the _OutputAwaitable method to get the final output from the stream. This is typically called after the stream has completed processing. ```python output = _OutputAwaitable(self) ``` -------------------------------- ### OAuth2 Security Scheme Example Source: https://reference.langchain.com/python/langgraph-cli/schemas/AuthConfig/openapi Example of an OAuth2 security scheme configuration for an OpenAPI specification. This includes token URL and scopes. ```json { "securitySchemes": { "OAuth2": { "type": "oauth2", "flows": { "password": { "tokenUrl": "/token", "scopes": {"me": "Read user info", "items": "Manage items"} } } } }, "security": [ {"OAuth2": ["me"]} ] } ``` -------------------------------- ### Example Usage of SyncRunsClient.wait Source: https://reference.langchain.com/python/langgraph-sdk/_sync/runs/SyncRunsClient/wait Demonstrates how to use the wait method to create a run, specify an assistant ID, provide input, set metadata, define interruption points, configure a webhook, and specify a multitasking strategy. This is useful for synchronous execution where you need the final state before proceeding. ```python final_state_of_run = client.runs.wait( thread_id=None, assistant_id="agent", input={"messages": [{"role": "user", "content": "how are you?"}]}, metadata={"name":"my_run"}, context={"model_name": "anthropic"}, interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"], interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"], webhook="https://my.fake.webhook.com", multitask_strategy="interrupt" ) print(final_state_of_run) ``` -------------------------------- ### Embedding Model Examples Source: https://reference.langchain.com/python/langgraph-cli/schemas/IndexConfig/embed Examples of how to specify embedding models using provider and model names. These are used to reference recognized embedding services. ```text "openai:text-embedding-3-large" ``` ```text "cohere:embed-multilingual-v3.0" ``` -------------------------------- ### __init__ Method Source: https://reference.langchain.com/python/langgraph-sdk/_sync/client/SyncLangGraphClient The constructor for SyncLangGraphClient, accepting an httpx.Client. ```python __init__( self, client: httpx.Client, ) -> None ``` -------------------------------- ### HttpClient.get Method Signature Source: https://reference.langchain.com/python/langgraph-sdk/_async/http/HttpClient/get This is the signature for the `get` method, which sends a GET request. It accepts a path, optional query parameters, headers, and a callback for responses. ```python get( self, path: str, *, params: QueryParamTypes | None = None, headers: Mapping[str, str] | None = None, on_response: Callable[[httpx.Response], None] | None = None, ) -> Any ``` -------------------------------- ### Initialize HttpClient Source: https://reference.langchain.com/python/langgraph-sdk/_async/client/LangGraphClient/http Instantiates the HttpClient with a given client. This is the primary way to set up the HTTP client for asynchronous interactions. ```python http = HttpClient(client) ``` -------------------------------- ### Healthcheck Start Interval Signature Source: https://reference.langchain.com/python/langgraph-cli/docker/DockerCapabilities/healthcheck_start_interval This attribute defines the start interval for health checks in Docker containers managed by the LangGraph CLI. It is a boolean value. ```python healthcheck_start_interval: bool ``` -------------------------------- ### Local Custom Embedding Function Example Source: https://reference.langchain.com/python/langgraph-cli/schemas/IndexConfig/embed Example of how to reference a custom embedding function defined in a local Python file. This allows for user-defined embedding logic. ```text "src/app.py:embeddings" ``` -------------------------------- ### create Source: https://reference.langchain.com/python/langgraph-sdk/_sync/runs/SyncRunsClient/create Initiates a new run for an assistant or graph. This method allows for detailed configuration of the run, including input, streaming behavior, metadata, and callbacks. ```APIDOC ## POST /runs ### Description Creates a new run for a given assistant or graph. This method allows for detailed configuration of the run, including input, streaming behavior, metadata, and callbacks. ### Method POST ### Endpoint /runs ### Parameters #### Request Body - **thread_id** (str | None) - Yes - The thread ID to assign to the thread. If `None` will create a stateless run. - **assistant_id** (str) - Yes - The assistant ID or graph name to stream from. If using graph name, will default to first assistant created from that graph. - **input** (Input | None) - No - The input to the graph. (default: `None`) - **command** (Command | None) - No - The command to execute. (default: `None`) - **stream_mode** (StreamMode | Sequence[StreamMode]) - No - The stream mode(s) to use. (default: `'values'`) - **stream_subgraphs** (bool) - No - Whether to stream output from subgraphs. (default: `False`) - **stream_resumable** (bool) - No - Whether the stream is considered resumable. If true, the stream can be resumed and replayed in its entirety even after disconnection. (default: `False`) - **metadata** (Mapping[str, Any] | None) - No - Metadata to assign to the run. (default: `None`) - **config** (Config | None) - No - The configuration for the assistant. (default: `None`) - **context** (Context | None) - No - Static context to add to the assistant. !!! version-added "Added in version 0.6.0" (default: `None`) - **checkpoint** (Checkpoint | None) - No - The checkpoint to resume from. (default: `None`) - **checkpoint_during** (bool | None) - No - (deprecated) Whether to checkpoint during the run (or only at the end/interruption). (default: `None`) - **interrupt_before** (All | Sequence[str] | None) - No - Nodes to interrupt immediately before they get executed. (default: `None`) - **interrupt_after** (All | Sequence[str] | None) - No - Nodes to Nodes to interrupt immediately after they get executed. (default: `None`) - **webhook** (str | None) - No - Webhook to call after LangGraph API call is done. (default: `None`) - **multitask_strategy** (MultitaskStrategy | None) - No - Multitask strategy to use. Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'. (default: `None`) - **on_completion** (OnCompletionBehavior | None) - No - Whether to delete or keep the thread created for a stateless run. Must be one of 'delete' or 'keep'. (default: `None`) - **if_not_exists** (IfNotExists | None) - No - How to handle missing thread. Defaults to 'reject'. Must be either 'reject' (raise error if missing), or 'create' (create new thread). (default: `None`) - **after_seconds** (int | None) - No - The number of seconds to wait before starting the run. Use to schedule future runs. (default: `None`) - **langsmith_tracing** (LangSmithTracing | None) - No - LangSmith tracing configuration. Allows routing traces to a specific project or associating with a dataset example. (default: `None`) - **headers** (Mapping[str, str] | None) - No - Optional custom headers to include with the request. (default: `None`) - **on_run_created** (Callable[[RunCreateMetadata], None] | None) - No - Optional callback to call when a run is created. (default: `None`) - **durability** (Durability | None) - No - The durability to use for the run. Values are "sync", "async", or "exit". "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps (default: `None`) ### Response #### Success Response (200) - **Run** (Run) - The created background `Run`. ``` -------------------------------- ### add_edge Source: https://reference.langchain.com/python/langgraph/graph/state/StateGraph/add_edge Adds a directed edge from the start node(s) to the end node in a StateGraph. If multiple start nodes are provided, the graph waits for all of them to complete before executing the end node. ```APIDOC ## add_edge ### Description Adds a directed edge from the start node(s) to the end node in a StateGraph. If multiple start nodes are provided, the graph waits for all of them to complete before executing the end node. ### Method `add_edge` ### Signature ```python add_edge(self, start_key: str | list[str], end_key: str) -> Self ``` ### Parameters #### Path Parameters - **start_key** (str | list[str]) - Required - The key(s) of the start node(s) of the edge. - **end_key** (str) - Required - The key of the end node of the edge. ### Returns `Self` - The instance of the `StateGraph`, allowing for method chaining. ``` -------------------------------- ### StateGraph add_edge Signature Source: https://reference.langchain.com/python/langgraph/graph/state/StateGraph/add_edge This is the signature for the add_edge method. It takes a single start node key or a list of start node keys and a single end node key. ```python add_edge( self, start_key: str | list[str], end_key: str, ) -> Self ``` -------------------------------- ### HostBackendClient Constructor Source: https://reference.langchain.com/python/langgraph-cli/host_backend/HostBackendClient Initializes the HostBackendClient with the base URL, API key, and an optional tenant ID. ```APIDOC ## HostBackendClient Constructor ### Description Initializes the HostBackendClient with the base URL, API key, and an optional tenant ID. ### Signature ```python HostBackendClient(base_url: str, api_key: str, tenant_id: str | None = None) ``` ### Parameters #### Path Parameters - **base_url** (str) - Required - The base URL for the host backend service. - **api_key** (str) - Required - The API key for authentication. - **tenant_id** (str | None) - Optional - The tenant ID. ``` -------------------------------- ### DockerBuildPlan __init__ Method Source: https://reference.langchain.com/python/langgraph-cli/uv_lock/DockerBuildPlan Initializes a DockerBuildPlan object with a list of Dockerfile lines. The 'lines' parameter is of type list[str]. ```python __init__( self, lines: list[str], ) -> None ``` -------------------------------- ### on_tool_start Method Signature Source: https://reference.langchain.com/python/langgraph/pregel/_tools/StreamToolCallHandler/on_tool_start This is the signature for the on_tool_start method. It outlines the parameters accepted by the method, including serialized tool information, input string, run ID, and optional metadata. ```python on_tool_start( self, serialized: dict[str, Any], input_str: str, *, run_id: UUID, parent_run_id: UUID | None = None, tags: list[str] | None = None, metadata: dict[str, Any] | None = None, inputs: dict[str, Any] | None = None, **kwargs: Any = {}, ) -> Any ``` -------------------------------- ### Allow Scoped Store GET Operations Source: https://reference.langchain.com/python/langgraph-sdk/auth/Auth/on This handler permits 'get' operations on the 'store' resource, ensuring that access is restricted to the user's own namespace by modifying the 'namespace' value. ```python @auth.on.store.get def allow_get(ctx: AuthContext, value: Auth.types.on.store.get.value): # Allow gets, scoped to user's namespace value["namespace"] = (ctx.user.identity, *value["namespace"]) ```