LangChain API (LangServe) Free

-

LangChain API (LangServe) is a REST API deployment framework in the ecosystem. It is built on FastAPI and Pydantic and can deploy LangChain's Runnable objects as production-level API services with one click. Provides standard endpoints such as `/invoke`, `/batch`, `/stream`, `/stream_log`, `/stream_events`, etc., automatically infers input and output Schema and generates OpenAPI documents. The project has entered the deprecation stage in November 2024, and officials recommend that new projects be migrated to LangGraph Platform to obtain more complete Agent deployment capabilities.

LangChain API (LangServe) Product Interface

LangChain API (LangServe): Deploy LLM application chain as a production-grade REST API

Core parameters and statistics

Parameters Details
GitHub Stars 2,300+ (langchain-ai/langserve)
GitHub Forks 272+
Open Source License MIT
Latest version v0.3.3 (2025-10-17)
Project Status Deprecated (from 2024-11-18), only accepting community bug fixes
Alternatives LangGraph Platform (official recommendation)
Underlying framework FastAPI + Pydantic + uvloop + asyncio
Supported programming languages Python (server), JavaScript/TypeScript (client)
Core endpoints /invoke, /batch, /stream, /stream_log, /stream_events, /playground
PyPI downloads Millions cumulative (2023-2025)
pypi package name langserve
Installation method pip install "langserve[all]"

Project Status Interpretation: LangServe was the de facto standard solution for deploying chains and agents in the LangChain ecosystem from June 2023 to November 2024. The cumulative 2.3K+ Stars and millions of PyPI downloads confirm its market penetration. After the deprecation announcement was released in November 2024, LangGraph Platform officially took over its positioning. For existing projects that are still being maintained, LangServe's MIT protocol and simple architecture allow it to continue to be used, but new projects should directly adopt the cloud deployment solution of LangGraph.

Architecture positioning: LangServe is not a model inference engine, but an adaptation layer that "converts LangChain's Runnable abstraction into an HTTP interface". The core problem it solves is that after developers construct a chained pipeline with LCEL, they can expose it as a structured REST endpoint with zero additional code, and get streaming support, concurrency processing, and automatic document generation.

User and market recognition

The "last mile" component of the LangChain ecosystem: With the huge user base of the LangChain framework (138K+ Star), LangServe has naturally been widely adopted as an official deployment solution. Millions of cumulative PyPI downloads indicate that LangServe is the tool of choice for LangChain developers pushing prototypes into production in 2023-2024. The 36 contributors on GitHub include LangChain core team members (eyurtsev, nfcampos, hwchase17) and active community developers.

Enterprise Adoption History: Prior to the launch of LangGraph Cloud, LangServe was the only official solution for multiple Fortune 500 companies to deploy LangChain applications. Typical scenarios include encapsulating the internal RAG Q&A system, document analysis chain, and customer support agent as internal microservices. LangServe's compatibility with the FastAPI ecosystem enables it to be seamlessly integrated into an enterprise's existing API gateway and monitoring system (such as using standard tools such as Prometheus and Datadog). This is its key advantage over "self-built Flask endpoints".

Positioning differences with competing products:

Compare Dimensions LangServe LangGraph Platform Self-built FastAPI endpoint Modal / Beam
Deployment object LangChain Runnable LangGraph Agent Any Python function Universal Python application
Automatic Schema ✅ Automatic Inference ✅ Automatic Inference ❌ Handwriting ❌ Handwriting
Streaming support ✅ Native ✅ Native ❌ Need to be implemented ✅ Need to be implemented
Playground UI ✅ BUILT-IN ✅ BUILT-IN
Agent persistence ✅ Checkpoint
Hosting Services ✅ LangSmith Hosting
Current recommendation ❌ Deprecated ✅ Recommended ⚠️ Flexible but heavy workload ⚠️ Limited scenarios

