Alpha Notice: These docs cover the v1-alpha release. Content is incomplete and subject to change.For the latest stable version, see the current LangGraph Python or LangGraph JavaScript docs.

Overview

A LangGraph application consists of one or more graphs, a configuration file (langgraph.json), a file that specifies dependencies, and an optional .env file that specifies environment variables. This guide shows a typical structure of an application and shows how the required information to deploy an application using the LangGraph Platform is specified.

Key Concepts

To deploy using the LangGraph Platform, the following information should be provided:
  1. A LangGraph configuration file (langgraph.json) that specifies the dependencies, graphs, and environment variables to use for the application.
  2. The graphs that implement the logic of the application.
  3. A file that specifies dependencies required to run the application.
  4. Environment variables that are required for the application to run.

File Structure

Below are examples of directory structures for applications:
my-app/
├── src # all project code lies within here
│   ├── utils # optional utilities for your graph
│   │   ├── tools.ts # tools for your graph
│   │   ├── nodes.ts # node functions for your graph
│   │   └── state.ts # state definition of your graph
│   └── agent.ts # code for constructing your graph
├── package.json # package dependencies
├── .env # environment variables
└── langgraph.json # configuration file for LangGraph
The directory structure of a LangGraph application can vary depending on the programming language and the package manager used.

Configuration File

The langgraph.json file is a JSON file that specifies the dependencies, graphs, environment variables, and other settings required to deploy a LangGraph application. See the LangGraph configuration file reference for details on all supported keys in the JSON file.
The LangGraph CLI defaults to using the configuration file langgraph.json in the current directory.

Examples

  • The dependencies will be loaded from a dependency file in the local directory (e.g., package.json).
  • A single graph will be loaded from the file ./your_package/your_file.js with the function agent.
  • The environment variable OPENAI_API_KEY is set inline.
{
  "dependencies": ["."],
  "graphs": {
    "my_agent": "./your_package/your_file.js:agent"
  },
  "env": {
    "OPENAI_API_KEY": "secret-key"
  }
}

Dependencies

A LangGraph application may depend on other TypeScript/JavaScript libraries. You will generally need to specify the following information for dependencies to be set up correctly:
  1. A file in the directory that specifies the dependencies (e.g. package.json).
  2. A dependencies key in the LangGraph configuration file that specifies the dependencies required to run the LangGraph application.
  3. Any additional binaries or system libraries can be specified using dockerfile_lines key in the LangGraph configuration file.

Graphs

Use the graphs key in the LangGraph configuration file to specify which graphs will be available in the deployed LangGraph application. You can specify one or more graphs in the configuration file. Each graph is identified by a name (which should be unique) and a path for either: (1) the compiled graph or (2) a function that makes a graph is defined.

Environment Variables

If you’re working with a deployed LangGraph application locally, you can configure environment variables in the env key of the LangGraph configuration file. For a production deployment, you will typically want to configure the environment variables in the deployment environment.