LangGraph Module 9: Local Server, Studio, and Deployment
Introduction
Scripts are fine for learning, but real applications need a server with an API, persistence, and good debugging tools. The LangGraph CLI provides a local development server and connects to Studio, a visual environment for running and inspecting graphs. This final module sets those up and discusses production options.
Prerequisites
- Python 3.11 or newer
- A free LangSmith account and API key
- A graph you want to serve
Step-by-Step Guide
Step 1: Install the CLI
The CLI requires Python 3.11 or newer. The inmem extra includes the in-memory server used for local development.
pip install -U "langgraph-cli[inmem]"Step 2: Create a project from a template
langgraph new scaffolds an application. Install the project in editable mode, then copy the example environment file to .env and add your LangSmith API key. Without a template option, the command shows an interactive menu.
langgraph new my-agent --template new-langgraph-project-python
cd my-agent
pip install -e .
# create .env from .env.example and set:
# LANGSMITH_API_KEY=your-langsmith-keyStep 3: Understand langgraph.json
A configuration file named langgraph.json tells the server which graphs to expose. The generated project includes one; a minimal version points a graph name at a variable holding your compiled graph. Check the application structure documentation for all options.
{
"dependencies": ["."],
"graphs": {
"agent": "./src/agent/graph.py:graph"
},
"env": ".env"
}Step 4: Start the dev server and open Studio
langgraph dev starts a local server and prints three addresses: the API at 127.0.0.1:2024, a link that opens Studio against your local server, and the interactive API documentation at /docs. In Studio you can run the graph, watch each step, inspect and edit state, and replay from earlier points. On Safari, add the --tunnel option. Under this server you compile without a checkpointer, because the server provides persistence.
langgraph devStep 5: Call the running graph and plan for production
Use the SDK (pip install langgraph-sdk) or plain HTTP to call the server, here with the synchronous client. The dev server is in-memory and meant for development only. For production, deploy the application with LangSmith Deployment or run the open-source server in your own infrastructure with a durable database, authentication, and monitoring.
from langgraph_sdk import get_sync_client
client = get_sync_client(url="http://localhost:2024")
for chunk in client.runs.stream(
None, # no thread: a stateless run
"agent",
input={"messages": [{"role": "human", "content": "What is 3 + 4?"}]},
stream_mode="messages-tuple",
):
print(chunk.event, chunk.data)FAQs
- Is the LangGraph dev server safe to expose publicly?
- No. It is an in-memory development tool. For anything public, use a production deployment with authentication, persistent storage, and monitoring.
- Do I need LangSmith to use LangGraph?
- LangGraph itself works without it. The local dev server and Studio workflow described here use a LangSmith API key, and tracing is a recommended, optional way to observe your runs.
Summary
Use the LangGraph CLI to scaffold a project, describe your graphs in langgraph.json, run langgraph dev to get an API and Studio, and move to a durable, authenticated deployment for production. That completes the course from first graph to deployable agent.
Comments
Log in or create a free account to join the discussion.