API Reference
Open LangGraph Server provides a comprehensive REST API that follows the LangGraph SDK specification. This reference covers all available endpoints, request/response formats, and usage examples.
Base URL
All API endpoints are relative to your configured base path:
- Next.js:
/api/langgraph/ - Hono.js:
/api/langgraph/(configurable)
Authentication
Open LangGraph Server relies on your framework's authentication mechanisms. Context can be injected via:
- Next.js:
x-langgraph-contextheader (set by middleware) - Hono.js:
langgraph_contextvariable (set by middleware)
Content Types
- Request:
application/json - Response:
application/json(except streaming endpoints)
Error Responses
All errors follow this format:
Common HTTP Status Codes
200- Success201- Created400- Bad Request (validation error)401- Unauthorized403- Forbidden404- Not Found409- Conflict422- Unprocessable Entity500- Internal Server Error
Assistants API
Manage and query available graph assistants.
GET /assistants
Search for assistants with optional filtering.
Parameters:
graph_id(string, optional) - Filter by graph IDmetadata(object, optional) - Filter by metadata key-value pairslimit(number, optional) - Maximum number of results (default: 10)offset(number, optional) - Pagination offset (default: 0)sort_by(string, optional) - Sort field:assistant_id,graph_id,name,created_at,updated_atsort_order(string, optional) - Sort order:asc,desc
Response:
Example:
GET /assistants/
Retrieve detailed information about a specific assistant.
Parameters:
assistantId(string, required) - The assistant IDxray(boolean or number, optional) - Include graph structure (true) or depth limit
Response:
Example:
Threads API
Manage conversation threads and their lifecycle.
POST /threads
Create a new conversation thread.
Request Body:
Parameters:
metadata(object, optional) - Thread metadatathread_id(string, optional) - Custom thread ID (auto-generated if not provided)if_exists(string, optional) - Behavior if thread_id exists:create,rejectgraph_id(string, optional) - Associate with specific graph
Response (201):
Example:
GET /threads
Search and list threads with filtering and pagination.
Parameters:
metadata(object, optional) - Filter by metadata key-value pairslimit(number, optional) - Maximum results (default: 10)offset(number, optional) - Pagination offset (default: 0)status(string, optional) - Filter by status:idle,busy,error,stoppedsort_by(string, optional) - Sort field:thread_id,status,created_at,updated_atsort_order(string, optional) - Sort order:asc,desc
Response:
Example:
GET /threads/
Retrieve detailed information about a specific thread.
Parameters:
threadId(string, required) - The thread ID
Response:
Example:
DELETE /threads/
Delete a thread and all associated data.
Parameters:
threadId(string, required) - The thread ID to delete
Response (200):
Example:
Runs API
Execute and manage graph runs within threads.
GET /threads//runs
List runs for a specific thread.
Parameters:
threadId(string, required) - The thread IDlimit(number, optional) - Maximum results (default: 10)offset(number, optional) - Pagination offset (default: 0)status(string, optional) - Filter by run status
Response:
Example:
POST /threads//runs
Create and execute a new run.
Parameters:
threadId(string, required) - The thread ID
Request Body:
Response (201):
Example:
DELETE /threads//runs/
Cancel a running execution.
Parameters:
threadId(string, required) - The thread IDrunId(string, required) - The run ID to cancelwait(boolean, optional) - Wait for cancellation to completeaction(string, optional) - Cancellation action:interrupt,rollback
Response (200):
Example:
GET /threads//runs//stream
Stream run results in real-time using Server-Sent Events.
Parameters:
threadId(string, required) - The thread IDrunId(string, required) - The run IDsignal(AbortSignal, optional) - Cancellation signalcancelOnDisconnect(boolean, optional) - Cancel run on client disconnectlastEventId(string, optional) - Resume from specific event IDstreamMode(string|string[], optional) - Override stream mode
Response: Server-Sent Events stream
Event Types:
messages- New messages from the graphvalues- State value updatesevents- General graph eventserror- Error eventsend- Stream completion
Example:
Stream Event Format:
Streaming Configuration
Stream Modes
Control what data is streamed during execution:
messages- Stream message updatesvalues- Stream state value changesevents- Stream all graph eventsdebug- Stream debug information
Example:
Stream Options
Additional streaming configuration:
Context and Configuration
Context Injection
Context data is injected via framework middleware and made available to graphs through getConfig().configurable.
Next.js Middleware Example:
Hono.js Middleware Example:
Run Configuration
Override default behavior per run:
Error Handling
Validation Errors
Invalid requests return detailed validation information:
Graph Execution Errors
Graph execution failures include error details:
Streaming Errors
Stream errors are sent as events:
Rate Limiting
Implement rate limiting at the framework level:
Next.js Example:
SDK Compatibility
Open LangGraph Server maintains compatibility with the LangGraph SDK, supporting all standard operations while adding framework-specific enhancements.
LangGraph SDK Features Supported
- ✅ Thread management
- ✅ Run execution and streaming
- ✅ Checkpoint persistence
- ✅ Assistant discovery
- ✅ Context passing
- ✅ Error handling
- ✅ Type safety
Additional Open LangGraph Server Features
- 🔧 Framework Integration - Native Next.js and Hono.js support
- 💾 Multiple Storage Backends - SQLite, PostgreSQL, Redis, Memory
- 📊 Message Queues - Redis-based streaming queues
- 🏷️ Context Injection - Framework-specific context passing
- 🎯 Type Validation - Runtime type checking with Zod
Show your support! Star us on GitHub ⭐️