tonhowtf/omniget · error
Gemini
Error message
Gemini: {} What it means
In models()'s "gemini" branch, error_for_status() failures on GET {base_url}/models are wrapped as "Gemini: {}". The Gemini API returned a non-2xx response — usually because the key query parameter is invalid or the base_url is not a Gemini-compatible endpoint.
Solutions
- Check the wrapped status: 400/403 means fix the Gemini API key in Google AI Studio
- Verify entry.base_url points at the Gemini API root (e.g. https://generativelanguage.googleapis.com/v1beta)
- Ensure the key has the Generative Language API enabled and no referrer restrictions
- Retry after delay on 429 quota errors
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight before models():
let resp = client.get(format!("{}/models?key={}", entry.base_url, entry.key)).send().await?;
if !resp.status().is_success() { bail!("Gemini key/base_url invalido: {}", resp.status()); } Try / catch
match models(entry).await {
Err(e) if e.to_string().starts_with("Gemini:") => {
if e.to_string().contains("429") { schedule_retry(); } else { prompt_reenter_key(); }
}
other => handle(other),
} Prevention
- Verify the key is a Gemini (Generative Language API) key, not another provider's
- Use the v1beta base URL and confirm the API is enabled for the key's project
- Back off on 429 quota errors and surface status codes to the user
When it happens
Trigger: Calling models/test for a gemini entry with a revoked/typo'd key (key= query param), wrong base_url, or API quota/billing errors (429/403).
Common situations: User saved an OpenAI key under provider "gemini"; Gemini API key restricted by referrer/API restrictions in Google Cloud console; deprecated v1base_url vs v1beta model availability.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Anthropic
- YouTube não retornou URL
- HTTP
- Twitch GQL respondeu HTTP
- Server returned HTML instead of media — the link may have…
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/9fd94039ba3bc9ca.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/ai_keys.rs:343
c.get(format!("{}/models?limit=1000", entry.base_url))
.header("x-api-key", &entry.key)
.header("anthropic-version", "2023-06-01")
.send()
.await?
.error_for_status()
.map_err(|e| anyhow!("Anthropic: {}", e))?
.json()
.await?
}
"gemini" => {
c.get(format!(
"{}/models?pageSize=1000&key={}",
entry.base_url, entry.key
))
.send()
.await?
.error_for_status()
.map_err(|e| anyhow!("Gemini: {}", e))?
.json()
.await?
}
_ => {
let mut req = c.get(format!("{}/models", entry.base_url));
if !entry.key.is_empty() {
req = req.bearer_auth(&entry.key);
}
let resp = req.send().await?;
let status = resp.status();
let text = resp.text().await.unwrap_or_default();
if !status.is_success() {
return Err(anyhow!(
"HTTP {}: {}",
status.as_u16(),
text.chars().take(200).collect::<String>()
));
}View on GitHub (pinned to 8600b91f42)