Skip to main content

OmniServe — Production API Server

Turn any agent into a production-ready REST/SSE API with a single command. OmniServe is an optional production extra:

Agent File Requirements

Your Python file must define one of the following:
OmniServe looks for agent variable first, then create_agent() function. Your file must export one of these.

Quick Start

Step 1: Create your agent file (my_agent.py)

Step 2: Set environment variables

Step 3: Run the server

Step 4: Test the API


CLI Commands


CLI Options: omniserve run

Examples:

CLI Options: omniserve quickstart

Start a server instantly without writing any code:
Use the provider that matches your LLM_API_KEY. For an OpenAI key, run omniserve quickstart --provider openai --model gpt-4o-mini. Examples:

API Endpoints

Core Endpoints

/ready returns ready: true only after the FastAPI lifespan has completed startup, the served agent is initialized, and any configured MCP servers are connected. Agents without MCP servers do not need an MCP client to pass readiness.

Background Task Endpoints

These routes are mounted when background execution is enabled. It is enabled by default and can be turned off with OMNICOREAGENT_BACKGROUND_ENABLED=false or OmniServeConfig(background_enabled=False). *Auth required only if --auth-token is set or OMNICOREAGENT_SERVE_AUTH_ENABLED=true with OMNICOREAGENT_SERVE_AUTH_TOKEN.

Request/Response Examples

For telemetry traces, trace_id is the exact lookup handle returned by the agent runtime. run_id is the serving/runtime correlation handle returned from /run/sync and SSE completion payloads. Use trace_id when you need one exact trace. Use run_id when your UI or application needs all telemetry for one execution inside a shared session. /telemetry/events defaults to limit=200; /telemetry/traces defaults to limit=100. Both accept lower limits per request. Exact trace, run trace, and session trace detail endpoints return 404 when no matching trace exists or an accessor returns a trace that does not match the requested selector.

Background Task Example

OmniServe registers the served agent as a background-capable agent during server startup. The default background agent id is default; override it with OMNICOREAGENT_BACKGROUND_AGENT_ID or OmniServeConfig(background_agent_id="...").
Set {"wait": true} when the response should wait for terminal run state. If the run does not finish before the background wait budget, OmniServe returns 504 with the run_id, latest status, wait_timeout_seconds, and request_timeout_seconds in detail; use the run_id with /background/runs/{run_id} to inspect the run later. If auth is enabled with --auth-token or OMNICOREAGENT_SERVE_AUTH_ENABLED=true, add -H "Authorization: Bearer YOUR_TOKEN" to protected requests. Each run stores operational state in the task store and writes lifecycle files into the configured workspace namespace. Use the default in-memory task store for local development, or choose sql, redis, or mongodb when runs must survive restarts. Durable stores preserve queued runs across server restarts: OmniServe can queue a run, stop, start again with the same task store, and the new manager can claim and complete that run. Choose one durable backend per deployment. Use SQL/SQLite for local durability or simple single-node services. Use Redis when your deployment already operates Redis with persistence and no eviction for task-store keys. Use MongoDB when MongoDB is your durable operational store. Common inspection endpoints:

Environment Variables

Server settings use the OMNICOREAGENT_SERVE_* prefix. Background task settings use the OMNICOREAGENT_BACKGROUND_* prefix. Environment variables always override code values. You can run OmniServe without adding any OMNICOREAGENT_SERVE_* variables. The defaults enable the background API, start the worker, and use in-memory background task state. Add variables only when you want to change server behavior, authentication, rate limits, or background storage.
The background task store is not conversation memory. Memory stays in MemoryRouter. The task store is the control plane for schedules, runs, attempts, leases, retries, and cancellation. Leave it at the in-memory default to start; choose sql, redis, or mongodb when that state must survive restarts. Redis durable deployments need persistence enabled and a no-eviction policy for task-store keys. MongoDB durable deployments use majority writes.
Example shell environment:

Docker Deployment

Generate a Dockerfile

Build and run

The generator creates a Dockerfile for the current project directory and stores only non-sensitive defaults in the image: The agent file must be inside the current Docker build context. The generator does not import or execute the agent file. S3/R2 workspace credentials are passed at runtime with -e, never baked into the image.

Cloud deployment examples


Python API (Programmatic Control)

For full programmatic control, use OmniServe directly in your Python script:
Run with Python directly:
CLI vs Python API:
  • omniserve run --agent my_agent.py — CLI loads your agent file and applies CLI flags
  • python server.py — You control everything programmatically via OmniServeConfig
Environment Variable Precedence: environment variables always override values set in OmniServeConfig.

OmniServe is perfect for deploying agents as microservices, webhooks, chatbots, or any HTTP-accessible AI capability.

Learn More: See OmniServe Cookbook for more examples.