{"record":{"id":"9fd94039ba3bc9ca","repo":"tonhowtf/omniget","slug":"gemini","errorCode":null,"errorMessage":"Gemini: {}","messagePattern":"Gemini: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/ai_keys.rs","lineNumber":343,"sourceCode":"            c.get(format!(\"{}/models?limit=1000\", entry.base_url))\n                .header(\"x-api-key\", &entry.key)\n                .header(\"anthropic-version\", \"2023-06-01\")\n                .send()\n                .await?\n                .error_for_status()\n                .map_err(|e| anyhow!(\"Anthropic: {}\", e))?\n                .json()\n                .await?\n        }\n        \"gemini\" => {\n            c.get(format!(\n                \"{}/models?pageSize=1000&key={}\",\n                entry.base_url, entry.key\n            ))\n            .send()\n            .await?\n            .error_for_status()\n            .map_err(|e| anyhow!(\"Gemini: {}\", e))?\n            .json()\n            .await?\n        }\n        _ => {\n            let mut req = c.get(format!(\"{}/models\", entry.base_url));\n            if !entry.key.is_empty() {\n                req = req.bearer_auth(&entry.key);\n            }\n            let resp = req.send().await?;\n            let status = resp.status();\n            let text = resp.text().await.unwrap_or_default();\n            if !status.is_success() {\n                return Err(anyhow!(\n                    \"HTTP {}: {}\",\n                    status.as_u16(),\n                    text.chars().take(200).collect::<String>()\n                ));\n            }","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/ai_keys.rs#L325-L361","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight before models():\nlet resp = client.get(format!(\"{}/models?key={}\", entry.base_url, entry.key)).send().await?;\nif !resp.status().is_success() { bail!(\"Gemini key/base_url invalido: {}\", resp.status()); }","typeGuard":null,"tryCatchPattern":"match models(entry).await {\n    Err(e) if e.to_string().starts_with(\"Gemini:\") => {\n        if e.to_string().contains(\"429\") { schedule_retry(); } else { prompt_reenter_key(); }\n    }\n    other => handle(other),\n}","preventionTips":["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"],"tags":["http","api","gemini","authentication"],"backgroundTag":"http-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}