EN ▾
Get API key

Open WebUI Knowledge Base with a Hosted LLM API

An Open WebUI knowledge base lets you upload files and ask a chat model questions about them. The model itself can live on a hosted OpenAI-compatible API, so you only run the web interface. This page covers the connection, the knowledge setup and the settings that change answer quality.

Updated

Document sheets feeding fragments into a chat window connected to a server, illustrating an Open WebUI knowledge base

Key points

  1. Add the API under Connections as an OpenAI API entry with the base URL and your key; the model ID is uncensored.
  2. Open WebUI builds the knowledge base itself; this API handles chat only and has no embeddings endpoint.
  3. Retrieved passages are added to the prompt, so every question costs input tokens.
  4. Small chunks, a modest top-k and a clear system prompt give the biggest quality gains.

How the pieces fit together

Open WebUI is a self-hosted chat interface that can talk to any OpenAI-compatible server. A knowledge base in Open WebUI is a collection of documents that the interface splits into chunks, indexes and searches whenever you ask a question. The best matches are pasted into the prompt, and the chat model writes an answer from them. This pattern is called retrieval-augmented generation, or RAG.

That means two models are involved, and only one of them is the hosted API:

  • The embedding step turns text chunks into vectors for search. Open WebUI does this itself, and by default it runs a small embedding model locally inside its own container. This API has no embeddings endpoint, so do not point the embedding setting at it.
  • The chat step reads your question plus the retrieved chunks and writes the answer. This is where the hosted model, uncensored at https://api.grokunhinged.cc/v1, does its work.

The practical result: you keep your document index on your own machine, and only the question and the retrieved passages travel to the API when you chat. Prompts are not used for training, but you should still avoid uploading material you are not allowed to send to a third-party service.

Step 1: connect the API to Open WebUI

You need a key first. Sign up with Google or with email and password and open the API key page; the one-click trial gives $0.50 of credit for 7 days with no payment. Then, in Open WebUI:

  1. Sign in as an admin and open the Admin Settings, then the Connections section.
  2. Add a new connection of type OpenAI API.
  3. For the URL enter https://api.grokunhinged.cc/v1. For the key paste your key. The interface sends it as Authorization: Bearer.
  4. Save and use the verify button if one is shown. The interface calls GET /v1/models, and uncensored should appear in the model list.

If you run Open WebUI in Docker you can also set the connection with environment variables when the container starts:

docker run -d -p 3000:8080 \
  -e OPENAI_API_BASE_URL="https://api.grokunhinged.cc/v1" \
  -e OPENAI_API_KEY="$API_KEY" \
  -v open-webui:/app/backend/data \
  --name open-webui ghcr.io/open-webui/open-webui:main

Open http://localhost:3000, create the first admin account and pick uncensored in the model selector. Send a short test message before you add any documents. If the model list is empty, the usual causes are a trailing slash mistake, a missing /v1 at the end of the URL, or a key with a typo.

Step 2: create the knowledge base

Menu names change between Open WebUI releases, so look for the Workspace area in the sidebar and then Knowledge. The steps are:

  1. Create a new knowledge base and give it a plain name and a one-line description.
  2. Upload files. PDFs, Markdown, plain text and similar document formats are the safe choices. Scanned PDFs without a text layer give poor results because there is no text to index.
  3. Wait for the processing indicator to finish. Large files take longer because every chunk is embedded.
  4. Start a chat, type # in the message box and choose the knowledge base, or attach it to a custom model in the workspace so it is always on.

Attaching the base to a custom model is the better route for repeat use. You pick uncensored as the base model, add the knowledge base, and write a system prompt for how answers should look. People then select that custom model and never think about retrieval again.

Keep the base focused. One base for one topic, for example a game's lore, a product's manual or a set of story notes, retrieves far better than a single base with every file you own. Mixed bases pull in irrelevant chunks that waste tokens and confuse the answer.

Settings that change answer quality

Open WebUI exposes retrieval settings in the admin area under Documents. Names vary a little by version, but these matter most.

