LangServe logo

LangServe

Free

LangServe helps developers deploy LangChain runnables and chains as a REST API. ![GitHub Repo stars](https://img.shields.io/github/stars/langchain-ai/langserve?style=social)

FreeFree tier
Inputs: textOutputs: text
Type
Open Source
Company
LangChain

About LangServe

LangServe is an open-source Python library by LangChain that enables developers to deploy LangChain runnables and chains as a REST API. Built on FastAPI and Pydantic, it automatically infers input/output schemas, provides Swagger documentation, and supports efficient invoke, batch, and streaming endpoints. It also includes a client SDK for remote runnable-like calls, a playground for testing, optional LangSmith tracing, and is designed for simple, non-graph-based deployments. Note: LangServe was deprecated on November 18, 2024; the LangGraph Platform is recommended for new projects, though community bug fixes continue to be accepted.

Key Features

Automatic input/output schema inference and validation via Pydantic
API docs page with JSONSchema and Swagger
/invoke, /batch, and /stream endpoints for efficient remote execution
/stream_log and /stream_events endpoints for streaming intermediate steps
Playground page at /playground/ with streaming output and intermediate steps
Integrated FastAPI server with uvloop and asyncio support
Client SDK to call a LangServe server like a local Runnable
Optional LangSmith tracing by adding API key
Supports concurrent requests on a single server

Pros & Cons

Pros
  • Simple setup with FastAPI and automatic schema generation
  • Supports streaming, batching, and concurrent requests out of the box
  • Client SDK enables seamless remote calls as if runnable were local
  • Built-in playground for testing and debugging
  • Optional tracing integration with LangSmith
Cons
  • Deprecated as of Nov 18, 2024; superseded by LangGraph Platform
  • Not suitable for deploying LangGraph-based applications
  • Versions 0.2.0-0.2.x have OpenAPI doc issues with Pydantic V2 (fixed in 0.3.0+)
  • Client callbacks for server-originating events not supported
  • Security vulnerability in version range 0.0.13-0.0.15 (resolved in 0.0.16)

Best For

Deploying LangChain chains or agents as REST APIs for integration into web or mobile appsEnabling remote invocation of LangChain runnables with streaming responsesBuilding interactive demos or internal tools that require real-time AI responsesServing LangChain applications with built-in API documentation and validation

FAQ

What is LangServe?
LangServe is a Python library that helps developers deploy LangChain runnables and chains as a REST API, integrated with FastAPI and Pydantic.
Is LangServe still maintained?
LangServe was deprecated on November 18, 2024. The repository is archived and read-only. Community bug fixes are still accepted, but no new features will be added. New projects should use the LangGraph Platform.
Which Python libraries does LangServe use?
LangServe is built on FastAPI, Pydantic, uvloop, and asyncio for performance and validation.
How do I deploy a LangChain chain with LangServe?
Install via 'pip install "langserve[server]"', then use the LangChain CLI to bootstrap a project and add your runnables. The library automatically generates endpoints.
Does LangServe support streaming?
Yes, it provides /stream and /stream_log endpoints for streaming responses, and /stream_events (since 0.0.40) for easier intermediate step streaming.
Can I use LangServe with LangGraph?
No, LangServe is designed for simple runnables and chains. For LangGraph applications, use LangGraph Cloud/Platform instead.