lfnovo/open-notebook · error · HTTPException
Failed to discover models
Error message
Failed to discover models
What it means
Catch-all 500 from POST /api/credentials/{credential_id}/discover-models. Discovery makes live calls to the provider API using the stored credential; any unexpected failure (network error, provider schema change, auth layer crash) is wrapped as this 500.
Source
Thrown at api/routers/credentials.py:446
credential_id=cred.id or "",
provider=provider,
discovered=[
DiscoveredModelResponse(
name=d["name"],
provider=d["provider"],
description=d.get("description"),
)
for d in discovered
],
)
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error discovering models for credential {credential_id}: {e}")
raise HTTPException(status_code=500, detail="Failed to discover models")
@router.post("/{credential_id}/register-models", response_model=RegisterModelsResponse)
async def register_models_for_credential(
credential_id: str, request: RegisterModelsRequest
):
"""Register discovered models and link them to this credential."""
try:
result = await register_models(credential_id, request.models)
return RegisterModelsResponse(**result)
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error registering models for credential {credential_id}: {e}")
raise HTTPException(status_code=500, detail="Failed to register models")
View on GitHub (pinned to a7de90d38a)
Solutions
- Check logs for 'Error discovering models for credential <id>: ...'
- Test the credential's API key and base_url directly (curl the provider's /models endpoint)
- Verify network egress from the API host to the provider; fix proxy/DNS issues
- If the key is invalid, update the credential with a valid key before retrying discovery
Defensive patterns
Strategy: validation
Validate before calling
const cred = await api.getCredential(credentialId);
if (!cred || !cred.api_key) throw new Error('Credential needs a valid API key before discovery');
// optional: smoke-test connectivity
await fetch(cred.base_url ?? defaultBaseUrl(cred.provider) + '/models', { headers: { Authorization: `Bearer ${cred.api_key}` } }); Try / catch
try {
const models = await api.discoverModels(credentialId);
} catch (e) {
if (e.status === 500) showError('Discovery failed — check API key, base URL and network access');
throw e;
} Prevention
- Smoke-test the provider /models endpoint before running discovery in the UI
- Confirm network egress from the API host to providers in containerized setups
When it happens
Trigger: Clicking 'Discover models' for a credential whose provider endpoint is unreachable, an invalid/expired API key causing an unhandled client exception, or a provider returning an unexpected response shape the discovery parser cannot handle.
Common situations: Firewalled/offline environment blocking api.openai.com etc., revoked API key, or provider API response format change after a library update.
Related errors
- Failed to check environment status
- Failed to list credentials
- Failed to list credentials for provider
- Failed to create credential
- Failed to update credential
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/bbbf791e1d0e921f.
Report an issue: GitHub.