Market change signal: The abandonment of LangServe is not due to product failure, but a strategic upgrade by LangChain, Inc. - upgrading the deployment capabilities from "lightweight adaptation layer" to "fully managed Agent platform". The REST API design paradigm (invoke/batch/stream endpoint specification) accumulated by LangServe is inherited by LangGraph Platform, similar to Kubernetes deprecating Docker, but the concept of container orchestration is inherited and deepened.

Cost advantage

C-side/individual developer (zero cost):

  • LangServe uses the MIT license and is completely open source and free with no usage restrictions. Individual developers can pip install langserve to deploy on-premises or on any cloud VM, and only bear the cost of server infrastructure (such as AWS EC2 t3.medium about $30-50/month, or lower Serverless options).
  • Hidden Cost: Self-hosted LangServe requires developers to handle operation and maintenance themselves - SSL certificate management, automatic expansion and contraction, log rotation, monitoring and alarming. For personal projects these costs are negligible, but for production services, the investment in operation and maintenance manpower is usually much higher than the software license fee.

Developer/API Integrator (Infrastructure Cost):

  • LangServe itself is free, and the costs are concentrated in three parts: ① The underlying LLM API call fee (billed by Token, has nothing to do with LangServe); ② Server hosting fee (based on concurrency and latency requirements, usually $50-500/month); ③ LangSmith tracking service fee (if enabled, Free tier 3,000 traces/month, Plus tier $39/month/user).
  • Compared with self-built Flask/FastAPI endpoints, LangServe saves about 1-2 weeks of development time in engineering costs (Schema definition, streaming implementation, input verification OpenAPI documents, error handling), but it introduces version dependence on the LangChain runtime.

Enterprise/Private Deployment (Operation and Maintenance Cost Dominated):

  • When an enterprise uses LangServe to deploy production-level AI API, the actual cost distribution is: operation and maintenance manpower > infrastructure > framework cost (zero). For teams with existing Kubernetes clusters and DevOps processes, LangServe’s Dockerized deployment can be quickly integrated into existing CI/CD pipelines.
  • Procurement Risk Tip: Since LangServe has been deprecated, new enterprise projects should evaluate the private deployment plan of LangGraph Platform (need to contact the business to confirm pricing). Existing LangServe services need to develop a migration plan to avoid compliance risks caused by discontinued updates of security patches.

Main functions

Tool open list (REST endpoint primitives exposed by LangServe)

LangServe converts LangChain Runnable into the following standard HTTP endpoints, through which large models or external systems complete an LLM application interaction:

  • POST /{path}/invoke: Receives a single input, calls Runnable synchronously and returns the complete output. The simplest request mode, suitable for non-streaming scenarios (such as batch data processing).
  • POST /{path}/batch: Receives an input array, calls Runnable in parallel and returns an output array. Suitable for batch reasoning, it uses asyncio for concurrent execution internally, significantly improving throughput.
  • POST /{path}/stream: Receives a single input and returns the output Token in Server-Sent Events (SSE) streaming. Achieve typewriter effect, suitable for chat and real-time generation scenarios.
  • POST /{path}/stream_log: Receive a single input and stream the output of all intermediate steps (including Prompt assembly, tool calls, retrieval results, etc.). Used for debugging complex chains and Agent’s reasoning process.
  • POST /{path}/stream_events (v0.2.0+): Receives a single input and streams structured events back. Provides a clearer event model than stream_log, and can obtain intermediate step information without parsing the original output.
  • GET /{path}/input_schema: Returns the JSON Schema of the Runnable input parameter. For clients to dynamically generate request forms or verify input formats.
  • GET /{path}/output_schema: Returns the JSON Schema of the Runnable output parameter. For the client to understand the returned data structure.
  • GET /{path}/config_schema: Returns the JSON Schema of Runnable runtime configuration (such as configurable model parameters).
  • GET /{path}/playground/: An interactive debugging interface accessible by the browser, supporting input configuration, streaming output display and shared links.

