praisonai serve openai starts a FastAPI server that exposes OpenAI-compatible HTTP endpoints — point any existing OpenAI SDK code at it and it works as a drop-in replacement.
Quick Start
How It Works
Endpoints
All endpoints follow the OpenAI REST specification.| Method | Path | Description | Streaming |
|---|---|---|---|
POST | /v1/chat/completions | Chat completions | SSE (stream: true) with [DONE] sentinel |
POST | /v1/completions | Legacy text completions | No |
GET | /v1/models | List available models | No |
POST | /v1/tools/invoke | PraisonAI extension — invoke an agent tool | No |
GET | /__praisonai__/discovery | Provider discovery | No |
GET | /health | Health check | No |
Streaming
Setstream=True to receive tokens via Server-Sent Events:
data: [DONE] sentinel. Errors during streaming are also sent as SSE events:
Tool Invocation
/v1/tools/invoke is a PraisonAI extension that calls an agent tool by name. It requires --agents-url to point to a running agents server.
Authentication
Pass--api-key to require authentication:
Authorization header:
CLI Reference
| Option | Type | Default | Description |
|---|---|---|---|
--host, -h | str | "127.0.0.1" | Host to bind to |
--port, -p | int | 8765 | Port to bind to |
--agents-url | str | "http://127.0.0.1:8000" | URL of the running Agents API server |
--api-key | str | None | Optional API key for authentication |
--reload | bool | False | Enable auto-reload (dev) |
Choosing Between serve openai and serve rag --openai-compat
| Surface | Command | Scope |
|---|---|---|
| OpenAI server | praisonai serve openai | Standalone — chat, completions, models, tool invocation |
| RAG compat flag | praisonai serve rag --openai-compat | RAG microservice only, chat endpoint only |
| Unified | praisonai serve unified | All providers in a single server |
For OpenAI-compatible RAG queries, use
praisonai serve rag --openai-compat instead. See RAG CLI for details.Error Shape
All errors follow the OpenAI error format:Best Practices
Set an API key for production
Set an API key for production
Always pass
--api-key when running on a public or shared network. The default configuration accepts unauthenticated requests.Bind to 0.0.0.0 for external access
Bind to 0.0.0.0 for external access
The default
127.0.0.1 only accepts local connections. Use --host 0.0.0.0 to accept connections from other machines — always pair with --api-key.Route model names with LiteLLM
Route model names with LiteLLM
The server passes
model directly to the underlying LLM. Use LiteLLM-style model names (ollama/llama3, anthropic/claude-3-5-sonnet-20241022) to route to any provider.When to use the unified server instead
When to use the unified server instead
Use
praisonai serve unified when you need multiple protocol surfaces (MCP, A2A, agents) alongside the OpenAI-compat layer. Use serve openai for a lightweight standalone deployment that only exposes OpenAI endpoints.Related
Serve Commands
All praisonai serve subcommands
Gateway
Unified gateway and control plane
RAG OpenAI Compat
OpenAI-compatible RAG server
LLM Endpoint Config
Configure LLM provider endpoints

