fix: correct provider icons, ~ model filtering, and model ID stripping#8
Merged
Conversation
…pping
- Fix all 22 provider icon URLs: /images/models/ path returned 404; updated
to verified /images/icons/ URLs (13 providers). Removed 9 entries that have
no icon at that path (avoids broken-image requests in OWUI). Added moonshotai.
- Add legacy icon cleanup: when a provider has no icon and the DB holds one of
our old /images/models/ URLs, clear it so OWUI shows its default instead of
a broken image.
- Fix _is_owui_managed_icon to also recognise /images/icons/ so future icon
URL changes are not blocked by the user-set-icon guard.
- Fix _clean_model_id: model IDs like anthropic/claude-3.5-sonnet were
incorrectly stripped to 5-sonnet when passed without a manifold prefix.
Now checks for '/' in the prefix before stripping.
- Fix ~ prefix models (e.g. ~anthropic/claude-haiku-latest): provider_key
was ~anthropic instead of anthropic, causing them to be excluded when
MODEL_PROVIDERS filter was active. Applied lstrip('~') in pipes() and
_sync_model_icons().
- Extract _build_cache_key() helper: DRY between _models_cache_valid and the
cache-store assignment; hashes the API key instead of embedding it raw.
- Add return type hint on _retryable_request() -> requests.Response.
- Inline unused user_field variable in _prepare_payload().
- 402 tests pass (was 374 before this session; +28 new assertions).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes OpenRouter provider icon syncing and model-list filtering edge cases in the Open WebUI pipe, especially around OpenRouter’s ~provider/... “latest alias” models and dotted model IDs (e.g. claude-3.5-*). It also updates provider icon URL handling to use the correct OpenRouter /images/icons/ path and adds regression tests for these behaviors.
Changes:
- Updated provider icon mapping to
/images/icons/, removed providers without valid icons, and addedmoonshotai. - Fixed provider filtering and icon-sync provider resolution to treat
~openai/...asopenai(and similarly for other providers). - Fixed
_clean_model_id()to avoid corrupting OpenRouter model IDs that contain dots, and expanded tests accordingly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
openrouter_pipe.py |
Fixes provider icon URLs, tilde-provider filtering, model ID cleaning, and refactors model-list cache keying. |
test_pipe.py |
Adds/updates regression tests for tilde-provider filtering, dotted model IDs, provider icon paths, and managed-icon detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| in long-lived strings that may end up in logs or memory dumps. | ||
| """ | ||
| api_key_hash = ( | ||
| hashlib.sha256(self.valves.OPENROUTER_API_KEY.encode("utf-8")).hexdigest()[:16] |
Comment on lines
+349
to
+352
| return ( | ||
| f"{api_key_hash}|{self.valves.FREE_ONLY}|" | ||
| f"{self.valves.MODEL_PROVIDERS}|{self.valves.INVERT_PROVIDER_LIST}|" | ||
| f"{self.valves.MODEL_PREFIX}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/images/models/path which does not exist. Verified and updated to/images/icons/for 13 providers; removed 9 entries without a valid icon (prevents broken-image requests in OWUI). Addedmoonshotai(new icon found).~prefix models excluded by provider filter — OpenRouter exposes 8 "latest" alias models (e.g.~anthropic/claude-haiku-latest,~openai/gpt-latest). Theirprovider_keywas~anthropic/~openaiinstead ofanthropic/openai, so they were silently excluded wheneverMODEL_PROVIDERSwas set to any specific provider. Fixed with.lstrip("~")inpipes()and_sync_model_icons()._clean_model_idcorrupted model IDs containing.—anthropic/claude-3.5-sonnet(no manifold prefix) was incorrectly stripped to5-sonnet. Fixed by checking for/in the prefix before splitting./images/models/URLs in OWUI's DB are cleared so OWUI shows its default icon rather than a broken image._is_owui_managed_icon— extended to also recognise/images/icons/path so future icon URL changes are not blocked by the user-set-icon guard._build_cache_key()helper — eliminates duplicate inline strings; hashes the API key instead of storing it in plaintext in long-lived cache-key strings.-> requests.Responseon_retryable_request().user_fieldvariable in_prepare_payload().Test plan
python test_pipe.py→ 402 passed, 0 failed (was 374 before this session; +28 new assertions covering tilde filtering, new icon URLs,_is_owui_managed_iconwith both paths, and real OpenRouter model IDs in_clean_model_id)python -c "from openrouter_pipe import _PROVIDER_ICONS; [print(k, v) for k, v in _PROVIDER_ICONS.items()]"— all should contain/images/icons/MODEL_PROVIDERS=anthropicset,~anthropic/claude-haiku-latestshould appear in the model listMODEL_PROVIDERS=ALL(default), all 368+ OpenRouter models should appearNotes for reviewer
The OpenRouter public API currently exposes 368 models (the README says "300+", which was accurate at an earlier date — a separate docs update may be warranted). Eight of those models carry a
~prefix indicating dynamic "latest" aliases. Five belong to theopenrouter/provider (meta-routing models).The icon URL change is a data fix, not a behavior change — OWUI was silently displaying broken images; now it will display the correct provider logos for 13 providers and the default icon for the rest.
🤖 Generated with Claude Code