Registry / llm-agents / langgraph-api

langgraph-api

JSON →
library0.13.0pypypi✓ verified 25d ago

langgraph-api provides a convenient API layer for serving LangGraph agents as RESTful or RPC endpoints. It simplifies the deployment of complex, stateful LLM agents by integrating with FastAPI and Pydantic, making it easy to expose agent functionality over HTTP. It is currently at version 0.7.98 and is part of the rapidly evolving LangChain ecosystem, implying frequent updates.

pip install langgraph-api
INSTALL
IMPORT
SIG · LANGGRAPH-API
L
langgraph-api
llm-agentspythonv0.13.0
Install
12.0s avg
Import
Disk
216MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.13.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/2 runs
1/2 runs
py 3.11
✓ —
✓ 13.25s
py 3.12
✓ —
✓ 11.25s
py 3.13
✓ —
✓ 11.6s
py 3.9
1/2 runs
1/2 runs
216MB installed
● package 216MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

create_langgraph_api
from langgraph_api import create_langgraph_api
from langgraph_api import create_langgraph_api

Demonstrates how to create a simple LangGraph `AgentExecutor` and then wrap it using `create_langgraph_api` to expose it as a FastAPI application. This makes the agent accessible via HTTP endpoints like `/agent/invoke` and `/agent/stream_log`.

import os from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_react_agent from langchain_core.prompts import PromptTemplate from langchain_core.tools import tool from langgraph_api import create_langgraph_api from fastapi import FastAPI # Set API key for OpenAI, or any other LLM provider os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "sk-mock-key-for-test") # 1. Define a tool @tool def multiply(a: int, b: int) -> int: """Multiply two integers together.""" return a * b tools = [multiply] # 2. Define an LLM llm = ChatOpenAI(temperature=0) # 3. Define a prompt template prompt = PromptTemplate.from_template(""" You are a helpful assistant. Answer the following questions as best you can. You have access to the following tools: {tools} {agent_scratchpad} """) # 4. Create a React agent agent = create_react_agent(llm, tools, prompt) # 5. Create an AgentExecutor (LangGraph runnable) agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True) # 6. Create the LangGraph API app app = FastAPI(title="My Agent API") langgraph_api_app = create_langgraph_api(app, agent_executor, path="/agent") # To run this application: # Save the code as 'main.py' (or any other name) # Execute from your terminal: uvicorn main:app --port 8000 --reload # Then access via: http://localhost:8000/agent/invoke or /agent/stream_log print("LangGraph API application created. To run, use: uvicorn your_module_name:app --port 8000") print("Example: uvicorn main:app --port 8000 --reload")
langgraph --version
Debug
Known issues
breakingThe library is in active development (currently in `0.x.x` versions) and does not strictly adhere to semantic versioning. This means breaking changes can occur in minor or patch releases, requiring frequent updates to your code.
fix
Regularly consult the official documentation and GitHub releases for breaking changes when upgrading versions. Pin specific patch versions in your `requirements.txt` to avoid unexpected breakage.
affects: <1.0.0
gotchaBy default, `langgraph-api` manages agent state per request/session. Without careful configuration (e.g., providing a custom `state_getter`), concurrent users or requests might not have isolated state or might interact with the agent's state in unexpected ways, leading to cross-talk or incorrect responses.
fix
Thoroughly understand LangGraph's state management. If shared state or specific session isolation is required, implement a custom `state_getter` and `state_setter` functions when creating the API, ensuring state is correctly managed per user or session.
affects: All
gotchaThe API layer itself does not provide built-in authentication or authorization mechanisms. Deploying a `langgraph-api` endpoint without external security measures can expose your agent to unauthorized access.
fix
Implement robust authentication and authorization using FastAPI's security features (e.g., OAuth2, API Keys) or integrate with an API gateway. This is critical for any production deployment.
affects: All
gotcha`create_langgraph_api` is specifically designed to wrap `BaseAgentExecutor` or other LangGraph runnables that conform to a particular input/output schema. Attempting to wrap generic LangChain runnables or custom graphs that do not meet these expectations might lead to runtime errors or unexpected behavior.
fix
Ensure the runnable passed to `create_langgraph_api` is a properly configured `AgentExecutor` from LangGraph or a custom Runnable that matches the expected `input_messages` and `output_messages` interface.
affects: All
breakingThe `langgraph-api` library strictly requires Python 3.11 or newer. Attempting to install or use it with older Python versions (e.g., 3.9 or 3.10) will result in installation failures (`No matching distribution found`) or runtime errors.
fix
Ensure your development and deployment environments are running Python 3.11 or a more recent version. Update your `requirements.txt` to include `python_version >= '3.11'` or specify a compatible Python version in your Dockerfile or environment setup.
affects: All
gotchaWhile `langgraph-api` depends on `langchain-core`, it does not automatically install the full `langchain` package. If your application uses components from the broader `langchain` ecosystem (e.g., `langchain.agents`, which the test script attempts to import), you must explicitly install the `langchain` package.
fix
Explicitly install the `langchain` package (`pip install langchain`) in your environment if your code relies on modules beyond those provided by `langchain-core`.
affects: All
Upgrade
Version history
0.13.0latest on PyPI · released Aug 21, 2026
Audit
Dependencies
langgraphrequiredCore dependency for defining agents.
fastapirequiredThe web framework used to build the API.
uvicornrequiredThe ASGI server used to run the API.
pydanticrequiredUsed for data validation and serialization.
Agent activity
46 hits · last 30 days
node
42
Amazon
1
OpenAI (training)
1
Resources
langgraph-api — pip install langgraph-api · libregistry