Skip to main content

LangChain CLI Cheatsheet

The LangChain CLI ecosystem provides two tools: `langchain` for application scaffolding and LangServe deployment, and `langgraph` for agent workflow development. Both support template-based quick-start, REST API deployment, and Docker packaging for production.

Updated: 2026-07-20·24 commands

Quick Start

``bash # Install CLI pip install langchain-cli

# Create a new app langchain app new my-app

# Add a RAG template langchain app add rag-chroma

# Create environment file with API keys echo 'OPENAI_API_KEY=sk-xxx' > .env

# Start LangServe langchain serve --port 8000

# Visit the docs open http://localhost:8000/docs `

LangGraph

For agent workflows, install and use LangGraph separately:

`bash pip install langgraph

# Start dev server langgraph dev

# Build for production langgraph build -t my-agent:v1

# Deploy with Docker Compose langgraph up `

Templates

Templates provide pre-built architectures: RAG, conversational retrieval, SQL agents, document analysis, and more. Browse and add them via the CLI.

LangServe

LangServe wraps LangChain chains as REST APIs automatically. Each template has its own endpoint at /chain-name, plus a Playground UI at /chain-name/playground` for interactive testing.

LangSmith

Observability and debugging platform. Enable tracing via environment variables to log all LLM calls, chains, and agent steps for inspection and evaluation.

Startup & Modes(16)

CommandLevel
langchain --help
Show LangChain CLI help
Basic
langchain app new
Create a new LangChain application
Basic
langchain app new --package
Create app from a template package
Intermediate
langchain app add
Add a package (template) to existing app
Intermediate
pip install langchain-cli
Install LangChain CLI
Basic
pip install langchain
Install LangChain core library
Basic
pip install langchain-community
Install LangChain community integrations
Basic
pip install langgraph
Install LangGraph framework
Intermediate
langgraph build
Build LangGraph app for deployment
Intermediate
langgraph build -t
Specify Docker image tag
Intermediate
langgraph test
Run LangGraph tests
Intermediate
langchain template list
List all available template packages
Basic
pip install langchain-postgres
Install LangChain PostgreSQL integration
Intermediate
pip install langchain-chroma
Install LangChain Chroma integration
Intermediate
export LANGCHAIN_API_KEY
Set LangSmith API key
Basic
export LANGCHAIN_TRACING_V2=true
Enable LangSmith tracing
Intermediate

ai-server(8)

CommandLevel
langchain serve
Start LangServe REST API server
Intermediate
langchain serve --port
Specify server port
Basic
langchain serve --host
Specify bind host address
Basic
langgraph dev
Start LangGraph development server
Intermediate
langgraph up
Start LangGraph app with Docker Compose
Intermediate
npx @langchain/langgraph-cli dev
Start LangGraph dev server via npx
Intermediate
curl http://localhost:8000/docs
Access LangServe API documentation
Basic
curl http://localhost:8000/rag/playground
Access LangServe Playground UI
Basic

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-20.