LangGraph OpenAI Serve
Serve LangGraph graphs through an OpenAI-compatible /v1 API so existing
OpenAI SDKs, Chainlit, Open WebUI, and similar clients can call them without a
project-specific protocol.
Install
Use uv for project dependency management:
uv add langgraph-openai-serve
The equivalent pip command is:
pip install langgraph-openai-serve
The package contains the OpenAI-compatible server integration, not a built-in
LLM graph. Applications register their own graphs. The demo/ checkout keeps
each deployable application in an independent uv project with its own lockfile.
Its lgos-rag example indexes a small corpus packaged with the demo API, so the
entire directory can be copied and run without files from this repository.
Quick Demo
From this repository, prepare the demo environment and PostgreSQL:
cd demo
cp .env.example .env
docker compose -f compose.yaml up -d lgos-db
uv run --directory api --env-file ../.env \
--locked --with-editable ../.. lgos-demo-api-setup
uv run --directory api --env-file ../.env \
--locked --with-editable ../.. lgos-demo-api
Then call the demo with the OpenAI Python client:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="DUMMY")
response = client.chat.completions.create(
model="custom-input-output-context",
messages=[{"role": "user", "content": "Show me custom schemas."}],
user="demo-user",
)
print(response.choices[0].message.content)
Use curl http://localhost:8000/v1/models only as a diagnostic to inspect the
registered demo graph names.
The optional editable overlay tests this checkout without changing the self-contained demo project or its lockfile. The demo publishes independent API and Chainlit images and uses official images for third-party services such as Open WebUI. See the demo Docker Compose guide.
The demo also includes a PostgreSQL-persistent Chainlit client. It uses a shared mock login by default, with PocketID OAuth available as an opt-in mode. See the Chainlit demo.
Use In FastAPI
from fastapi import FastAPI
from langgraph_openai_serve import GraphConfig, GraphRegistry, LanggraphOpenaiServe
from your_graphs import my_graph
app = FastAPI()
graphs = GraphRegistry(
registry={
"my-graph": GraphConfig(
graph=my_graph,
description="Answer questions with my LangGraph workflow.",
streamable_node_names=["generate"],
)
}
)
LanggraphOpenaiServe(app=app, graphs=graphs).bind_openai_api()
The default base URL is {host}/v1. Registered graph names become OpenAI model
values.
Docs
- Documentation home: docs/index.md
- Package getting started: docs/getting-started.md
- Self-contained demo stack: docs/demo/index.md
- Runnable demo API: docs/demo/api.md
- Demo graph catalog: docs/demo/graphs.md
- OpenAI clients: docs/tutorials/openai-clients.md
- Custom graphs: docs/tutorials/custom-graphs.md
- LangGraph runtime settings: docs/how-to-guides/langgraph-runtime-settings.md
- OpenAI-compatible proxies: docs/how-to-guides/openai-proxies.md
- API and configuration: docs/reference.md
- Compatibility contract: docs/explanation/openai-compatibility.md
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file langgraph_openai_serve-0.8.0.tar.gz.
File metadata
- Download URL: langgraph_openai_serve-0.8.0.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e029b4f0b642899412dc48d351af1a5485b95222d55454aa443e2b49905250
|
|
| MD5 |
d8a28532a3370e338327fecdcc4f0ef7
|
|
| BLAKE2b-256 |
b9f16e231296e34e7a754e64dd4434384dfc61fea6931a321b774a962c2e5309
|