[docs] LangGraph / LangGraph Platform docs updates (#4479)

Main changes made:
- Add top level horizontal tabs
- Reorganize the sidenav
- Build out README/index page
- Consolidate how-tos under each section
- Remove duplicate content

---------

Signed-off-by: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com>
Co-authored-by: Tat Dat Duong <david@duong.cz>
Co-authored-by: Sydney Runkle <sydneymarierunkle@gmail.com>
Co-authored-by: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com>
Co-authored-by: Vadym Barda <vadym@langchain.dev>
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Co-authored-by: ccurme <chester.curme@gmail.com>
Co-authored-by: Andrew Nguonly <andrewnguonly@users.noreply.github.com>
Co-authored-by: David Asamu <david.asamu@langchain.dev>
Co-authored-by: infra <mukil@langchain.dev>
Co-authored-by: Arjun Natarajan <arjun@langchain.dev>
This commit is contained in:
Lauren Hirata Singh
2025-05-09 16:09:43 -04:00
committed by GitHub
co-authored by Tat Dat Duong Sydney Runkle William Fu-Hinthorn Vadym Barda Eugene Yurtsev ccurme Andrew Nguonly David Asamu infra Arjun Natarajan
parent 909a4591a8
commit 3055c4b9cc
239 changed files with 14663 additions and 27446 deletions
@@ -1,19 +1,28 @@
# Quickstart: Launch Local LangGraph Server
# LangGraph Platform quickstart
This is a quick start guide to help you get a LangGraph app up and running locally.
This guide shows you how to run a LangGraph application locally.
!!! info "Requirements"
## Prerequisites
- Python >= 3.11
- [LangGraph CLI](https://langchain-ai.github.io/langgraph/cloud/reference/cli/): Requires langchain-cli[inmem] >= 0.1.58
Before you begin, ensure you have the following:
## Install the LangGraph CLI
- An API key for [LangSmith](https://smith.langchain.com/settings) - free to sign up
This quickstart uses the `react-agent` template and requires the following:
- An API key for [Anthropic](https://console.anthropic.com/)
- An API key for [OpenAI](https://openai.com/)
- An API key [Tavily](https://app.tavily.com/)
## 1. Install the LangGraph CLI
```bash
# Python >= 3.11 is required.
pip install --upgrade "langgraph-cli[inmem]"
```
## 🌱 Create a LangGraph App
## 2. Create a LangGraph app 🌱
Create a new app from the `react-agent` template. This template is a simple agent that can be flexibly extended to many tools.
@@ -29,22 +38,31 @@ Create a new app from the `react-agent` template. This template is a simple agen
langgraph new path/to/your/app --template react-agent-js
```
!!! tip "Additional Templates"
!!! tip "Additional templates"
If you use `langgraph new` without specifying a template, you will be presented with an interactive menu that will allow you to choose from a list of available templates.
## Install Dependencies
## 3. Install dependencies
In the root of your new LangGraph app, install the dependencies in `edit` mode so your local changes are used by the server:
```shell
pip install -e .
```
=== "Python server"
## Create a `.env` file
```shell
cd path/to/your/app
pip install -e .
```
You will find a `.env.example` in the root of your new LangGraph app. Create
a `.env` file in the root of your new LangGraph app and copy the contents of the `.env.example` file into it, filling in the necessary API keys:
=== "Node server"
```shell
cd path/to/your/app
yarn install
```
## 4. Create a `.env` file
You will find a `.env.example` in the root of your new LangGraph app. Create a `.env` file in the root of your new LangGraph app and copy the contents of the `.env.example` file into it, filling in the necessary API keys:
```bash
LANGSMITH_API_KEY=lsv2...
@@ -53,21 +71,25 @@ ANTHROPIC_API_KEY=sk-
OPENAI_API_KEY=sk-...
```
??? note "Get API Keys"
## 5. Launch LangGraph Server 🚀
- **LANGSMITH_API_KEY**: Go to the [LangSmith Settings page](https://smith.langchain.com/settings). Then clck **Create API Key**.
- **ANTHROPIC_API_KEY**: Get an API key from [Anthropic](https://console.anthropic.com/).
- **OPENAI_API_KEY**: Get an API key from [OpenAI](https://openai.com/).
- **TAVILY_API_KEY**: Get an API key on the [Tavily website](https://app.tavily.com/).
Start the LangGraph API server locally:
## 🚀 Launch LangGraph Server
=== "Python Server"
```shell
langgraph dev
```
=== "Node Server"
```shell
npx @langchain/langgraph-cli dev
```
Sample output:
```shell
langgraph dev
```
This will start up the LangGraph API server locally. If this runs successfully, you should see something like:
> Ready!
>
> - API: [http://localhost:2024](http://localhost:2024/)
@@ -75,133 +97,130 @@ This will start up the LangGraph API server locally. If this runs successfully,
> - Docs: http://localhost:2024/docs
>
> - LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
```
The `langgraph dev` command starts LangGraph Server in an in-memory mode. This mode is suitable for development and testing purposes. For production use, deploy LangGraph Server with access to a persistent storage backend. For more information, see [Deployment options](../../concepts/deployment_options.md).
!!! note "In-Memory Mode"
## 6. Test your application in LangGraph Studio
The `langgraph dev` command starts LangGraph Server in an in-memory mode. This mode is suitable for development and testing purposes. For production use, you should deploy LangGraph Server with access to a persistent storage backend.
If you want to test your application with a persistent storage backend, you can use the `langgraph up` command instead of `langgraph dev`. You will
need to have `docker` installed on your machine to use this command.
## LangGraph Studio Web UI
LangGraph Studio Web is a specialized UI that you can connect to LangGraph API server to enable visualization, interaction, and debugging of your application locally. Test your graph in the LangGraph Studio Web UI by visiting the URL provided in the output of the `langgraph dev` command.
[LangGraph Studio](../../concepts/langgraph_studio.md) is a specialized UI that you can connect to LangGraph API server to visualize, interact with, and debug your application locally. Test your graph in LangGraph Studio by visiting the URL provided in the output of the `langgraph dev` command:
```
> - LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
```
!!! info "Connecting to a server with a custom host/port"
For a LangGraph Server running on a custom host/port, update the baseURL parameter.
If you are running the LangGraph API server with a custom host / port, you can point the Studio Web UI at it by changing the `baseUrl` URL param. For example, if you are running your server on port 8000, you can change the above URL to the following:
```
https://smith.langchain.com/studio/baseUrl=http://127.0.0.1:8000
```
!!! warning "Safari Compatibility"
??? info "Safari compatibility"
Use the `--tunnel` flag with your command to create a secure tunnel, as Safari has limitations when connecting to localhost servers:
Currently, LangGraph Studio Web does not support Safari when running a server locally.
## Test the API
=== "Python SDK (Async)"
**Install the LangGraph Python SDK**
```shell
pip install langgraph-sdk
langgraph dev --tunnel
```
**Send a message to the assistant (threadless run)**
## 7. Test the API
```python
from langgraph_sdk import get_client
=== "Python SDK (async)"
client = get_client(url="http://localhost:2024")
1. Install the LangGraph Python SDK:
async for chunk in client.runs.stream(
None, # Threadless run
"agent", # Name of assistant. Defined in langgraph.json.
input={
"messages": [{
"role": "human",
"content": "What is LangGraph?",
}],
},
stream_mode="updates",
):
print(f"Receiving new event of type: {chunk.event}...")
print(chunk.data)
print("\n\n")
```
```shell
pip install langgraph-sdk
```
=== "Python SDK (Sync)"
1. Send a message to the assistant (threadless run):
**Install the LangGraph Python SDK**
```python
from langgraph_sdk import get_client
import asyncio
```shell
pip install langgraph-sdk
```
client = get_client(url="http://localhost:2024")
**Send a message to the assistant (threadless run)**
async def main():
async for chunk in client.runs.stream(
None, # Threadless run
"agent", # Name of assistant. Defined in langgraph.json.
input={
"messages": [{
"role": "human",
"content": "What is LangGraph?",
}],
},
):
print(f"Receiving new event of type: {chunk.event}...")
print(chunk.data)
print("\n\n")
```python
from langgraph_sdk import get_sync_client
asyncio.run(main())
```
client = get_sync_client(url="http://localhost:2024")
=== "Python SDK (sync)"
for chunk in client.runs.stream(
None, # Threadless run
"agent", # Name of assistant. Defined in langgraph.json.
input={
"messages": [{
"role": "human",
"content": "What is LangGraph?",
}],
},
stream_mode="updates",
):
print(f"Receiving new event of type: {chunk.event}...")
print(chunk.data)
print("\n\n")
```
1. Install the LangGraph Python SDK:
```shell
pip install langgraph-sdk
```
1. Send a message to the assistant (threadless run):
```python
from langgraph_sdk import get_sync_client
client = get_sync_client(url="http://localhost:2024")
for chunk in client.runs.stream(
None, # Threadless run
"agent", # Name of assistant. Defined in langgraph.json.
input={
"messages": [{
"role": "human",
"content": "What is LangGraph?",
}],
},
stream_mode="messages-tuple",
):
print(f"Receiving new event of type: {chunk.event}...")
print(chunk.data)
print("\n\n")
```
=== "Javascript SDK"
**Install the LangGraph JS SDK**
1. Install the LangGraph JS SDK:
```shell
npm install @langchain/langgraph-sdk
```
```shell
npm install @langchain/langgraph-sdk
```
**Send a message to the assistant (threadless run)**
1. Send a message to the assistant (threadless run):
```js
const { Client } = await import("@langchain/langgraph-sdk");
```js
const { Client } = await import("@langchain/langgraph-sdk");
// only set the apiUrl if you changed the default port when calling langgraph dev
const client = new Client({ apiUrl: "http://localhost:2024"});
// only set the apiUrl if you changed the default port when calling langgraph dev
const client = new Client({ apiUrl: "http://localhost:2024"});
const streamResponse = client.runs.stream(
null, // Threadless run
"agent", // Assistant ID
{
input: {
"messages": [
{ "role": "user", "content": "What is LangGraph?"}
]
},
streamMode: "messages",
const streamResponse = client.runs.stream(
null, // Threadless run
"agent", // Assistant ID
{
input: {
"messages": [
{ "role": "user", "content": "What is LangGraph?"}
]
},
streamMode: "messages-tuple",
}
);
for await (const chunk of streamResponse) {
console.log(`Receiving new event of type: ${chunk.event}...`);
console.log(JSON.stringify(chunk.data));
console.log("\n\n");
}
);
for await (const chunk of streamResponse) {
console.log(`Receiving new event of type: ${chunk.event}...`);
console.log(JSON.stringify(chunk.data));
console.log("\n\n");
}
```
```
=== "Rest API"
@@ -219,35 +238,16 @@ LangGraph Studio Web is a specialized UI that you can connect to LangGraph API s
}
]
},
\"stream_mode\": \"updates\"
\"stream_mode\": \"messages-tuple\"
}"
```
!!! tip "Auth"
If you're connecting to a remote server, you will need to provide a LangSmith
API Key for authorization. Please see the API Reference for the clients
for more information.
## Next Steps
Now that you have a LangGraph app running locally, take your journey further by exploring deployment and advanced features:
### 🌐 Deploy to LangGraph Cloud
- **[LangGraph Cloud Quickstart](../../cloud/quick_start.md)**: Deploy your LangGraph app using LangGraph Cloud.
### 📚 Learn More about LangGraph Platform
Expand your knowledge with these resources:
- **[LangGraph Platform Concepts](../../concepts/index.md#langgraph-platform)**: Understand the foundational concepts of the LangGraph Platform.
- **[LangGraph Platform How-to Guides](../../how-tos/index.md#langgraph-platform)**: Discover step-by-step guides to build and deploy applications.
### 🛠️ Developer References
Access detailed documentation for development and API usage:
- **[LangGraph Server API Reference](../../cloud/reference/api/api_ref.html)**: Explore the LangGraph Server API documentation.
- **[Python SDK Reference](../../cloud/reference/sdk/python_sdk_ref.md)**: Explore the Python SDK API Reference.
- **[JS/TS SDK Reference](../../cloud/reference/sdk/js_ts_sdk_ref.md)**: Explore the JS/TS SDK API Reference.
- [Deployment quickstart](../../cloud/quick_start.md): Deploy your LangGraph app using LangGraph Platform.
- [LangGraph Platform overview](../../concepts/langgraph_platform.md): Learn about foundational LangGraph Platform concepts.
- [LangGraph Server API Reference](../../cloud/reference/api/api_ref.html): Explore the LangGraph Server API documentation.
- [Python SDK Reference](../../cloud/reference/sdk/python_sdk_ref.md): Explore the Python SDK API Reference.
- [JS/TS SDK Reference](../../cloud/reference/sdk/js_ts_sdk_ref.md): Explore the JS/TS SDK API Reference.