SettingEffectStarting point
Chunk sizeHow much text sits in one searchable piece800 to 1,000 characters
Chunk overlapText repeated between neighbors so sentences are not cut off100 to 200 characters
Top KHow many chunks go into each prompt4 to 6
Relevance thresholdDrops weak matchesRaise it if answers cite unrelated text

A higher Top K gives the model more to work with but raises input tokens on every question. A lower Top K is cheaper and sometimes sharper. The context window here is 100,000 tokens, prompt plus completion, so you will not run out of room with normal chunk sizes, but long answers over huge contexts cost more and drift.

A system prompt for a knowledge model should tell the model what to do when the documents do not contain the answer. Without it, the model fills gaps from its own memory and sounds sure about it.

Answer using the supplied documents. If the documents do not contain the answer, say so and then give your best guess, marked as a guess. Quote the relevant passage briefly. Keep answers under 200 words.

Testing the same setup from code

When retrieval gives odd answers, it helps to separate the two halves. Send the question and a pasted passage straight to the API and see if the model handles it. If it does, the problem is in retrieval settings, not the model.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.grokunhinged.cc/v1",
    api_key=os.environ["API_KEY"],
)

passage = "The northern gate closes at dusk. The keeper, Orla, holds the only key."
resp = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "Answer only from the passage."},
        {"role": "user", "content": passage + "\n\nQuestion: Who holds the gate key?"},
    ],
    temperature=0.2,
)
print(resp.choices[0].message.content)

A low temperature such as 0.2 keeps document answers close to the source text. Raise it for creative use. The quickstart shows the same call in curl if you want to test without Python.

When answers are wrong or missing

Retrieval problems come in a few shapes, and each has a different fix. If the model says it cannot find something that is clearly in a file, the file probably failed to index; reopen the knowledge base and check that the document shows as processed. If it finds the right file but gives a vague answer, the chunk is too short to carry the fact, so raise the chunk size a little. If it mixes two documents, the question is ambiguous or the bases are not separated enough. Rewriting the question with a distinctive term from the document, such as a name or a heading, often helps more than any setting.

It also helps to open the source citations Open WebUI shows below an answer. They tell you which chunks were used, so you can see whether the fault lies in retrieval or in the model's reading of the text.

Cost and limits for a document chat

Knowledge-base chat is input heavy, because retrieved text is added to every question. The price is $0.15 per 1M input tokens and $0.50 per 1M output tokens. Take a question with a 300 token system prompt and question, plus 5 chunks of about 250 tokens each, which is 1,550 input tokens, and a 350 token answer:

  • Input: 1,550 / 1,000,000 x $0.15 = $0.0002325
  • Output: 350 / 1,000,000 x $0.50 = $0.000175
  • Total: $0.0004075 per question

A hundred questions cost about $0.04. Even heavy use stays small, so the bigger decision is data handling, not price. Prepaid credit never expires, failed or refused requests are not charged, and top-ups run from $20 to $500 by USDT on TRC20 or USDC on Base. See the pricing page for bonus tiers.

Limits to remember: a full key allows 8 concurrent requests and 300 per minute, and a trial key allows 2 and 60. Open WebUI may send extra background requests, such as title generation, while you chat. On a trial key, those can push you into HTTP 429 with the code concurrency. If that happens, turn off the optional auto-generation features or move to a full key.

The model is tuned to answer without content refusals for lawful adult use, which suits private story, lore and research collections. Nothing sexual involving minors is allowed.

Questions and answers

Can I use this API for the embedding model in Open WebUI?

No. The API offers chat completions and a model list only, with no embeddings endpoint. Keep Open WebUI's default local embedding or use a separate embedding service.

Why does my knowledge base answer with unrelated text?

Usually the chunks are too large, Top K is too high, or the base mixes unrelated topics. Reduce chunk size and Top K, and split topics into separate bases.

Does Open WebUI send my documents to the API?

Only the retrieved passages relevant to each question are added to the prompt and sent. The full files stay in your Open WebUI instance.

Which model name do I choose in Open WebUI?

Choose uncensored. It appears in the list after the connection is verified through the models endpoint.

Start with trial credit

Email and password, key on screen right away.

Get API key