continuedev/continue · warning
Failed to fetch OpenRouter models: ${response.status}
Error message
Failed to fetch OpenRouter models: ${response.status} What it means
Thrown by fetchOpenRouterModels when GET https://openrouter.ai/api/v1/models returns a non-OK status. This endpoint normally requires no auth, so a failure indicates connectivity, rate limiting, or an outage rather than bad credentials.
Source
Thrown at core/llm/fetchModels.ts:128
name,
description,
icon: getOllamaIcon(name),
supportsTools: capabilities.includes("tools"),
});
}
return models;
} catch (error) {
console.error("Error fetching Ollama library models:", error);
return [];
}
}
async function fetchOpenRouterModels(): Promise<FetchedModel[]> {
try {
const response = await fetch("https://openrouter.ai/api/v1/models");
if (!response.ok) {
throw new Error(`Failed to fetch OpenRouter models: ${response.status}`);
}
const data = await response.json();
if (!data.data || !Array.isArray(data.data)) {
return [];
}
return data.data
.filter((m: any) => m.id && m.name)
.map((m: any) => ({
name: m.name,
modelId: m.id,
icon: "openrouter.png",
contextLength: m.context_length,
maxTokens: m.top_provider?.max_completion_tokens,
supportsTools: (m.supported_parameters ?? []).includes("tools"),
}));
} catch (error) {View on GitHub (pinned to 5522c6f44c)
Solutions
- Retry with backoff (often transient 429/5xx)
- Verify connectivity: curl https://openrouter.ai/api/v1/models
- Cache the model list locally and hardcode a fallback set of model names
- Check openrouter.ai status page for outages
Example fix
// before
const models = await fetchModels();
// after
let models;
for (let i = 0; i < 3 && !models; i++) {
try { models = await fetchModels(); } catch (e) { await sleep(1000 * 2 ** i); }
} Defensive patterns
Strategy: retry
Validate before calling
const r = await fetch('https://openrouter.ai/api/v1/models'); if (!r.ok) serveCachedModelList(); Try / catch
catch (e) { if (e.message.includes('Failed to fetch OpenRouter models')) { await sleep(2000); retry(); } else throw e; } Prevention
- Cache the OpenRouter catalog
- Back off on 429/5xx
- Hardcode fallback model names for offline use
When it happens
Trigger: OpenRouter API unreachable or returning 429/5xx; proxy or firewall blocking openrouter.ai; temporary outage.
Common situations: CI environments with restricted egress; heavy polling hitting rate limits; regional blocks.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to fetch Ollama library: ${response.status}
- Failed to fetch Anthropic models: ${response.status}
- Failed to fetch Gemini models: ${response.status}
- Failed to fetch models for ${provider}: ${error?.message ??
- Failed to fetch Google search results: ${response.statusText
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/117be5f839ce2557.
Report an issue: GitHub.