LangServe is a library developed by LangChain AI that enables developers to deploy LangChain runnables and chains as REST APIs. Built on FastAPI and Pydantic, it provides a streamlined way to expose language model applications through HTTP endpoints. The repository will continue to accept community bug fixes but will not accept new feature contributions going forward.
The core functionality of LangServe centers on converting LangChain objects into production-ready API services. The library automatically infers input and output schemas from LangChain objects and enforces these schemas on every API call with detailed error messages. It provides multiple endpoint types to handle different use cases: the /invoke endpoint for single requests, /batch for processing multiple inputs concurrently, and /stream for streaming responses. Additionally, the /stream_log endpoint allows streaming of intermediate steps from chains and agents, while the /stream_events endpoint, added in version 0.0.40, simplifies streaming without requiring output parsing. The library includes a built-in playground page accessible at /playground/ that displays streaming output and intermediate processing steps, along with optional tracing integration to LangSmith for monitoring and debugging.
LangServe is constructed using battle-tested open-source Python libraries including FastAPI, Pydantic, uvloop, and asyncio. The library provides client SDKs that allow developers to interact with deployed LangServe servers as if they were local Runnables, with a JavaScript client available through LangChain.js. API documentation is automatically generated with JSONSchema and Swagger support, reducing manual documentation overhead.
The library has some documented limitations. Client callbacks for server-originated events are not yet supported. A security vulnerability affecting versions 0.0.13 through 0.0.15 allowed the playground endpoint to access arbitrary files on the server, which was resolved in version 0.0.16.
LangServe is designed primarily for deploying simple Runnables and working with well-known primitives in langchain-core. For applications using LangGraph, the documentation recommends using LangGraph Cloud instead, as it is better suited for that use case. The project provides setup guidance through the LangChain CLI for bootstrapping new projects, uses Poetry for dependency management, and includes an examples directory to help developers get started quickly.