Models from an external OpenAI-compatible connection are missing from /api/models when prefix_id is empty
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 875
- Forks
- 630
- Avg merge
- 15h 43m
- Merged PRs (30d)
- 43
Description
Bug Description
When an external OpenAI-compatible connection has an empty prefix_id, the models it returns are correctly fetched when querying that connection individually (/openai/models/{idx}), but they are silently dropped when the models are merged/aggregated into the final list at /api/models. No error is logged.
Adding a non-empty prefix_id to the same connection immediately fixes the issue and the models appear in /api/models.
Environment
- open-webui image:
ghcr.io/open-webui/open-webui:main - Deployment: Docker, self-hosted
- Backend proxy: LiteLLM (
ghcr.io/berriai/litellm:main-latest), acting as an OpenAI-compatible endpoint on the same Docker network
Steps to Reproduce
- Add an external OpenAI API connection pointing to an OpenAI-compatible endpoint (in my case, a local LiteLLM proxy at
http://litellm:4000/v1), withprefix_idleft empty. - Enable the connection (
enable: true), verify connection succeeds (POST /openai/verifyreturns 200). - Query that connection's models directly:
GET /openai/models/{connection_index}
→ Returns the full list of models correctly (confirmed 8 models returned, e.g.packy.aws-q/claude-sonnet-5,packy.cc-sale/claude-sonnet-5, etc.) - Query the aggregated model list:
GET /api/models
→ The models from this connection are completely absent, even though other connections (with non-emptyprefix_id) show up correctly. - Edit the connection and set
prefix_idto any non-empty string (e.g.lite/). - Query
/api/modelsagain → the models now appear correctly (prefixed as expected).
Expected Behavior
Models from a connection with an empty prefix_id should still appear in the aggregated /api/models response, the same as models from a connection with a prefix_id set — only the model ID prefixing should differ, not whether the models are included at all.
Actual Behavior
Models are silently dropped during aggregation when prefix_id is an empty string (""). No error, no warning in logs — connection verification and individual model fetch (/openai/models/{idx}) both succeed.
Additional Context
OPENAI_API_CONFIGSfor the affected connection (viaGET /openai/config):
{
"enable": true,
"tags": [],
"prefix_id": "",
"model_ids": [],
"connection_type": "external",
"auth_type": "bearer",
"passthrough_params": []
}
- Other connections in the same config, with non-empty
prefix_id, work as expected. - Logs during the failing request show only
200 OKresponses for all relevant endpoints (/openai/verify,/openai/models/{idx},/api/models) — no exceptions or errors are logged, making this hard to diagnose.
Suggested Fix Direction
The model-merging logic likely uses prefix_id as part of a key (e.g., for deduplication or grouping), and an empty string may be causing models to be overwritten, filtered, or excluded unintentionally during that step. Would appreciate a look at whatever function assembles the aggregated model list at /api/models to see how it treats connections with an empty/falsy prefix_id.
Workaround
Setting a non-empty prefix_id (e.g. a short string like lite/) on the affected connection resolves the issue completely.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the aggregation behind GET /api/models and compare it with GET /openai/models/{connection_index}, focusing on how an empty prefix_id is handled during merging or deduplication. Reproduce with an enabled external connection whose prefix_id is empty, then confirm its models appear in the aggregated response without a prefix while existing prefixed connections still work.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100