This is a concise guide on setting up and running the LangGraph development server (langgraph dev) using uv as the package manager and runner.
- Python: Ensure you have Python 3.11+ installed.
- UV: Install
uv:curl -LsSf https://astral.sh/uv/install.sh | sh(or other methods from astral.sh/uv). .envfile: Have your necessary API keys (e.g.,OPENAI_API_KEY) in a.envfile in your project root.- LangGraph Agent: Have your LangGraph agent code (e.g., in
agent.py) defining a compiled graph (e.g.,graph).
-
langgraph.json: Create alanggraph.jsonfile in your project root. This file tells the LangGraph CLI where to find your graph(s).{ "dependencies": ["."], // Optional: If your agent has local dependencies "graphs": { "agent": "./agent.py:graph" // Path to your file and graph variable }, "env": ".env" // Points to your environment variables file }- Replace
"./agent.py:graph"with the actual path to your agent file and the variable name of your compiled graph.
- Replace
-
Install Dependencies: Use
uvto installlanggraph-cliwith the necessary extras for the dev server, along with any other project dependencies (e.g.,langchain-openai,python-dotenv).# Activate your virtual environment if you have one (optional but recommended) # uv venv # Install langgraph-cli and other dependencies uv pip install --upgrade "langgraph-cli[inmem]" langchain-openai python-dotenv # Add other dependencies here
- The
[inmem]extra is required forlanggraph dev.
- The
-
Start the Dev Server: Use
uv runto execute thelanggraph devcommand within the environment managed byuv. Navigate to your project root in the terminal and run:uv run langgraph dev
-
Output: You should see output indicating the server is running, including URLs for the API, docs, and the LangGraph Studio:
Ready! * API: http://localhost:2024 * Docs: http://localhost:2024/docs * LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
- Open the LangGraph Studio Web UI link in your browser (Note: Safari might have issues with local servers) to visualize, interact with, and debug your agent. The
baseUrlparameter connects the web UI to your locally running server.