Langgraph API OpenSource, no License-Key required, to be used with n8n-
2.6K
mwaeckerlin/langgraph-agent is a minimalistic, highly optimized and secure image to run LangGraph agent workflows as a REST API.
Built on top of mwaeckerlin/python, using mwaeckerlin/python-build for multi-stage builds. No commercial license required — uses LangGraph as an open-source Python library.
This image is intended as a self-hosted alternative to langchain/langgraph-api for local and on-prem deployments, without requiring platform registration or commercial runtime licensing.
Exposes API on port 8000.
GRAPHS_DIR (default /app/graphs) — mount .py modules with graph, name, description exportslanggraph_api_key or environment variable LANGGRAPH_API_KEYDATABASE_URI — PostgreSQL connection string for checkpoint persistence (required, startup fails if missing)OPENAI_BASE_URL — OpenAI-compatible API base URL (e.g. http://litellm:4000/v1)OPENAI_API_KEY — API key for the LLM endpoint (can also be read from secret litellm_master_key)GRAPHS_DIR — directory to scan for graph modules (default /app/graphs)LLM_MODEL — default model name (default gpt-4o-mini)Secrets are read from /run/secrets/ and take precedence over environment variables:
langgraph_api_key — Bearer token for API authenticationlitellm_master_key — LLM endpoint API key (sets OPENAI_API_KEY)langgraph_db_password — fallback to construct DATABASE_URI when DATABASE_URI is not setGET /ok — health check (no auth required)GET /graphs — list loaded graphsPOST /runs — execute a graph statelesslyPOST /threads — create a conversation threadPOST /threads/{thread_id}/runs — execute a graph with checkpoint persistenceGET /threads/{thread_id}/state — retrieve thread stateThis project focuses on a lightweight self-hosted runtime and intentionally keeps a smaller operational surface.
What this image provides:
What is intentionally out of scope compared to full platform runtimes:
See docker-compose.yml for a local example stack with:
db (PostgreSQL)n8nlanggraph-agentStart:
npm run starthttp://localhost:8583/okhttp://localhost:5678Notes:
.env (Docker Compose standard)..env is ignored by git; commit only .env.example.POST /runs needs a real LLM endpoint/key (OPENAI_BASE_URL, OPENAI_API_KEY).cp .env.example .env.env and set at least:
OPENAI_BASE_URL=https://openrouter.ai/api/v1 (or your OpenAI-compatible endpoint)OPENAI_API_KEY=<your_real_api_key>npm run startExample .env:
POSTGRES_DB=n8n
POSTGRES_USER=n8n
POSTGRES_PASSWORD=local_db_password
N8N_ENCRYPTION_KEY=local_n8n_encryption_key
LANGGRAPH_API_KEY=local_langgraph_api_key
OPENAI_BASE_URL=https://openrouter.ai/api/v1
OPENAI_API_KEY=sk-or-v1-xxxxxxxx
LLM_MODEL=openrouter/openai/gpt-4o-mini
Provider/Key matching is mandatory:
sk-or-v1-...) requires:
OPENAI_BASE_URL=https://openrouter.ai/api/v1sk-...) requires:
OPENAI_BASE_URL=https://api.openai.com/v1If key and base URL do not match, model calls fail with 401 authentication errors.
After changing .env, restart the stack:
npm run stopnpm run buildnpm start (foreground) or npm run start:daemon (background)http://localhost:8000/docs (interactive API docs)Ctrl+C (or npm stop for daemon mode)docker run -it --rm --name agent -p 8583:8000 mwaeckerlin/langgraph-agent
Browse to http://localhost:8583/ok. Returns {"status": "ok"} when healthy.
Place .py files in GRAPHS_DIR (default /app/graphs). Each module must expose:
graph — compiled LangGraph StateGraphname — unique graph identifier (str)description — human-readable description (str)Example: see graphs/echo.py.
This repository contains a minimal local stack (db, n8n, langgraph-agent) and an importable n8n workflow template.
Start it with:
npm run starthttp://localhost:5678... menu (top right) → Import from file… → select n8n-sample-workflow.jsonLangGraph Agent Gateway and click Publish.POST /webhook/langgraph/create-threadPOST /webhook/langgraph/runPOST /webhook/langgraph/thread-run/webhook/... endpoints for published operation./webhook-test/... endpoints are for editor test mode only.curl -i -X POST http://localhost:5678/webhook/langgraph/create-threadcurl -i -X POST http://localhost:5678/webhook/langgraph/run -H 'Content-Type: application/json' -d '{"graph_name":"echo","input":{"message":"hello stateless"},"config":{}}'curl -i -X POST http://localhost:5678/webhook/langgraph/thread-run -H 'Content-Type: application/json' -d '{"thread_id":"<THREAD_ID>","graph_name":"echo","input":{"message":"hello thread"},"config":{}}'curl -i http://localhost:8583/okcurl -i -H 'Authorization: Bearer local_langgraph_api_key' http://localhost:8583/graphsLLM auth note:
OPENAI_API_KEY is missing, echo falls back to local response mode and returns "[local-echo] <message>".OPENAI_API_KEY for the configured OPENAI_BASE_URL.Content type
Image
Digest
sha256:c8acb739d…
Size
38 MB
Last updated
1 day ago
docker pull mwaeckerlin/langgraph-agent