fix(models): accept all models from 9router, remove claude-only filter

This commit is contained in:
Zac Gaetano 2026-06-02 12:27:53 -04:00
parent 07b6f4eb87
commit 7ed22b9077

View file

@ -17,8 +17,8 @@ let cacheExpiry = 0;
/**
* Maps a raw /v1/models entry to the { value, label } shape used by the UI.
* Filters to models that are relevant for Claude routing (id contains 'claude'
* or starts with 'cc/').
* Accepts all models returned by the endpoint 9router surfaces only what it
* actually routes, so no client-side filtering is needed.
*
* @param {Object} entry - Raw model object from /v1/models
* @returns {{ value: string, label: string } | null}
@ -27,14 +27,8 @@ function mapModelEntry(entry) {
const id = typeof entry?.id === 'string' ? entry.id.trim() : null;
if (!id) return null;
// Only surface Claude-family and cc/* (9router) models for the Claude provider.
// Extend this filter if you want to surface all models.
const isClaude = id.toLowerCase().includes('claude') || id.startsWith('cc/');
if (!isClaude) return null;
// Build a human-readable label from the id.
// e.g. "cc/claude-sonnet-4-6" → "claude-sonnet-4-6 (9router)"
// "claude-3-5-sonnet-20241022" → "claude-3-5-sonnet-20241022"
// Build a human-readable label: prefer server-supplied name, then id.
// cc/* entries strip the prefix and add a "(9router)" suffix for clarity.
let label = entry.name ?? id;
if (id.startsWith('cc/')) {
label = `${id.slice(3)} (9router)`;
@ -80,7 +74,7 @@ async function fetchModelsFromApi() {
const mapped = raw.map(mapModelEntry).filter(Boolean);
if (mapped.length === 0) return null;
console.log(`[model-discovery] Loaded ${mapped.length} Claude models from ${url}`);
console.log(`[model-discovery] Loaded ${mapped.length} models from ${url}`);
return mapped;
} catch (err) {
console.warn(`[model-discovery] Failed to fetch ${url}:`, err?.message ?? err);