# Open WebUI OpenAI-Compatible API: Setup and Fixes

> Connect Open WebUI to an OpenAI-compatible API: the exact URL, API key and API Type, Docker env vars that stick, model picks with USD prices, and 401/404 fixes.

Source: https://goiapi.com/en/blog/open-webui-openai-compatible-api
Updated: 2026-12-05

Author: GoiAPI, December 5, 2026

To connect Open WebUI to an OpenAI-compatible API, open **Admin Panel > Settings > Connections**, add a connection under **Manage OpenAI API Connections**, and enter the provider's base URL ending in `/v1` (for GoiAPI, `https://api.goiapi.com/v1`) plus your API key. Keep **API Type** on **Chat Completions**, click **Verify Connection**, save, and the provider's models appear in the model selector.

That is the whole happy path. The rest of this guide covers what Open WebUI actually appends to your URL (and the exact 404 you get when it is wrong), why Docker environment variables seem to be ignored after the first start, how Open WebUI rewrites requests for `gpt-5`-and-later model IDs, and how background tasks quietly multiply your token bill.

How we checked this guide: field names, environment variables and Docker commands come from the Open WebUI docs and source code on GitHub, checked on December 5, 2026 (the latest release then was v0.13.5, published November 25, 2026). GoiAPI's error messages were captured with curl on December 5, 2026, and the model list comes from a `/v1/models` call on December 3, 2026. We have **not tested Open WebUI against GoiAPI end to end**, so click **Verify Connection** and send a test message after each step.

## What you need

- A running Open WebUI instance and an admin account (the first account created is the admin).
- An API key for an OpenAI-compatible endpoint. For GoiAPI it looks like `sk-...` and is created on the **API Keys** page of the dashboard.
- The endpoint's base URL. It is the part that comes before `/models` and `/chat/completions`, which for most providers ends in `/v1`.

If base URL vs endpoint is new to you, [what an OpenAI-compatible API is](https://goiapi.com/en/blog/openai-compatible-api) explains it in five minutes.

## Step 1: Run Open WebUI with Docker

The Open WebUI docs recommend Docker for most users. This one-line command works in bash and PowerShell:

```bash
docker run -d -p 3000:8080 -v open-webui:/app/backend/data -e WEBUI_SECRET_KEY=replace-with-a-random-string --name open-webui --restart always ghcr.io/open-webui/open-webui:main
```

Per the [Quick Start docs](https://docs.openwebui.com/getting-started/quick-start) (checked December 5, 2026):

- `-p 3000:8080` serves the UI on port 3000. Keep `8080` on the right; that is the port inside the container.
- `-v open-webui:/app/backend/data` holds chats, users and settings, including your connections. Never run without it.
- `WEBUI_SECRET_KEY` should be set once and kept, or everyone is logged out when the container is recreated. The docs suggest `openssl rand -hex 32`.
- The docs' version also adds `--add-host=host.docker.internal:host-gateway`, which only matters if Open WebUI must reach Ollama on the same machine. For an API-only setup you can drop it.

Running on a small VPS? Swap `:main` for `:slim`. The docs list it at about 197 MB to download instead of 1.62 GB, and about 300 MiB of RAM at idle (their own measurement from October 16, 2026). Slim leaves out local embeddings, document extraction and speech, which you do not need for chatting through an API.

Open `http://localhost:3000` once the log shows `Uvicorn running on http://0.0.0.0:8080`. Without Docker, the docs support `python -m pip install open-webui` followed by `open-webui serve` on Python 3.11 or 3.12 (3.13 is not supported).

## Step 2: Add the connection in Admin Panel > Settings > Connections

1. Open your account menu, choose **Admin Panel**, then the **Settings** tab, then **Connections**.
2. Next to **Manage OpenAI API Connections**, click **+** (Add Connection). If the list already holds an `https://api.openai.com/v1` row with no key, edit it or switch it off with its toggle.
3. Fill in the fields below.
4. Click **Verify Connection** next to the URL field. Open WebUI calls `<URL>/models` with your key and shows "Server connection verified" on success.
5. Click **Save** in the dialog, then **Save** at the bottom of the Connections page.
6. Start a new chat, pick a model from the selector and send a short message.

| Open WebUI field | Value for GoiAPI | Notes |
|---|---|---|
| **Connection Type** | External | Label for the Local/External filters; also decides that the External Task Model applies (see the cost section) |
| **URL** | `https://api.goiapi.com/v1` | Include `/v1`, nothing after it |
| **Auth** | Bearer | Sends the key as `Authorization: Bearer` |
| **API Key** | your key, `sk-...` | |
| **API Type** | **Chat Completions** | The default; see below |
| **Prefix ID** | empty | Only needed when two connections share model names |
| **Model IDs** | empty, or the IDs you want to show | Empty shows every model your key can use |
| **Provider** (under **Advanced**) | Default | Other options are for Azure, llama.cpp, LM Studio, vLLM, OpenRouter and LiteLLM |

Field names come from the [Connect a Provider docs](https://docs.openwebui.com/getting-started/quick-start/connect-a-provider) and the connection dialog in the Open WebUI source, both checked December 5, 2026.

### Check that API Type says Chat Completions

The connection dialog switches **API Type** to **Responses** automatically whenever the URL contains `api.openai.com`. If you edited the preinstalled OpenAI row, or typed an OpenAI address before changing it, the toggle may still say Responses. Click it to switch back. GoiAPI does serve the [Responses API](https://goiapi.com/en/docs/openai-responses), but our tests of all nine models went through `/v1/chat/completions` ([Chat Completions docs](https://goiapi.com/en/docs/openai-chat-completions)), so that is the tested path.

## The URL rules: /v1, trailing slashes and what Open WebUI appends

The Open WebUI troubleshooting docs say it does not validate the URL: it removes one trailing slash and appends a fixed path, `/models` to list models and `/chat/completions` to chat. Here is what each common mistake turns into. The responses are GoiAPI's real error bodies, captured with curl on December 5, 2026:

| You enter | Open WebUI requests | GoiAPI returns |
|---|---|---|
| `https://api.goiapi.com/v1` | `/v1/models` | 200 with a valid key |
| `https://api.goiapi.com` | `/models` | 404 `Cannot GET /models` |
| `https://api.goiapi.com/v1/chat/completions` | `/v1/chat/completions/models` | 404 `The path GET /v1/chat/completions/models does not exist.` |
| `https://api.goiapi.com/v1/v1` | `/v1/v1/models` | 404 `The path GET /v1/v1/models does not exist.` |
| `https://api.goiapi.com/v1//` | `/v1//models` | 404 `The path GET /v1//models does not exist.` |

A single trailing slash typed into the dialog is harmless because the dialog strips it. The real trailing-slash trap is in environment variables. In the source code we checked, Open WebUI strips a trailing slash from `OPENAI_API_BASE_URL` but not from the plural `OPENAI_API_BASE_URLS`, so `https://api.goiapi.com/v1/` in the plural variable becomes `/v1//models` and the last row of the table.

## Configure the connection with Docker environment variables

To start the container with the connection already in place:

```bash
docker run -d -p 3000:8080 -v open-webui:/app/backend/data -e WEBUI_SECRET_KEY=replace-with-a-random-string -e OPENAI_API_BASE_URL=https://api.goiapi.com/v1 -e OPENAI_API_KEY=sk-... -e ENABLE_OLLAMA_API=false --name open-webui --restart always ghcr.io/open-webui/open-webui:main
```

Or with Docker Compose:

```yaml
services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    ports:
      - "3000:8080"
    volumes:
      - open-webui:/app/backend/data
    environment:
      - WEBUI_SECRET_KEY=replace-with-a-random-string
      - OPENAI_API_BASE_URL=https://api.goiapi.com/v1
      - OPENAI_API_KEY=sk-...
      - ENABLE_OLLAMA_API=false
    restart: unless-stopped

volumes:
  open-webui:
```

Run it with `docker compose up -d`, and keep files with real keys out of Git.

| Variable | What it does (per the [environment variable reference](https://docs.openwebui.com/reference/env-configuration), checked December 5, 2026) |
|---|---|
| `OPENAI_API_BASE_URL` | The OpenAI connection URL; defaults to `https://api.openai.com/v1` |
| `OPENAI_API_KEY` | The key for that connection |
| `OPENAI_API_BASE_URLS` / `OPENAI_API_KEYS` | Several connections at once, separated by `;`, keys in the same order as the URLs |
| `OPENAI_API_CONFIGS` | Per-connection settings as JSON keyed by index, for example `{"0": {"model_ids": ["gpt-6-luna"]}}` |
| `ENABLE_OLLAMA_API` | Set to `false` when you do not run Ollama |

### Why your environment variables seem to be ignored

All of these are `ConfigVar` variables. The docs state they are read on the **first launch only**; after that, the values stored in Open WebUI's database win. So if you add or change `OPENAI_API_KEY` on a container that has already run, nothing happens. Either change the connection in **Admin Panel > Settings > Connections**, or restart once with `RESET_CONFIG_ON_START=true`. The docs say this clears every saved setting from the database (all connections, task models, interface settings) and rebuilds them from environment variables and defaults. Back up the `open-webui` volume first, and remove the flag right after that start, or every restart wipes your settings again. If you want environment variables to always win, the docs offer `ENABLE_PERSISTENT_CONFIG=false`, at the cost of UI changes being lost on every restart.

## Pick your models

With a valid key, Open WebUI reads `GET /v1/models`. GoiAPI answers in the OpenAI list format (`{"object": "list", "data": [...]}`), which is what Open WebUI expects ([List models](https://goiapi.com/en/docs/list-models)); listing models is not charged. The December 3, 2026 call returned nine models. Prices per 1M tokens, checked December 5, 2026 on the [pricing page](https://goiapi.com/en/pricing):

| Model ID | Good for | Input | Output |
|---|---|---|---|
| `gpt-6-luna` | Everyday chat, short answers | $0.0208 | $0.1248 |
| `claude-haiku-5-5` | Fast chat, summaries | $0.0221 | $0.1105 |
| `deepseek-v4.1-flash` | Many-turn, budget work | $0.0408408 | $0.1225224 |
| `glm-5.3-flash` | Same role as DeepSeek V4.1 Flash | $0.0408408 | $0.1225224 |
| `deepseek-v4-pro-0813` | More careful answers, code | $0.144144 | $0.432432 |
| `glm-5.3` | More careful answers, code | $0.144144 | $0.432432 |
| `gpt-6.1-sol`, `gpt-6.2-sol` | Hard tasks, long writing | $0.13 | $0.78 |
| `claude-opus-5-5` | The hardest tasks | $0.442 | $2.21 |

To show only some of them, type the IDs into **Model IDs** and click **+**. The docs note that once this list is set, Open WebUI stops calling `/models` for that connection and shows exactly what you typed. For deeper price comparisons, see [GPT-6 API pricing](https://goiapi.com/en/blog/gpt-6-api-pricing), [Claude API pricing](https://goiapi.com/en/blog/claude-api-pricing) and [DeepSeek V4 API pricing](https://goiapi.com/en/blog/deepseek-v4-api-pricing).

### Claude goes through Chat Completions

Open WebUI only switches to its Anthropic compatibility layer for Anthropic's own URLs, so on any other OpenAI-compatible endpoint Claude is called through Chat Completions. On December 3, 2026, both Claude models returned 200 through `/v1/chat/completions` in our main test run, but `claude-haiku-5-5` returned 503 through that route in a separate run the same day (details in the [Cline, Roo Code, Kilo Code and Cursor setup guide](https://goiapi.com/en/blog/cline-roo-code-kilo-code-cursor-api-key)). Keep a GPT, DeepSeek or GLM model as a fallback.

### What Open WebUI changes for gpt-5 and later model IDs

The OpenAI-compatible docs describe a rule that applies to every server, not just OpenAI: when a model ID starts with `gpt-` followed by 5 or higher (or `o` plus a digit), Open WebUI renames `max_tokens` to `max_completion_tokens` and sends the first `system` message with the `developer` role. `gpt-6-luna`, `gpt-6.1-sol` and `gpt-6.2-sol` all match. GoiAPI accepts both `max_tokens` and `max_completion_tokens` ([Limits and balance](https://goiapi.com/en/docs/limits-and-balance)); we have not tested the `developer` role through GoiAPI. If a GPT model seems to ignore your system prompt, this rule is the first thing to check.

### Reasoning tokens on the two flash models

`deepseek-v4.1-flash` and `glm-5.3-flash` reason before answering, and reasoning counts as output tokens. In our December 3, 2026 test, `deepseek-v4.1-flash` with `max_tokens: 400` spent all 400 tokens reasoning and returned an empty reply that was still billed. If you set **max_tokens** in a model's **Advanced Params**, do not set it low for these two.

## What one chat costs, and the hidden background calls

This is a **calculation**, not a measurement. It **assumes** one chat turn sends 2,000 input tokens (system prompt plus history) and gets 500 output tokens back, with no caching:

| Model | 1 turn | 1,000 turns |
|---|---|---|
| `claude-haiku-5-5` | $0.000099 | $0.10 |
| `gpt-6-luna` | $0.000104 | $0.10 |
| `deepseek-v4.1-flash` | $0.000143 | $0.14 |
| `deepseek-v4-pro-0813` | $0.000505 | $0.50 |
| `gpt-6.1-sol` | $0.00065 | $0.65 |
| `claude-opus-5-5` | $0.001989 | $1.99 |

Formula: (input tokens × input price + output tokens × output price) ÷ 1,000,000, at the December 5, 2026 prices. Try your own numbers in the [cost calculator](https://goiapi.com/en/tools/cost-calculator), and see [AI API tokens explained](https://goiapi.com/en/blog/ai-api-tokens-pricing) for how input and output tokens are counted.

Each request that returns content also has a small minimum charge, so very short turns and background calls (titles, tags) can cost slightly more than the formula; a failed request that returns no content is not charged. Check the real amounts on the Request history page.

Two things make real costs higher than the table:

- **History grows.** Every turn resends the whole conversation, so turn 20 costs far more than turn 1. Start a new chat when the topic changes; [Claude Code prompt is too long](https://goiapi.com/en/blog/claude-code-prompt-is-too-long) covers how context limits work.
- **Background tasks.** Per the [Task Models docs](https://docs.openwebui.com/features/administration/task-models) (checked December 5, 2026), Open WebUI makes extra model calls to write chat titles, generate tags and suggest follow-up questions, and by default it uses the model you are chatting with. Chat with `claude-opus-5-5` and every title is billed at Opus rates. In **Admin Panel > Settings > Interface**, under **Tasks**, set **External Task Model** to a low-priced, non-reasoning model such as `gpt-6-luna` or `claude-haiku-5-5` (avoid the two flash models because of their reasoning tokens). If you do not want follow-up suggestions, turn it off in **Admin Panel > Settings > Interface**, or set `ENABLE_FOLLOW_UP_GENERATION=false` on a fresh install (it is a ConfigVar too, read on first launch only).

## Troubleshooting Open WebUI connection errors

When **Verify Connection** fails and the API returns a JSON error, Open WebUI shows "OpenAI:" followed by the API's message ([Connection Errors docs](https://docs.openwebui.com/troubleshooting/connection-error), checked December 5, 2026). During a chat, the message usually appears in the reply itself. The 401 and 404 messages below were captured with curl on December 5, 2026; the others come from the [error codes docs](https://goiapi.com/en/docs/error-codes). Messages follow your account's language; for requests without a valid key (the 401 rows), the language depends on the request's Accept-Language header, so the exact wording you see may differ.

| Symptom | Message from GoiAPI | Cause | Fix |
|---|---|---|---|
| Verify fails with 401, no models | `Missing API key. Send your key in the Authorization: Bearer <key> header or the x-api-key header.` | Empty **API Key**, or **Auth** not set to Bearer | Paste the key, choose Bearer |
| Verify fails with 401 | `The API key is invalid or has been revoked.` | Wrong, truncated or revoked key, or a pasted space | Create a new key and paste it again |
| Verify fails with 404, no models | `Cannot GET /models` | URL missing `/v1` | Use `https://api.goiapi.com/v1` |
| Verify fails with 404 | `The path GET /v1//models does not exist.` (or `/v1/v1/models`, `/v1/chat/completions/models`) | Extra slash, extra `/v1` or `/chat/completions` | Keep only `https://api.goiapi.com/v1` |
| Chat fails with 404 | `The model <name> does not exist. See the list at /v1/models.` | Typo in **Model IDs** | Copy the ID from the pricing page, or clear **Model IDs** |
| Chat fails with 403 | `This API key is not allowed to use the model <model>.` or `This API key cannot be used from IP address <ip>.` | Key restricted by model or IP | Update the key's limits in the dashboard |
| Chat fails with 402 | `Your balance is too low for this request (about $<amount> needs to be held). Please top up your balance.` | Balance below the hold for the request | Top up, or set a lower **max_tokens** |
| Chat fails with 429 | Per-minute limit, `Your account already has {max} requests running at the same time…`, spending limit, or `The model is overloaded. Please try again in a few minutes.` | A whole team sharing one key, or the key hit its daily or monthly cap | Wait for `Retry-After`; for spending caps, raise the limit or wait |

Problems that do not come with a clear code:

- **Verified, but no models in the selector.** An old value in **Model IDs**, or you did not click **Save** at the bottom of the Connections page. Reload after saving.
- **403 from an IP-restricted key.** Requests come from the machine running Open WebUI, not from each user's browser, so allow your server's public IP on the key ([Authentication](https://goiapi.com/en/docs/authentication)).
- **The model selector spins and the UI feels slow.** The docs blame an unreachable connection, typically an Ollama URL with no Ollama behind it. Switch off unused connections or set `ENABLE_OLLAMA_API=false`.
- **Empty replies when the model calls a tool.** The Open WebUI docs have a dedicated section on this. We have not tested tool calling through GoiAPI, so try a prompt that forces a tool call before turning tools on for everyone.

## Knowledge and RAG need a separate embeddings source

Document chat (Knowledge, file attachments) needs embeddings, and GoiAPI does not offer them: on December 5, 2026, `POST /v1/embeddings` returned 404 `The path POST /v1/embeddings does not exist.` So:

- On the `:main` image, keep the default embedding engine (`RAG_EMBEDDING_ENGINE` empty, meaning SentenceTransformers inside the container). If you switch the engine to OpenAI, set `RAG_OPENAI_API_BASE_URL` and `RAG_OPENAI_API_KEY` to a service that offers embeddings; do not point it at GoiAPI, which has no `/v1/embeddings`.
- On `:slim`, the docs say knowledge search needs an external embeddings service and PostgreSQL with pgvector. If you rely on documents, `:main` is simpler.

The answer written from the retrieved passages still comes from your chat model, and those passages count as input tokens.

## Running Open WebUI for a team

Every user's chats go through the connection's key, so the whole team shares one key and one balance. A few controls help:

- **Create a dedicated key for Open WebUI** with daily and monthly spending limits. When a cap is hit, requests get a 429 instead of draining your balance.
- **Concurrent requests are capped per account.** Several people chatting at once, plus the background title and tag calls, can hit that cap and get a 429; users just resend after a few seconds.
- **Restrict the key to the models** you want to offer; others return 403.
- **Restrict the key to your server's IP**, so a leaked key is far less useful.
- In Open WebUI, use **Model IDs** and model access settings so each group only sees the models meant for it. If you set an External Task Model, give every group read access to it; per the Task Models docs, users who cannot read it get no titles, tags or follow-ups, while admins testing the setup see no problem.

The **Request history** page in the GoiAPI dashboard shows the cost of every request, so you can see what Open WebUI spends per day. Setting up other tools with the same key? See the [n8n guide](https://goiapi.com/en/blog/n8n-claude-gpt-api) and the [OpenCode custom provider guide](https://goiapi.com/en/blog/opencode-custom-provider).

## FAQ

### What URL do I enter for an OpenAI-compatible API in Open WebUI?

The base URL including `/v1`, for GoiAPI `https://api.goiapi.com/v1`. Open WebUI appends `/models` and `/chat/completions` itself, so never add them.

### Does a trailing slash break Open WebUI?

Not in the connection dialog, which strips one trailing slash. It can in the `OPENAI_API_BASE_URLS` environment variable, which is not stripped in the source we checked, so `/v1/` there leads to a 404 on `/v1//models`.

### Why does Verify Connection pass but the chat fails?

Verify only calls `/models`; it never runs a model. Chat failures are usually 402 (balance below the hold), 403 (key restricted by model or IP), 404 (wrong ID in Model IDs) or 503 (model temporarily not responding). Read the message in the reply and match it to the table above.

### Can I use Claude in Open WebUI without an Anthropic key?

Yes. Add the OpenAI connection with `https://api.goiapi.com/v1` and pick `claude-haiku-5-5` or `claude-opus-5-5`. Both go through Chat Completions; keep a GPT or DeepSeek model as a fallback because we saw an occasional 503 on that route.

### Should I set API Type to Responses?

Only if you know the provider expects it. For GoiAPI, keep **Chat Completions**, the path we tested with all nine models.

## Get started

1. [Create a GoiAPI account](https://goiapi.com/en/signup).
2. Top up with USDT (TRC20 or BEP20) or Binance Pay, from 5 to 4,000 USDT at a time, where 1 USDT adds $1 to your balance. No credit card and no monthly fee ([quickstart](https://goiapi.com/en/docs/quickstart)). Top-ups are final and non-refundable ([refund policy](https://goiapi.com/en/refund-policy)), so add only what you plan to use; by the calculation above (before the per-request minimum charge), $5 covers tens of thousands of short turns on the low-priced models. More on paying without a card: [OpenAI API without a credit card](https://goiapi.com/en/blog/openai-api-without-credit-card).
3. Create a dedicated key for Open WebUI on the **API Keys** page, with spending limits.
4. Add the connection in **Admin Panel > Settings > Connections** with `https://api.goiapi.com/v1`, click **Verify Connection**, save, and send a test message.

GoiAPI sells API access to the models mentioned in this article.