Detailed description of core functions

  • Automatic Schema inference and verification: LangServe uses Pydantic to automatically extract JSON Schema from Runnable's input/output type annotations and automatically verify it when each request arrives. Developers do not need to write request/response models by hand, nor do they need to write verification logic in the controller - once the LangChain pipeline is defined, the Schema and verification are automatically ready. When illegal parameters are passed in (such as type mismatch, missing required fields), a structured 422 error is returned.
  • Streaming Output Full Link: End-to-end streaming from LLM to client through SSE protocol. The /stream endpoint returns token-level increments, and /stream_log and /stream_events return step-level intermediates. Clients can use the RemoteRunnable SDK or standard HTTP requests to consume the stream and do not need to handle the AsyncIterator to SSE conversion themselves.
  • Playground interactive debugging interface: Each deployed Runnable automatically gets a web debugging page (/playground/), which supports input configuration (including file upload widget and chat widget), trigger calls, view streaming output and intermediate steps. This interface is extremely useful in development, debugging and demo scenarios - product managers or testers can verify the behavior of the chain without installing Python.
  • LangSmith Trace Integration: After setting LANGCHAIN_TRACING_V2=true and API Key, LangServe automatically reports the complete Trace (input/output/delay/Token usage/intermediate steps) of each API call to LangSmith. This enables visibility consistent with local development in API deployment scenarios, without the need for additional bureaucracy.
  • Multiple endpoint combination: Through the add_routes function of FastAPI, multiple Runnables can be mounted on the same server instance, each mounted under a different /path. Supports mixed deployment of Agents of different models, different chains, and different versions.

Architecture link

Developer-defined LCEL/LangGraph pipeline
       │
       ▼
LangServe (add_routes registered to FastAPI)
       │
       ▼
FastAPI server (automatically generates OpenAPI documents + Schema verification)
       ├── /{path}/invoke → synchronous call
       ├── /{path}/batch → batch call
       ├── /{path}/stream → Token stream
       ├── /{path}/stream_log → Intermediate step log stream
       ├── /{path}/stream_events → Structured event stream
       ├── /{path}/input_schema → Input Schema
       ├── /{path}/output_schema→ Output Schema
       ├── /{path}/config_schema→ Configure Schema
       └── /{path}/playground/ → Web debugging UI
              │
              ▼
       LangSmith Trace (optional tracing)
              │
              ▼
       Developers get feedback → iterative optimization

Engineering Pitfall Guide

  1. Pydantic V1/V2 namespace conflict (LangServe <= 0.2.0): In the context of Pydantic V2, the old version of LangServe cannot generate OpenAPI documentation because FastAPI does not support mixing Pydantic V1 and V2 namespaces. Workaround: Upgrade to LangServe >= 0.3.0 (fixed in final version), or downgrade Pydantic to 1.10.17. New projects use LangGraph Platform directly to avoid this problem.

  2. Playground endpoint security exposure: The Playground endpoint of LangServe v0.0.13-0.0.15 has a CVE vulnerability that allows access to arbitrary files on the server. Solution: Upgrade to v0.0.16+; limit the access scope of the /playground/ endpoint through a reverse proxy (such as Nginx) in the production environment (only allow intranet or specific IP), or disable it in add_routes through disabled_endpoints=["playground"].

  3. Legacy Chain's Schema is incomplete: The input Schema of components (non-LCEL Runnable) inherited from the old version of the Chain class may be incomplete or incorrect, causing the generated OpenAPI document to be inconsistent with the actual parameters. Solution: Manually override the input_schema attribute, or refactor to LCEL Runnable format. It is recommended to conduct a Schema integrity test on the Legacy Chain before connecting to LangServe.

  4. LangGraph Agent incompatibility: LangServe is mainly designed for simple Runnable and Chain. For complex Agents built by LangGraph (including Checkpoint persistence Human-in-the-loop), LangServe cannot provide complete operation support. Solution: LangGraph Agent should be deployed using LangGraph Cloud/Platform instead of LangServe. The official LangServe documentation clearly notes this limitation.

