Skip to content

fix: correct provider icons, ~ model filtering, and model ID stripping#8

Merged
sena-labs merged 1 commit into
mainfrom
claude/laughing-beaver-f67164
May 7, 2026
Merged

fix: correct provider icons, ~ model filtering, and model ID stripping#8
sena-labs merged 1 commit into
mainfrom
claude/laughing-beaver-f67164

Conversation

@sena-labs
Copy link
Copy Markdown
Owner

Summary

  • Bug: All 22 provider icon URLs returned 404 — icons used /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). Added moonshotai (new icon found).
  • Bug: ~ prefix models excluded by provider filter — OpenRouter exposes 8 "latest" alias models (e.g. ~anthropic/claude-haiku-latest, ~openai/gpt-latest). Their provider_key was ~anthropic/~openai instead of anthropic/openai, so they were silently excluded whenever MODEL_PROVIDERS was set to any specific provider. Fixed with .lstrip("~") in pipes() and _sync_model_icons().
  • Bug: _clean_model_id corrupted model IDs containing .anthropic/claude-3.5-sonnet (no manifold prefix) was incorrectly stripped to 5-sonnet. Fixed by checking for / in the prefix before splitting.
  • Fix: legacy broken-icon cleanup — on first sync after update, old /images/models/ URLs in OWUI's DB are cleared so OWUI shows its default icon rather than a broken image.
  • Fix: _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.
  • Refactor: _build_cache_key() helper — eliminates duplicate inline strings; hashes the API key instead of storing it in plaintext in long-lived cache-key strings.
  • Type hint: added -> requests.Response on _retryable_request().
  • Cleanup: inlined unused user_field variable in _prepare_payload().

Test plan

  • python test_pipe.py402 passed, 0 failed (was 374 before this session; +28 new assertions covering tilde filtering, new icon URLs, _is_owui_managed_icon with both paths, and real OpenRouter model IDs in _clean_model_id)
  • Sanity check icon URLs: python -c "from openrouter_pipe import _PROVIDER_ICONS; [print(k, v) for k, v in _PROVIDER_ICONS.items()]" — all should contain /images/icons/
  • With MODEL_PROVIDERS=anthropic set, ~anthropic/claude-haiku-latest should appear in the model list
  • With MODEL_PROVIDERS=ALL (default), all 368+ OpenRouter models should appear

Notes 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 the openrouter/ 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

…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>
Copilot AI review requested due to automatic review settings May 7, 2026 14:19
@sena-labs sena-labs merged commit 0f31796 into main May 7, 2026
6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 added moonshotai.
  • Fixed provider filtering and icon-sync provider resolution to treat ~openai/... as openai (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.

Comment thread openrouter_pipe.py
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 thread openrouter_pipe.py
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}"
Comment thread openrouter_pipe.py
Comment thread openrouter_pipe.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants