API Endpoints
This guide provides essential information on how to interact with the API endpoints effectively to achieve seamless integration and automation using our models. Please note that this is an experimental setup and may undergo future updates for enhancement.
The API changes often and documenting it makes little sense. To find the latest endpoints and specs, point an AI agent at the Open WebUI backend and let it read them. The endpoints below stay for reference.
Authentication
To ensure secure access to the API, authentication is required. You can authenticate your API requests using the Bearer Token mechanism. Obtain your API key from Settings > Account in the Open WebUI, or alternatively, use a JWT (JSON Web Token) for authentication. For full instructions on enabling and generating API keys (including the admin toggle and group permissions required for non-admin users) see API Keys.
When Open WebUI is behind a reverse proxy that already uses the Authorization header for its own auth, you can deliver the API key via a custom header instead (x-api-key by default). Admins can rename the header via the CUSTOM_API_KEY_HEADER environment variable to avoid collisions. See Behind a reverse proxy that consumes Authorization? for the full pattern.
Swagger Documentation Links
Open WebUI serves Swagger UI at /docs and its machine-readable OpenAPI schema at /openapi.json when the backend starts with ENV=dev. The backend defaults to dev when ENV is unset, but the Docker image sets ENV=prod, which disables both routes.
If these URLs are unavailable on a local Docker test instance, set ENV=dev in the container environment and recreate the container. Use the same host and port you use to reach Open WebUI. Keep ENV=prod on production deployments.
Notable API Endpoints
Retrieve All Models
-
Endpoint:
GET /api/models -
Description: Fetches all models created or added via Open WebUI.
-
Example:
curl -H "Authorization: Bearer YOUR_API_KEY" http://localhost:3000/api/models
Hidden models are still listed. Hiding a model with Hide in Admin Panel > Settings > Models or in Workspace > Models only sets info.meta.hidden to true. The chat model selector leaves such models out, but GET /api/models returns them to every caller with access, and /api/chat/completions still answers requests for them. To keep a model away from API users, remove their access to it instead. A script that should skip hidden models can drop entries where info.meta.hidden is true.
Programmatic Model Management (Export / Import / Sync)
Custom models are plain JSON, so you can manage them declaratively (in git, via scripts or from an AI agent) without the UI. These endpoints live under /api/v1/models:
| Endpoint | Description |
|---|---|
GET /api/v1/models/all | (Admin) Every saved model record in one unpaginated list, including models no connection is currently offering. Backs the admin models page. |
GET /api/v1/models/export | Export all custom models as a JSON array, or the ones you name with a repeated ids query parameter (?ids=a&ids=b). Asking for a model you cannot write is refused with 403, rather than being quietly left out. |
POST /api/v1/models/import | Bulk upsert: create new models and update existing ones (matched by id). Additive, never deletes. |
POST /api/v1/models/sync | (Admin) Declarative reconcile: makes the instance match the list you send exactly, it creates, updates and deletes any model not in the payload. |
POST /api/v1/models/create | Create a single model. |
POST /api/v1/models/model/update | Update a single model. |
POST /api/v1/models/model/delete | Delete a saved custom model by ID. |
Bulk operations. sync is admin-only. Non-admins need the workspace.models_import permission for import or the workspace.models_export permission for export. Both import and sync take a body of the form {"models": [ ... ]}, where the array is exactly what export returns.
Delete a custom model. Send a JSON body containing the saved custom model's ID as a string. An administrator, the model owner, or a user with Write access to the model can delete it. The response body is the JSON boolean true on success.
curl -X POST https://open-webui.example.com/api/v1/models/model/delete \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "my-custom-model"}'Background images travel as data. A model's background is stored as a file on the instance, so export reads that file and puts it in the record as background_image_data, a data:image/...;base64,... URI, leaving meta.background_image_url null. import reverses it: the data URI is decoded, re-uploaded as a file on the target instance and the fresh file URL written back into meta. That keeps an exported model portable between instances. Two consequences worth knowing when scripting: exporting a model whose background file has gone missing fails the whole request with 400, and an image that breaks the limits (5 MiB, 25 megapixels, PNG/JPEG/WebP/GIF) is rejected on import.
Voice avatars travel as references. A voice avatar and its animations stay files on the source instance, and the export only carries their file IDs. Importing or syncing a model whose avatar or animation files are missing or not accessible on the target instance fails with 403 (Avatar or animation file is not accessible. Upload it again.). Upload the avatar on the target instance first.
Version-controlled, code-driven workflow:
# 1. Snapshot your live models into a file you can commit to git
curl -H "Authorization: Bearer YOUR_API_KEY" \
http://localhost:3000/api/v1/models/export > models.json
# 2. Edit or generate models.json with your scripts or an agent, commit it, then
# reconcile the instance to match the file exactly (creates, updates, prunes)
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"models\": $(cat models.json)}" \
http://localhost:3000/api/v1/models/syncThis gives reproducible, version-controlled model definitions. Use /import instead of /sync for additive updates that never delete existing models. Run the sync step on deploy, in CI or at container startup to load your models automatically.
Chat Completions
- Endpoint:
POST /api/chat/completions - Description: Serves as an OpenAI API compatible chat completion endpoint for models on Open WebUI including Ollama models, OpenAI models, and Open WebUI Function models. A model on a Responses API connection also answers in Chat Completions format, streamed or not, with
finish_reasonset tolengthorcontent_filterwhen the reply was cut off.
Connect an OpenAI-compatible chat client. If the client appends /models and /chat/completions to its base URL, set the base URL to your Open WebUI URL followed by /api/v1, for example http://localhost:3000/api/v1. Use a key from Settings > Account > API keys > Secrets > Show and copy the model ID from the response to GET /api/v1/models. API keys are disabled by default. An administrator must enable API Keys, and non-admin accounts also need the API Keys feature permission. See API Keys for setup.
If API Key Endpoint Restrictions is enabled under Settings > Authentication (admin section), include /api/v1/models and /api/v1/chat/completions in Allowed Endpoints for a client that calls both. The check uses the path the client actually calls, so an entry for /api/chat/completions alone does not cover its /api/v1/chat/completions alias.
Use this endpoint for workspace models. Only /api/chat/completions (and its alias /api/v1/chat/completions) applies a workspace model's settings. On a plain API call it applies the base model, system prompt, parameters and filters, but not the model's tools, knowledge or default features, which need extra fields, as listed below the table. The proxy routes under /openai skip more:
| Route | Workspace model handling |
|---|---|
POST /api/chat/completions | Base model, system prompt, parameters and filters apply. Tools, knowledge and default features apply only when the request asks for them. |
POST /openai/chat/completions | Swaps in the base model and applies the workspace model's system prompt and parameters. Knowledge, tools and filters do not run. |
POST /openai/responses | Nothing applies. The model you send is forwarded to the provider as is, and a workspace model ID that no connection offers goes to the first OpenAI connection, which usually rejects it. |
To use /openai/responses, send the provider's own model ID. On both /openai routes, a non-admin asking for a model that has no saved model record gets 403 with Model not found, unless BYPASS_MODEL_ACCESS_CONTROL is on.
What a plain API call leaves out. The web UI fills in some of a model's settings itself when it builds the request, so an API caller has to send them:
- Tools. The tools picked under Tools in the model editor are added to the request by the web UI, not by the server. Send their IDs in
tool_ids.GET /api/v1/models/model?id=<model-id>lists them undermeta.toolIds. - Default features. The features picked under Default Features are turned on by the web UI only. Send them yourself in
features. - Knowledge and web search. Function calling runs in native mode unless the request sends
params.function_calling, or the model's Function Calling parameter (or the one under Model Defaults) is set tolegacy. In native mode, built-in tools, which include knowledge search and web search, are offered only to requests that carry asession_id. Without one, the model's Knowledge is not searched, andfeatures.web_searchandfeatures.image_generationhave no effect. Send"params": {"function_calling": "legacy"}and Open WebUI searches the model's knowledge, and runs the web search or image generation thatfeaturesasks for, before the model answers. To stay in native mode with built-in tools, follow Server-Side Tool Calling (API). Files and knowledge bases you list infilesare searched either way, unless the model has Preload files turned off (see Using a Knowledge Collection in Chat Completions). - Filters. Global filters and the filters attached to the model run. A filter with a toggle runs only when its ID is in
filter_ids, and the filters marked Start enabled in new chats are sent only by the web UI.filter_idscannot add a filter that is neither global nor attached to the model.
usage from a reply that used toolsA reply can involve several model calls, one per round of tool use. input_tokens, output_tokens, total_tokens and cost add up all calls. prompt_tokens and completion_tokens hold the latest call only, which is what context compaction reads.
The parameters in your request are kept. A workspace model carries its own advanced parameters, and an administrator can set instance-wide ones under Model Defaults in Settings > Models (admin section). Both only fill in what your request left out, so temperature, max_tokens, top_p, seed, stop, reasoning_effort, response_format, logit_bias and, for Ollama models, the options object all keep the values you sent. For an Ollama model, max_tokens reaches Ollama as num_predict. Leave one out and the model's saved value applies, as before. The exception is Stream Chat Response, which still decides whether the reply streams whatever stream your request carries. The Anthropic Messages API below runs through this endpoint, so the same holds there and an SDK's max_tokens reaches the provider intact.
Model controls. A model with Model controls applies each control's default option to API requests as well, and those parameters also only fill in what your request left out. To pick another option, send the control and option IDs under params.model_controls, keyed by model ID. GET /api/models lists a model's controls under info.params.model_controls, with each control's ID, label, default and the IDs and labels of its options:
{
"model": "gpt-5",
"messages": [{ "role": "user", "content": "Plan a three-day trip to Lisbon." }],
"params": { "model_controls": { "gpt-5": { "thinking": "high" } } }
}Any caller with access to the model can pick an option, whatever their Allow Chat Controls and Allow Chat Params permissions say. A pick for a control the model no longer has is ignored, and picking an option the control no longer has returns a 400.
Getting a usage block at all. Most OpenAI-compatible providers leave usage out of a streamed reply unless asked. Open WebUI adds stream_options: {"include_usage": true} itself when the model has the Usage capability enabled, so you do not have to send it. A non-streaming request is left untouched, and a stream_options you send keeps its other keys but has include_usage forced to true, so usage cannot be switched off per request while the capability is on.
Provider errors. When the model provider rejects a request, the endpoint returns the provider's own status code and error, for example a 429 when you hit its rate limit, and passes its Retry-After and retry-after-ms headers through so your client can back off. The OpenAI, Ollama and Anthropic proxy routes forward those retry headers too.
Using Open WebUI tools, including MCP, from the API
The chat completions endpoint can run server-side tools when you pass Open WebUI tool IDs in the request body. This includes native Python tools, OpenAPI tool servers, and MCP tool servers that are already configured and enabled in Open WebUI.
- Configure the tool server in Open WebUI first. For MCP, see Model Context Protocol (MCP).
- Get the tool ID from the tools list endpoint or the browser network request when enabling the tool in chat. MCP tool server IDs use the
server:mcp:<server-id>form. - Include the ID in
tool_idswhen calling/api/chat/completions:
curl -X POST http://localhost:3000/api/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6:27b",
"messages": [
{"role": "user", "content": "Use the configured MCP tool if it helps."}
],
"tool_ids": ["server:mcp:YOUR_MCP_SERVER_ID"]
}'Open WebUI checks the caller's access to each selected tool server before resolving the tools. For OAuth-protected MCP servers, the user associated with the API key must have already completed the OAuth authorization flow in the web UI; otherwise the tool connection can fail during the API request.
If your external client sends its own OpenAI-style tools array, Open WebUI forwards those caller-provided tool definitions to the model instead of resolving tool_ids server-side.
To see which tools an MCP connection offers, call GET /api/v1/tools/id/{id}/specs with a server:mcp:<server-id> ID. It connects to the server and returns {"specs": [{"name": ..., "description": ...}]}. Any other ID, or a server you cannot access, returns 404. An OAuth server you have not signed in to returns 401, a server that does not answer within 15 seconds returns 504 and any other failure returns 502.
Which fields you send decides whether Open WebUI executes tool calls for you or hands them back for your client to run, and whether the answer arrives in the HTTP body or in the chat record. Server-Side Tool Calling (API) walks through every call for both approaches, streaming and non-streaming, with and without saving the chat, and ends in a reusable script.
-
Curl Example:
curl -X POST http://localhost:3000/api/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.6:27b", "messages": [ { "role": "user", "content": "Why is the sky blue?" } ] }' -
Python Example:
import requests def chat_with_model(token): url = 'http://localhost:3000/api/chat/completions' headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json' } data = { "model": "granite3.1-dense:8b", "messages": [ { "role": "user", "content": "Why is the sky blue?" } ] } response = requests.post(url, headers=headers, json=data) return response.json()
Anthropic Messages API
Open WebUI provides an Anthropic Messages API compatible endpoint. This allows tools, SDKs, and applications built for the Anthropic API to work directly against Open WebUI, routing requests through all configured models, filters, and pipelines.
Internally, the endpoint converts the Anthropic request format to OpenAI Chat Completions format, routes it through the existing chat completion pipeline, and converts the response back to Anthropic format. Both streaming and non-streaming requests are supported.
When the target connection already speaks the Anthropic Messages API, the request is forwarded as-is instead of being converted to OpenAI format and back. Nothing is lost in translation, so provider-specific fields survive the round trip without needing passthrough_params.
This applies when the connection's base URL is an Anthropic one, or when its Provider is set to LiteLLM under Advanced in the connection's settings, since LiteLLM exposes an Anthropic-compatible route of its own. The forwarded request goes straight to the provider, so filters, tools and knowledge do not run on it. Every other connection keeps the conversion behaviour described above, and the rest of the dropdown is covered in The Provider Setting.
-
Endpoints:
POST /api/message,POST /api/v1/messages -
Authentication: Supports both
Authorization: Bearer YOUR_API_KEYand Anthropic'sx-api-key: YOUR_API_KEYheader -
Extended thinking: reasoning output from the underlying model is returned as Anthropic
thinkingcontent blocks, in both streaming and non-streaming responses. -
Reasoning effort:
reasoning_effort, andoutput_config.effort, are mapped to the underlying model's reasoning-effort setting. -
Structured outputs:
output_config.format(json_schemaorjson_object) is mapped to the model's response-format setting. -
Passing extra parameters: parameters outside the standard conversion are dropped by default. Set Passthrough params on the connection (
passthrough_params, a comma-separated list of parameter names, or*for every non-standard parameter) to forward them verbatim to the upstream provider. -
Curl Example (non-streaming):
curl -X POST http://localhost:3000/api/v1/messages \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.6-sol", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Why is the sky blue?" } ] }' -
Curl Example (streaming):
curl -X POST http://localhost:3000/api/v1/messages \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.6-sol", "max_tokens": 1024, "stream": true, "messages": [ { "role": "user", "content": "Why is the sky blue?" } ] }' -
Python Example (using the Anthropic SDK):
from anthropic import Anthropic client = Anthropic( api_key="YOUR_OPEN_WEBUI_API_KEY", base_url="http://localhost:3000/api", ) message = client.messages.create( model="gpt-5.6-sol", max_tokens=1024, messages=[ {"role": "user", "content": "Why is the sky blue?"} ], ) print(message.content[0].text)warningThe
base_urlmust behttp://localhost:3000/api(not/api/v1). The Anthropic SDK automatically appends/v1/messagesto the base URL. -
Claude Code Configuration:
To use Claude Code with Open WebUI as a proxy, configure it to point at your Open WebUI instance:
# Set environment variables for Claude Code export ANTHROPIC_BASE_URL="http://localhost:3000/api" export ANTHROPIC_API_KEY="YOUR_OPEN_WEBUI_API_KEY" # Then run Claude Code as normal claudeAlternatively, create or edit
~/.claude/settings.json:{ "env": { "ANTHROPIC_BASE_URL": "http://localhost:3000/api", "ANTHROPIC_AUTH_TOKEN": "YOUR_OPEN_WEBUI_API_KEY" } }This routes all Claude Code requests through Open WebUI's authentication and access control layer, letting you use any configured model (including local models via Ollama or vLLM) with Claude Code's interface.
All models configured in Open WebUI are accessible through this endpoint, including Ollama models, OpenAI models, and any custom function models. The model field should use the model ID as it appears in Open WebUI. Filters (inlet/stream) apply to these requests just as they do for the OpenAI-compatible endpoint.
Tool Use: The Anthropic Messages endpoint supports tool use (tools and tool_choice parameters). Tool calls from the upstream model are translated into Anthropic-format tool_use content blocks in both streaming and non-streaming responses.
Usage reporting: Responses carry whatever usage the upstream model reported, in the closing message_delta when streaming and in usage when not. Prompt-cache counters (cache_creation_input_tokens, cache_read_input_tokens), output_tokens_details, server_tool_use and service_tier are passed through when the provider sends them, so a client that tracks cache hits or reasoning tokens sees the real figures rather than losing them in translation. An OpenAI-style provider that reports cached tokens as prompt_tokens_details.cached_tokens has them mapped to cache_read_input_tokens, and input_tokens is reported the way Anthropic clients expect it: the uncached prompt tokens, with cache creation and cache read counted separately rather than a second time. On a streaming request input_tokens is reported only when it is actually known, so a provider that never reports it leaves the field out instead of showing a fabricated zero.
Usage from the upstream provider is requested only when the model has the Usage capability enabled in its editor. Without it the provider is not asked to include usage in a stream, and the token counts a client receives fall back to what Open WebUI can determine on its own.
Counting Tokens
A companion to the Messages API that reports how many input tokens a request would use, without running it. This mirrors Anthropic's own token-counting endpoint, so SDKs that pre-flight a request for budgeting or context-fitting work unchanged.
- Endpoints:
POST /api/v1/messages/count_tokens,POST /api/message/count_tokens - Authentication: same as the Messages API
- Returns:
{"input_tokens": <int>}
curl -X POST http://localhost:3000/api/v1/messages/count_tokens \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"messages": [
{
"role": "user",
"content": "Why is the sky blue?"
}
]
}'The count is obtained from the upstream provider behind the resolved connection, so the provider must implement token counting. If it does not, or answers unexpectedly, the request fails with a 502.
input_tokens are now realThe Messages API previously always reported input_tokens: 0 in the streaming message_start block. Input tokens are now counted up front and reported in both streaming and non-streaming responses. If counting fails the request still succeeds, so clients should treat the value as best-effort rather than guaranteed.
Speech-to-text transcription
Send recorded audio to POST /api/v1/audio/transcriptions with bearer authentication and a multipart/form-data body. Include the recording in the required file field. The optional language field supplies a language hint to transcription engines that use it. Non-admin callers need the speech-to-text permission (chat.stt). The endpoint saves the original upload on the server. See server-side recording storage.
curl https://open-webui.example.com/api/v1/audio/transcriptions \
-H "Authorization: Bearer $OPEN_WEBUI_TOKEN" \
-F "[email protected]" \
-F "language=en"Read the transcript from text in the JSON response. To ask a model about the recording, send that transcript as a user message in a separate chat completions request.
Image Generation and Editing
- Endpoints:
POST /api/v1/images/generations(body:prompt, optionalmodel,size,n,steps,negative_prompt) andPOST /api/v1/images/edit(body:imageas one or more base64-encoded images or URLs,prompt, optionalmodel,size,n,negative_prompt,background). - Listing image models:
GET /api/v1/images/modelsreturns the image models you can use. Each entry has anidof the form<connection-id>:<model-id>, the baremodelID, andimage_generationandimage_editflags for what it can do.
The model you send must be one of those image models, given as its id or its bare model ID, and it must be able to do the job: an edit needs a model with image_edit set. These routes do not fall back to another model. A model you cannot use, or one no connection offers, returns 400 with Image model "<model>" was not found. A model that cannot do the job returns 400 with Image model "<model>" cannot be used for image generation or Image model "<model>" cannot be used for image edit. Leave model out and the admin's default image model for that job runs, or else the first one you can use. With no usable model at all, the request fails with 400 and [ERROR: No image model is available] ([ERROR: No image model that can edit images is available] for edits).
Image generation or image editing turned off by the admin, or a non-admin without the image generation permission, returns 403 with You do not have permission to access this resource. Please contact your administrator for assistance.
curl -X POST http://localhost:3000/api/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-2", "prompt": "A lighthouse at dusk"}'POST /api/v1/users/user/settings/update patches, it does not replace
The ui object in this request is applied field by field. A field you leave out keeps its current value, and a field sent as null is cleared, which drops the user back to the instance default for it. Sending a partial object is therefore the normal way to change one setting.
A script that reads the settings, edits one key and posts the whole object back still works. One that posts a hand-written object expecting everything else to be wiped does not, since nothing it omits is removed any more.
Removed: POST /api/v1/utils/pdf
The endpoint that rendered a chat to PDF server-side is gone, along with the fonts and the PDF library behind it. Nothing changes for people using Open WebUI: Chat > Download > PDF still works and always renders in the browser. Only a script calling that endpoint directly is affected, and there is no replacement endpoint for it.
Filter and Function Behavior with API Requests
When using the API endpoints directly, filters (Functions) behave differently than when requests come from the web interface.
Open WebUI accepts both API keys (prefixed with sk-) and JWT tokens for API authentication. This is intentional: the web interface uses JWT tokens internally for the same API endpoints. Both authentication methods provide equivalent API access.
Filter Execution
| Filter Function | WebUI Request | Direct API |
|---|---|---|
inlet() | Runs | Runs |
stream() | Runs | Runs |
outlet() | Runs | Runs inline by default, gated by ENABLE_API_OUTLET_FILTERS (see below) |
The inlet() function always executes, making it ideal for:
- Rate limiting: Track and limit requests per user
- Request logging: Log all API usage for monitoring
- Input validation: Reject invalid requests before they reach the model
outlet() runs inline after /api/chat/completions by default, on both the streaming and non-streaming paths, gated by ENABLE_API_OUTLET_FILTERS (default True). A chat_id and a message id are not required: when neither is in the request body, the conversation is reconstructed from the messages you sent plus the assistant reply, and a message ID is generated for it. Set ENABLE_API_OUTLET_FILTERS=False to turn inline execution off for direct API traffic.
What chat_id and id decide is where the response goes. Send both and the request takes the path built for the WebUI: the server consumes the upstream stream itself and routes the content to the user's WebSocket, so the HTTP response to a streaming caller is effectively empty. Omit them and the upstream stream is relayed to you over HTTP as usual, with outlet() running once it has finished.
In every case, outlet() does not rewrite the HTTP response body. It updates the persisted chat message and emits a chat:outlet WebSocket event, but the JSON your client receives is the pre-outlet content. If you need the outlet-filtered text, read it back from the chat record, subscribe to the WebSocket, or keep using /api/chat/completed.
Practical guidance: if you are a pure API consumer (Continue.dev, Claude Code, custom scripts, etc.) and you need outlet()'s output back over HTTP, follow the completion with /api/chat/completed. Inline execution still runs your outlet filters and their side effects; it just does not hand you the filtered payload.
Legacy / Supported-for-API Endpoint: /api/chat/completed
POST /api/chat/completed is the endpoint that reliably runs outlet() for direct API integrations. It is marked deprecated, but as described above, inline execution does not currently return the filtered payload to pure API callers, so in practice /api/chat/completed remains the right call for most API integrations today.
-
Endpoint:
POST /api/chat/completed -
Description: Runs
outlet()filters (and pipeline outlet filters) unconditionally over a completed chat payload. Returns the filtered payload. -
Curl Example:
curl -X POST http://localhost:3000/api/chat/completed \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.6:27b", "messages": [ {"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi! How can I help you today?"} ], "chat_id": "optional-uuid", "session_id": "optional-session-id" }' -
Python Example:
import requests def complete_chat_with_outlet(token, model, messages, chat_id=None): """ Second-step call that returns outlet()'s output to direct API callers. /api/chat/completions runs outlet inline by default but does not rewrite the HTTP response body, so this endpoint is still the right call for API integrations that want outlet's output over HTTP. """ url = 'http://localhost:3000/api/chat/completed' headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json' } payload = { 'model': model, 'messages': messages # Include the full conversation with assistant response } if chat_id: payload['chat_id'] = chat_id response = requests.post(url, headers=headers, json=payload) return response.json()
If you need outlet() output over HTTP today, call /api/chat/completions followed by /api/chat/completed. Inline execution on dev runs your outlet filters, and their side effects (persisted message, chat:outlet WebSocket event, logging or tracing calls) all take place, but the filtered text is not returned in the HTTP response. For more details on filter behavior, see the Filter Function documentation.
OpenAI-compatible embeddings
On Open WebUI v0.13.4, send POST /api/embeddings (also available at /api/v1/embeddings) with a model ID and the text to embed. Choose an embedding model available to your account through an Ollama or OpenAI-compatible connection. Use its ID from GET /api/models, including the connection prefix if one is configured.
The endpoint routes by the request's model field. The embedding engine and model under Admin Panel > Settings > Documents configure RAG separately. If you configured an embedding model only under Documents, make it available through a model connection before using it with this endpoint.
curl https://open-webui.example.com/api/v1/embeddings \
-H "Authorization: Bearer $OPEN_WEBUI_TOKEN" \
-H "Content-Type: application/json" \
-d '{"model": "YOUR_EMBEDDING_MODEL_ID", "input": ["First text", "Second text"]}'Read the vectors from data[].embedding in the JSON response. For the native Ollama request and response format, use the Ollama embeddings proxy.
Ollama API Proxy Support
If you want to interact directly with Ollama models (including for embedding generation or raw prompt streaming) Open WebUI offers a transparent passthrough to the native Ollama API via a proxy route.
- Base URL:
/ollama/<api> - Reference: Ollama API Documentation
Generate Completion (Streaming)
curl http://localhost:3000/ollama/api/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6:27b",
"prompt": "Why is the sky blue?"
}'List Available Models
curl http://localhost:3000/ollama/api/tags \
-H "Authorization: Bearer YOUR_API_KEY"Generate Embeddings
curl -X POST http://localhost:3000/ollama/api/embed \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6:27b",
"input": ["Open WebUI is great!", "Let'\''s generate embeddings."]
}'When using the Ollama Proxy endpoints, you must include the Content-Type: application/json header for POST requests, or the API may fail to parse the body. Authorization headers are also required if your instance is secured.
Responses API (OpenAI-Compatible)
Ollama supports the OpenAI Responses API format. Open WebUI proxies this through the Ollama router with the same model resolution, access control, and prefix handling used by chat completions.
curl -X POST http://localhost:3000/ollama/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6:27b",
"input": "Why is the sky blue?"
}'This allows API consumers (Codex, Claude Code, etc.) to use the Responses API directly with Ollama-hosted models without configuring a separate OpenAI-compatible connection.
This is ideal for building search indexes, retrieval systems, or custom pipelines using Ollama models behind the Open WebUI.
Embeddings (OpenAI-Compatible)
Alongside the native /ollama/api/embed route above, Open WebUI proxies an OpenAI-compatible embeddings endpoint, so clients that already speak the OpenAI embeddings format can use Ollama-hosted embedding models without configuring a separate connection. It applies the same model resolution, access control, and prefix handling as the other proxied routes.
curl -X POST http://localhost:3000/ollama/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6:27b",
"input": "Open WebUI is great!"
}'A specific backend can be targeted with /ollama/v1/embeddings/{url_idx}. The endpoint returns 503 if the Ollama integration is disabled.
Chat Completions, Completions, Messages and Models (OpenAI-Compatible)
Open WebUI also proxies Ollama's other /v1 routes. Each one takes a /{url_idx} suffix to target one Ollama connection, for example /ollama/v1/chat/completions/0. On the POST routes, a non-admin needs read access to the workspace model they name, and the connection's Prefix ID is removed from the model ID before the request goes to Ollama.
| Route | What Open WebUI applies |
|---|---|
POST /ollama/v1/chat/completions | Swaps a workspace model ID for its base model and applies the workspace model's system prompt and parameters. Knowledge, tools and filters do not run. |
POST /ollama/v1/completions | Swaps in the base model and applies the workspace model's parameters. The system prompt is not added. |
POST /ollama/v1/messages | Takes the Anthropic Messages format. Swaps in the base model and forwards the rest of the request unchanged. Returns 503 if the Ollama integration is disabled. |
GET /ollama/v1/models | Lists models in the OpenAI format, from every enabled Ollama connection. A user with the user role sees only models with a saved model record they can read, unless BYPASS_MODEL_ACCESS_CONTROL is on. With /{url_idx} it lists that connection's models and is admin-only. Other users get 401. |
curl -X POST http://localhost:3000/ollama/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6:27b",
"messages": [{"role": "user", "content": "Why is the sky blue?"}]
}'For filters, tools and knowledge, use /api/chat/completions instead.