Serve any LangGraph graph over the OpenAI Chat Completions + Responses APIs.
Project description
GraphServe
GraphServe is an open-source Python library that serves any LangGraph graph over the OpenAI Chat Completions and Responses APIs, enabling seamless integration of agent workflows into OpenAI-compatible applications.
Installation
pip install graphserve
Quickstart
from fastapi import FastAPI
from langgraph.graph import StateGraph, START, END
from graphserve import GraphRegistry, GraphConfig, create_openai_router
# 1. Build your LangGraph graph
graph = StateGraph(...)
# ... add nodes and edges ...
compiled = graph.compile()
# 2. Register it under a model name
registry = GraphRegistry()
registry.register("my-agent", GraphConfig(graph=compiled))
# 3. Mount the OpenAI-compatible router on your FastAPI app
app = FastAPI()
app.include_router(create_openai_router(registry), prefix="/v1")
Your app now exposes:
| Route | Description |
|---|---|
GET /v1/models |
List registered graphs |
POST /v1/responses |
Create a response (streaming or non-streaming) |
GET /v1/responses/{id} |
Retrieve a previous response |
DELETE /v1/responses/{id} |
Delete a response |
POST /v1/chat/completions |
Chat Completions API |
Public API
| Export | Description |
|---|---|
GraphRegistry |
Registry mapping model names to graph configs |
GraphConfig |
Holds a single already-compiled graph to serve (graph-only) |
create_openai_router |
Builds a FastAPI APIRouter with all OpenAI-compatible routes |
ConversationStore |
Protocol for plugging in a custom conversation metadata backend |
create_openai_router options
create_openai_router(
registry, # GraphRegistry — required
store=None, # ConversationStore — defaults to InMemoryConversationStore
)
GraphServe is a pure bind layer. Cross-cutting concerns are the consumer's job, applied with standard tools:
- Auth — apply it where you mount the router:
app.include_router(create_openai_router(registry), prefix="/v1", dependencies=[Depends(verify_api_key)])
- Callbacks / tracing — attach to your graph when you build it.
Per-request runtime context is derived generically from the OpenAI request and
exposed to the graph as LangGraph runtime context: user → context["user_id"],
instructions → context["metadata"]["custom_instructions"], and metadata is
passed through as context["metadata"]. Graphs read what they need and ignore the rest.
Stateful GET /
previous_response_idcontinuity requires the registered graph to be compiled with a LangGraph checkpointer — this is the consumer's responsibility (e.g.graph.compile(checkpointer=MemorySaver())). GraphServe reads thread state viagraph.aget_state(...)at GET time.
Streaming
Pass "stream": true in the request body to receive Server-Sent Events following the OpenAI Responses API event schema (response.created, response.output_item.added, response.output_text.delta, response.completed, etc.).
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file graphserve-0.1.0.tar.gz.
File metadata
- Download URL: graphserve-0.1.0.tar.gz
- Upload date:
- Size: 126.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aa7d7a62eaf9522726d2a67bd501522202202a954ce86a046db21ef6fa9a0af
|
|
| MD5 |
074446ab3ae714640ceb5f050e9d8bc0
|
|
| BLAKE2b-256 |
8fb2ade378057002889b3f9c59c97990803a441c5ad9204106a08669bdf61a78
|
File details
Details for the file graphserve-0.1.0-py3-none-any.whl.
File metadata
- Download URL: graphserve-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5507e4c4c425d1159605fc3333d1113678bdd447d2f91f410852d779c487efee
|
|
| MD5 |
b359d1204c9048339583fe547d86b46a
|
|
| BLAKE2b-256 |
79e3e3166e1f999bf682732f520206d78254fb0cb640a629e0a37e277a02d50d
|