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-apiVerified import paths — ran on the pinned version, not inferred.
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`.
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.
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.
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.
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.
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.
Explicitly install the `langchain` package (`pip install langchain`) in your environment if your code relies on modules beyond those provided by `langchain-core`.