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

  1. Retry with backoff (often transient 429/5xx)
  2. Verify connectivity: curl https://openrouter.ai/api/v1/models
  3. Cache the model list locally and hardcode a fallback set of model names
  4. 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

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


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/117be5f839ce2557. Report an issue: GitHub.