windmill-labs/windmill · error
Failed to fetch models for provider ${provider}
Error message
Failed to fetch models for provider ${provider} What it means
For all non-Bedrock providers, fetchAvailableModels requests the OpenAI-compatible `models` listing through Windmill's AI proxy, forwarding the provider and resource path (plus anthropic-version for Anthropic). A non-ok response is logged and rethrown as this Error naming the provider. It means the provider rejected the credential/endpoint used by the proxy.
Source
Thrown at frontend/src/lib/components/copilot/lib.ts:270
})
}
// Standard provider handling
const endpoint = 'models'
const models = await fetch(
`${location.origin}${OpenAPI.BASE}/w/${workspace}/ai/proxy/${endpoint}`,
{
signal,
headers: {
'X-Resource-Path': resourcePath,
'X-Provider': provider,
...(provider === 'anthropic' ? { 'anthropic-version': '2023-06-01' } : {})
}
}
)
if (!models.ok) {
console.error('Failed to fetch models for provider', provider, models)
throw new Error(`Failed to fetch models for provider ${provider}`)
}
const data = (await readListing(models, maxBytes)) as { data: ModelResponse[] }
if (data.data.length > 0) {
const sortFunc = (provider: AIProvider) => (a: string, b: string) => {
// First prioritize models in defaultModels array
const defaultModels = AI_PROVIDERS[provider]?.defaultModels || []
const aInDefault = defaultModels.includes(a)
const bInDefault = defaultModels.includes(b)
if (aInDefault && !bInDefault) return -1
if (!aInDefault && bInDefault) return 1
return 0
}
switch (provider) {
case 'openai':
return data.data
.filter(View on GitHub (pinned to e474e8803c)
Solutions
- Check console/network for the proxy response body to see the vendor's error (401 vs 404 vs 429)
- Re-enter/rotate the API key in the provider resource and test it
- For customai, verify the resource's base URL exposes an OpenAI-compatible /models endpoint
- Fix billing/quota on the vendor account, or retry on transient 5xx
Defensive patterns
Strategy: try-catch
Try / catch
try {
models = await fetchAvailableModels(res, ws, provider, signal)
} catch (e) {
notifyUser(`Model listing failed for ${provider}: check the provider resource API key`)
models = AI_PROVIDERS[provider]?.defaultModels ?? []
} Prevention
- Test the provider API key in the resource editor before chatting
- For customai, confirm the base URL serves an OpenAI-compatible /models route
- Watch vendor status pages and quota/billing; 429/402 surface here
- Cache a known-good model list to degrade gracefully on outages
When it happens
Trigger: GET /w/<workspace>/ai/proxy/models returns non-ok for providers like openai, anthropic, groq, mistral, openrouter, togetherai, deepseek, azure: invalid API key in the provider resource, 401/403 from the vendor, wrong base URL for customai endpoints, quota/billing issues, or vendor outage (5xx).
Common situations: Expired or revoked API keys; customai resource pointing at a base URL without a /models route; Azure resource missing deployment config; rate-limited or unpaid account; typo'd provider resource selection in the chat settings.
Related errors
- Failed to fetch foundation models for AWS Bedrock
- Bad Gateway
- Bad Gateway
- Failed to clone git repo `{}`: {e}
- no pinned address to connect
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/8dd12a0e8f387453.
Report an issue: GitHub.