Skip to content

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.

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.

All three are config coverage — no code required.

{
"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.

  1. mono-agent init --model anthropic:claude-sonnet-4-6
  2. Add the openaiApi section; set allowNonLoopback: true for a non-loopback bind, put MONO_AGENT_OPENAI_API_KEY in the owner-only .env, set modelId, and enable continuous session mode under runtime.session.
  3. mono-agent validate, then mono-agent start and confirm the status line reports openaiApi running with its endpoint.
  4. In Open WebUI, add an OpenAI connection pointing at http://host:4040/v1 with the bearer key.
  5. 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).
  6. Verify SSE streaming token-by-token in the UI.