Skip to main content

synapsekit serve

Deploy any SynapseKit app as a FastAPI server in one command. Auto-detects the object type and creates appropriate endpoints.

pip install synapsekit[serve]

Quick start

synapsekit serve my_app:rag --host 0.0.0.0 --port 8000

Where my_app:rag is a module:attribute import path pointing to a SynapseKit object (RAGPipeline, CompiledGraph, ReActAgent, FunctionCallingAgent, etc.).

CLI options

OptionDefaultDescription
app(required)Import path in module:attribute format
--host127.0.0.1Bind host
--port8000Bind port
--reloadfalseEnable auto-reload for development

Auto-detected endpoints

The CLI auto-detects the type of your object and creates type-appropriate endpoints:

RAG (RAGPipeline, RAG)

MethodPathDescription
POST/querySend a query, get an answer
GET/healthHealth check
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{"query": "What is SynapseKit?"}'

Graph (CompiledGraph)

MethodPathDescription
POST/runRun the graph with initial state
GET/streamStream graph events via SSE
GET/healthHealth check
curl -X POST http://localhost:8000/run \
-H "Content-Type: application/json" \
-d '{"state": {"messages": ["hello"]}}'

Agent (ReActAgent, FunctionCallingAgent)

MethodPathDescription
POST/runRun the agent with a prompt
GET/healthHealth check
curl -X POST http://localhost:8000/run \
-H "Content-Type: application/json" \
-d '{"prompt": "Search for Python tutorials"}'

OpenAPI docs

Every served app automatically includes OpenAPI documentation at /docs (Swagger UI) and /redoc (ReDoc).

Example: serving a RAG pipeline

# my_app.py
from synapsekit import RAG

rag = RAG(model="gpt-4o-mini", api_key="sk-...")
rag.add("SynapseKit is an async-first Python framework for LLM applications.")
synapsekit serve my_app:rag --port 8000

Programmatic usage

You can also build the FastAPI app programmatically:

from synapsekit.cli.serve import build_app

app = build_app(my_rag_pipeline, app_type="rag")

# Use with any ASGI server
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)