Model and version evolution

Initial release period (2023-06 ~ 2023-09)

  • v0.0.1 (2023-06): Initial version released, the core function is to mount LangChain Runnable to FastAPI applications through add_routes. Supports three basic endpoints: /invoke, /batch, and /stream, automatic Schema inference and Swagger document generation.
  • v0.0.16 (2023-10): Fixes an arbitrary file read security vulnerability in the Playground endpoint, this is the most important security update in the history of LangServe. At the same time, the playground sharing link function is introduced.

Function expansion period (2024-01 ~ 2024-10)

  • v0.2.0 (2024-06): Added /stream_events endpoint, providing a clearer structured event model than /stream_log. Introducing Chat Playground support (providing a dedicated interactive interface for chat-type Runnables). The Playground Widget system is complete and supports file upload widgets and chat history widgets.
  • v0.3.0 (2024-11): Official support for Pydantic V2. A deprecation statement (#791) was released on the same day, and it was officially recommended that new projects be migrated to LangGraph Platform. On the one hand, this is a natural choice for technological evolution - LangGraph's Agent orchestration capabilities have far exceeded the design scope of LangServe; on the other hand, it is a business strategy adjustment - integrating deployment capabilities into the paid platform LangSmith.

Final maintenance period (2025-01 ~ 2025-10)

  • v0.3.3 (2025-10-17): The last official version of LangServe. Fix security dependencies, update npm dependencies, and handle Deprecation warnings. Thereafter, the repository enters a read-only state and only accepts community bug fix PRs. GitHub repository archived on May 5, 2026.

Version Summary: The life cycle of LangServe is about 2 years and 4 months (2023-06 to 2025-10), and has experienced 65 version releases. As a deployment component in the LangChain ecosystem, its design philosophy is inherited by LangGraph Platform - including endpoint specification (invoke/batch/stream), automatic Schema inference and LangSmith integration.

Technical advantages

Declarative API exposure, zero boilerplate code: The core value of LangServe is that "definition is API" - developers use LCEL to define Runnable, and add_routes can get the complete REST API with one line of call. Compared with hand-written FastAPI endpoints: developers need to manually define the Pydantic request/response model, implement POST and streaming endpoints, write input validation logic, and generate OpenAPI documentation. LangServe condenses these approximately 200-300 lines of boilerplate code into 1 line.

Unified abstraction for full-link streaming: LangServe's streaming support is not a simple mapping of async generator to SSE. It understands LangChain's Runnable interface contract - if all components in the chain support streaming (such as ChatOpenAI's streaming mode + StrOutputParser's character-by-character parsing), end-to-end streaming is automatically enabled; if an intermediate section does not support streaming, it is automatically downgraded to buffering mode. Developers do not need to manually determine the throttling compatibility of each chain.

Combined with LangSmith’s native observability: LangServe is the only deployment solution in the LangChain ecosystem that can report production-level Trace with “zero configuration”. After setting two contextual variables, the complete call chain of each API call automatically enters LangSmith - including prompt injection, model response, tool call results, retrieval fragments and other intermediate steps. This is crucial for troubleshooting abnormal Agent behavior in production environments (such as tool call parameter errors, inaccurate retrieval and recall, and model phantom output).

FastAPI ecological compatibility: LangServe does not replace FastAPI, but makes a decorator-like enhancement on top of FastAPI. This means that developers can mix and deploy LangServe-managed AI endpoints and handwritten business endpoints in the same server instance, reusing all of FastAPI’s middleware, dependency injection, authentication mechanisms, and deployment tools. Enterprise teams can incorporate LangServe endpoints into existing API gateways and monitoring systems (such as Kong, APISIX, Datadog APM) without building separate infrastructure for AI services.

How to use

The relevant information has not been made public, please refer to the official real-time page.

Product Pricing

Open Source Framework (Zero Cost):

LangServe is licensed under the MIT license and is completely free. There are no licensing fees per se, and there is no commercial tier that charges per call or concurrency. The developer's entire cost comes from: ① the cost of the cloud infrastructure to run the service; ② the API fee of the underlying LLM called; ③ if LangSmith tracking is required, it is billed according to LangSmith pricing.

LangSmith Tracking Fee (optional):

LangSmith provides the observability backend for LangServe, with pricing tiered as follows:

Tier Price Quota Applicable scenarios
Free $0 3,000 traces/month, 1 project Personal development and debugging
Plus $39/month/user Unlimited traces, multiple projects, advanced evaluation Development Team
Enterprise Contact Business Includes SSO, audit logs, privatized deployment Large Enterprise

Operation and maintenance cost reference (self-hosted):

  • Low Traffic Prototype (average 1,000 calls per day): $5-15/month (minimal configuration of AWS Lambda + API Gateway or Cloud Run)
  • Medium traffic production (average 100,000 calls per day): $100-500/month (2-4 t3.medium instances + load balancing)
  • High traffic production (average daily 1 million + calls): $1,000-5,000/month (automatic scaling cluster + Redis cache + CDN)

Hidden Cost Tip: LangServe itself introduces almost no additional latency (the framework overhead for a single call is about 1-5ms), but the call latency of the LLM API is the main bottleneck. If the chain contains multiple serial LLM calls (such as Agent's multi-step reasoning), the end-to-end latency may be 3-10 times higher than a single API call. It is recommended to set the delay alarm threshold in LangSmith to P95 < 10 seconds, and troubleshoot the serial bottleneck of the chain when it exceeds.

Application scenarios

1. Internal RAG Q&A system backend

After the enterprise's internal knowledge base (product documentation, compliance documents, technical manuals) is processed through the LangChain RAG chain, it is exposed as an internal API through LangServe. Front-end applications (Slack Bot, Web portal, enterprise WeChat integration) obtain Q&A results through standard HTTP calls. Acceptance Indicators: API response time P95 < 5 seconds (including LLM inference and retrieval), retrieval accuracy > 90%, streaming output first token within 500ms. LangServe's automatic Schema validation ensures that all clients pass in the correct query format in this scenario.

2. Multi-model A/B testing API gateway

The product team mounted multiple Runnables on the same LangServe server - using GPT-4o, Claude 4, and Gemini 3 to process the same input, exposed through different /path endpoints. Use LangSmith's unified Trace capability to compare the delayed token consumption and output quality of each model. Implementation Tip: LangServe's per_req_config_modifier can be used to dynamically switch model parameters (such as temperature preferences of different users) in each request, without the need to deploy a separate endpoint for each configuration.

3. External triggering interface of Agent workflow

Automated agents built based on LangGraph (such as competitive product research agents and code review agents) expose trigger endpoints through LangServe. The external system (such as CI/CD pipeline, scheduled task scheduler) sends the task description to the /invoke endpoint, and the Agent starts execution and writes the results to the specified storage. Not suitable for the boundary: If the Agent runs for more than 10 minutes or requires multiple rounds of interaction with the user, LangServe's synchronous request/response model is no longer applicable - the asynchronous deployment and WebSocket communication capabilities of LangGraph Platform should be used at this time.

4. Real-time content generation service

The marketing team deployed the content generation chain (brand tone + product information + length constraints) built by LCEL as the LangServe API. The operating system calls the /batch endpoint in batches to generate social media copy, email templates and advertising slogans. LangServe's concurrent batch processing capability compresses the generation time of 100 pieces of copy from 5 minutes serially to 30 seconds in parallel. Acceptance concerns: Balance between batch size and number of concurrencies - too much concurrency may cause LLM API rate limit (Rate Limit) or OOM.

5. Cross-team AI competency center

The platform engineering team encapsulates the commonly used AI capabilities within the company (text summarization, sentiment analysis, entity extraction, content review) into independent LangServe modules and registers them uniformly to the API gateway. Each business team does not need to connect to the LLM API by itself and consume AI capabilities through the standard HTTP interface. This model centralizes the management and frequency control of LLM API Key from the decentralized management of each team to the platform team, reducing the risk of API Key leakage and the difficulty of compliance audits.

Applicable people

  • AI application developers (Python): the core user group. LangServe reduces the deployment cost of LCEL pipelines to nearly zero - define a Runnable, one line of add_routes, and you have a production-grade API. Prerequisite: Familiar with LangChain’s Runnable interface and LCEL basic syntax. For developers already using LangChain, LangServe is a natural deployment choice, but be aware that new projects are moving to the LangGraph Platform.

  • Backend Architects & DevOps Engineers: LangServe’s FastAPI compatibility allows it to fit seamlessly into existing backend infrastructure. Architects can regard it as an "AI adaptation layer" - it encapsulates LangChain's complex operating logic into a standard REST interface, and the back-end team can connect to AI capabilities without understanding concepts such as Token, Prompt, and Chain. When deploying, you need to pay attention to the state management limitations of LangServe: it is stateless by default, and you need to handle session consistency by yourself when deploying multiple copies.

  • AI Product Manager and Demo Producer: The Playground interface provided by LangServe is an ideal tool for demonstrating AI capabilities. The product manager directly tests different input parameters of the chain on the https://<server>/playground/ page without command line operations. The shared link function of Playground allows PMs to share links of specific configurations to stakeholder reviews to speed up product verification.

  • Education and Training Scenario: In the AI ​​course, the instructor deploys a LangServe server as the teaching backend. Students call the API through a browser or a simple Python script and focus on learning Prompt engineering and chain logic without being troubled by the deployment context.

  • Not suitable for the crowd: ① Teams that are starting new AI projects - should use LangGraph Platform instead of LangServe directly; ② Scenarios that require the deployment of complex Agents built by LangGraph (with Checkpoint, Human-in-the-loop, persistent memory) - LangServe cannot fully support these features; ③ Minimalist calling scenarios with strict requirements on minimum latency (< 50ms) - Directly calling the LLM SDK has lower latency and fewer dependencies; ④ Teams lacking Python operation and maintenance capabilities - Self-hosted LangServe requires basic Docker and server management skills, otherwise it is recommended to use a fully managed solution.

Summary and Outlook

LangChain API (LangServe), as the official deployment component of the LangChain ecosystem from 2023 to 2025, successfully solved the clear engineering pain point of "quickly exposing the LangChain chain as a REST API". Its automatic Schema inference, full-link streaming support and LangSmith native integration define the engineering paradigm of "LLM application API deployment". 2.3K+ GitHub Stars, 65 releases, and millions of PyPI downloads prove its real value among the developer community.

Current Limitations and Uncertainties:

  • LangServe has been officially deprecated (2024-11-18) and the GitHub repository has been archived in May 2026. Although the MIT license allows indefinite use, there are no longer new features and security updates.
  • Deployment support for LangGraph's complex Agents (recurrence, persistence, multi-Agent collaboration) is incomplete, and the design scope of LangServe is limited to simple Runnable and Chain.
  • There is no built-in authentication and authorization mechanism, and developers need to implement it on the FastAPI layer or reverse proxy layer.
  • The security of the Playground endpoint had a vulnerability (CVE) in early versions. Although it has been fixed in subsequent versions, it exposed the security boundary issue of the debugging interface that is turned on by default.
  • The performance of streaming endpoints may cause back pressure problems in large concurrency scenarios (>100 concurrent connections), and the appropriate number of Workers and connection pool size need to be configured.

Procurement and Adoption Risk Assessment:

  • Existing project: If the existing system is already running stably based on LangServe, it is recommended to maintain the current version and perform security monitoring on the periphery (especially reverse proxy configuration and dependency scanning), and plan a migration window within 6-12 months.
  • New project selection: directly use LangGraph Platform as the deployment solution. LangServe's interface design (invoke/batch/stream endpoint specification) is inherited in the new platform, and the migration cost is mainly reflected in runtime replacement rather than interface reconstruction.
  • Key terms that need to be verified before enterprise purchase: ① LangGraph Platform's private deployment pricing and data residency plan; ② LangSmith's data usage policy - confirm that AI tracking data will not be used for model secondary training; ③ Whether the migration tools and support services from LangServe to LangGraph Platform are included in the enterprise contract. It is recommended that the above verification items be subject to the latest official contract terms.

How to use LangChain API

Quick Start: Deploy a simple LLM chain

The following code shows the core usage of LangServe - about 20 lines of code deploying a chat model and a "joke telling" chain as a REST API:

# server.py
from fastapi import FastAPI
from langchain.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from langserve import add_routes

app = FastAPI(title="LangChain API Server", version="1.0")

# Directly expose the chat model
add_routes(app, ChatOpenAI(model="gpt-4o"), path="/chat")

# Expose a chain: prompt word + model
model = ChatOpenAI(model="gpt-4o", temperature=0.7)
prompt = ChatPromptTemplate.from_template("Tell a joke about {topic}")
add_routes(app, prompt | model, path="/joke")

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

Start command:

pip install "langserve[all]" langchain-openai
export OPENAI_API_KEY="sk-..."
python server.py

Call using client SDK

# client.py
from langserve import RemoteRunnable

joke_api = RemoteRunnable("http://localhost:8000/joke/")
result = joke_api.invoke({"topic": "Programmer"})
print(result)

Or via standard HTTP request:

curl -X POST http://localhost:8000/joke/invoke \
  -H "Content-Type: application/json" \
  -d '{"input": {"topic": "Programmer"}}'

Description of key configuration parameters

  • add_routes(app, runnable, path="/my_chain"): Mount a Runnable to the specified path and automatically generate all standard endpoints.
  • enabled_endpoints=["invoke", "batch", "stream"]: Limit exposure to only specified endpoints, reducing the attack surface.
  • disabled_endpoints=["playground"]: Disable the Playground debugging interface in production environment.
  • per_req_config_modifier: Inject user authentication information in each request (such as passing the user ID in the JWT to the Runnable's configuration).
  • playground_type="chat": Enable chat-specific Playground UI for chat type Runnable.

LangSmith trace configuration (optional)

export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=<your_langsmith_api_key>
export LANGCHAIN_PROJECT=my-langserve-app

Deploy to production environment

LangServe supports any FastAPI-compatible deployment method:

Deployment methods Commands/Tools Applicable scenarios
Local Docker docker build -t langserve-app . && docker run -p 8000:8000 langserve-app Development testing
AWS ECS / Copilot copilot init --app my-app --name langserve --type 'Load Balanced Web Service' AWS Cloud Native Deployment
Azure Container Apps az containerapp up --name langserve-app --source . Azure cloud native deployment
GCP Cloud Run gcloud run deploy langserve-app --source . --port 8001 GCP Serverless Deployment
Railway One-click deployment of Railway templates Rapid prototype launch

Version Info

  • LangServe v0.3.3 :Fully supports Pydantic V2, fixes OpenAPI document generation compatibility issues, and updates security dependencies. This version is the final official release version of LangServe.
  • LangServe v0.3.0 :Pydantic V2 is officially supported, a deprecation statement is released (2024-11-18, #791), and new projects are recommended to migrate to LangGraph Platform.
  • LangServe v0.2.0 :A new /stream_events endpoint is added to improve the streaming event model, allowing developers to obtain intermediate step events without parsing /stream_log output.
  • LangServe v0.0.16 :Fix the arbitrary file reading security vulnerability (CVE) of the Playground endpoint and enhance input validation.
  • LangServe initial release :The initial version is released, supporting the deployment of LangChain Runnable as a FastAPI service, providing /invoke, /batch, /stream endpoints. There is no official precise date yet.

User Reviews

  • Loading reviews...