2.3 KiB
Quick Start
This quick start guide will cover how to develop an application for LangGraph Cloud, run it locally in Docker, and call the APIs to invoke a graph.
Alternatively, clone or fork the langgraph/example GitHub repository and follow the instructions in the README.
Develop
-
Create a new application with the following directory and files:
<my-app>/ |-- agent.py # code for your LangGraph agent |-- requirements.txt # Python packages required for your graph |-- langgraph.json # configuration file for LangGraph |-- .env # environment files with API keys -
The
agent.pyfile should contain the following Python code for defining a simple graph:from langchain_openai import ChatOpenAI from langgraph.graph import END, MessageGraph model = ChatOpenAI(temperature=0) graph_workflow = MessageGraph() graph_workflow.add_node("agent", model) graph_workflow.add_edge("agent", END) graph_workflow.set_entry_point("agent") graph = graph_workflow.compile() -
The
requirements.txtfile should contain the following dependencies:langgraph langchain_openai -
The
langgraph.jsonfile should contain the following JSON object:{ "dependencies": ["."], "graphs": { "agent": "./agent.py:graph" }, "env": ".env" }Learn more about the LangGraph CLI configuration file here.
-
The
.envfile should contain the environment variables:OPENAI_API_KEY=<add your key here> LANGGRAPH_AUTH_TYPE=noop!!! warning "Disable Authentication" When testing locally, set
LANGGRAPH_AUTH_TYPEtonoopto disable authentication.
Run Locally
-
Install the LangGraph CLI.
-
Run the following command to start the API server in Docker:
langgraph up -c langgraph.json -
The API server is now running at
http://localhost:8123. Navigate tohttp://localhost:8123/docsto view the API docs.
Deploy to Cloud
Follow these instructions to deploy to LangGraph Cloud.