API Reference
/
API Reference

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-context header (set by middleware)
  • Hono.js: langgraph_context variable (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 - Success
  • 201 - Created
  • 400 - Bad Request (validation error)
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 409 - Conflict
  • 422 - Unprocessable Entity
  • 500 - 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 ID
  • metadata (object, optional) - Filter by metadata key-value pairs
  • limit (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_at
  • sort_order (string, optional) - Sort order: asc, desc

Response:

Example:

GET /assistants/

Retrieve detailed information about a specific assistant.

Parameters:

  • assistantId (string, required) - The assistant ID
  • xray (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 metadata
  • thread_id (string, optional) - Custom thread ID (auto-generated if not provided)
  • if_exists (string, optional) - Behavior if thread_id exists: create, reject
  • graph_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 pairs
  • limit (number, optional) - Maximum results (default: 10)
  • offset (number, optional) - Pagination offset (default: 0)
  • status (string, optional) - Filter by status: idle, busy, error, stopped
  • sort_by (string, optional) - Sort field: thread_id, status, created_at, updated_at
  • sort_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 ID
  • limit (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 ID
  • runId (string, required) - The run ID to cancel
  • wait (boolean, optional) - Wait for cancellation to complete
  • action (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 ID
  • runId (string, required) - The run ID
  • signal (AbortSignal, optional) - Cancellation signal
  • cancelOnDisconnect (boolean, optional) - Cancel run on client disconnect
  • lastEventId (string, optional) - Resume from specific event ID
  • streamMode (string|string[], optional) - Override stream mode

Response: Server-Sent Events stream

Event Types:

  • messages - New messages from the graph
  • values - State value updates
  • events - General graph events
  • error - Error events
  • end - Stream completion

Example:

Stream Event Format:

Streaming Configuration

Stream Modes

Control what data is streamed during execution:

  • messages - Stream message updates
  • values - Stream state value changes
  • events - Stream all graph events
  • debug - 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
Built with

Show your support! Star us on GitHub ⭐️