Skip to content

Instantly share code, notes, and snippets.

@sanjeed5
Created April 3, 2025 10:30
Show Gist options
  • Select an option

  • Save sanjeed5/5c3f953d8bedcc6e032dfafeca1a8f13 to your computer and use it in GitHub Desktop.

Select an option

Save sanjeed5/5c3f953d8bedcc6e032dfafeca1a8f13 to your computer and use it in GitHub Desktop.
This is a concise guide on setting up and running the LangGraph development server (`langgraph dev`) using `uv` as the package manager and runner.

Running LangGraph Dev with UV

This is a concise guide on setting up and running the LangGraph development server (langgraph dev) using uv as the package manager and runner.

Prerequisites

  1. Python: Ensure you have Python 3.11+ installed.
  2. UV: Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh (or other methods from astral.sh/uv).
  3. .env file: Have your necessary API keys (e.g., OPENAI_API_KEY) in a .env file in your project root.
  4. LangGraph Agent: Have your LangGraph agent code (e.g., in agent.py) defining a compiled graph (e.g., graph).

Setup

  1. langgraph.json: Create a langgraph.json file 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.
  2. Install Dependencies: Use uv to install langgraph-cli with 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 for langgraph dev.

Running the Server

  1. Start the Dev Server: Use uv run to execute the langgraph dev command within the environment managed by uv. Navigate to your project root in the terminal and run:

    uv run langgraph dev
  2. 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
    

Accessing LangGraph Studio

  • 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 baseUrl parameter connects the web UI to your locally running server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment