OpenAI-Compatible Endpoint for Open WebUI
This playbook exposes a mono-agent agent as an OpenAI-compatible /v1 endpoint so Open WebUI (or any OpenAI client) can list the model, stream responses token-by-token over SSE, and keep multi-turn conversation state per chat.
Who this is for
Section titled “Who this is for”AI infra engineers fronting the agent with a chat UI.
Expose the agent as an OpenAI-compatible /v1 endpoint so Open WebUI can stream responses and keep multi-turn conversation state.
Features used
Section titled “Features used”openai-api.chat-completions—/v1/models+/v1/chat/completionswith SSE streaming and an optional bearer key.openai-api.session-headers— session continuity via theX-OpenWebUI-Chat-Id/X-Conversation-Idrequest headers (only the latest user turn is forwarded per conversation).runtime.provider-sessions— continuous provider sessions that retain context across requests.
All three are config coverage — no code required.
Configuration
Section titled “Configuration”{ "runtime": { "model": "anthropic:claude-sonnet-4-6", "session": { "mode": "continuous", "idleTimeoutMs": 1800000 } }, "openaiApi": { "enabled": true, "host": "0.0.0.0", "port": 4040, "basePath": "/v1", "allowNonLoopback": true, "modelId": "my-agent" }}Create an owner-only .env in the invocation folder (chmod 600 .env) and add:
MONO_AGENT_OPENAI_API_KEY=<strong-client-bearer>The same settings can be supplied via environment variables (MONO_AGENT_*); see Environment variables for the full mapping.
mono-agent init --model anthropic:claude-sonnet-4-6- Add the
openaiApisection; setallowNonLoopback: truefor a non-loopback bind, putMONO_AGENT_OPENAI_API_KEYin the owner-only.env, setmodelId, and enable continuous session mode underruntime.session. mono-agent validate, thenmono-agent startand confirm the status line reportsopenaiApirunningwith its endpoint.- In Open WebUI, add an OpenAI connection pointing at
http://host:4040/v1with the bearer key. - Send two consecutive messages in one Open WebUI chat and confirm continuity (only the latest user turn is forwarded per conversation; prior context comes from the continuous session keyed by the chat id header).
- Verify SSE streaming token-by-token in the UI.