tonhowtf/omniget · error

o chat do OmniGet fala OpenAI/Anthropic; use a rota…

Error message

o chat do OmniGet fala OpenAI/Anthropic; use a rota OpenAI-compatível do Gemini (…/v1beta/openai) como personalizado

What it means

use_in_app() applies a stored key as the app's AI backend; it only maps 'openai', 'anthropic' and a default local/custom kind. The 'gemini' kind is explicitly rejected with a message explaining that OmniGet chat only speaks OpenAI/Anthropic protocols and directing the user to Gemini's OpenAI-compatible route (…/v1beta/openai) configured as a custom provider instead.

Solutions

  1. Instead of use_in_app, add the Gemini key as a custom provider whose base_url is https://generativelanguage.googleapis.com/v1beta/openai and then use it as local/custom.
  2. Set the model name to a Gemini model (e.g. gemini-2.0-flash) on that custom entry.
  3. Change the entry's provider kind from 'gemini' to a custom kind pointing at the OpenAI-compatible endpoint, then call use_in_app.

Example fix

// before
{ "kind": "gemini", "base_url": "https://generativelanguage.googleapis.com" }
// after
{ "kind": "custom", "base_url": "https://generativelanguage.googleapis.com/v1beta/openai", "model": "gemini-2.0-flash" }
Defensive patterns

Strategy: validation

Validate before calling

let entry = get(id)?;
if entry.kind == "gemini" {
    eprintln!("configure Gemini via its OpenAI-compatible route: https://generativelanguage.googleapis.com/v1beta/openai");
    return;
}

Type guard

fn usable_in_app(e: &KeyEntry) -> bool { e.kind != "gemini" }

Try / catch

match use_in_app(id) {
    Ok(()) => show("AI provider applied"),
    Err(e) if e.to_string().contains("v1beta/openai") => {
        show_gemini_compat_instructions();
    }
    Err(e) => show_error(e),
}

Prevention

When it happens

Trigger: Calling use_in_app(id) on a key entry whose provider kind is 'gemini'. Always thrown for gemini entries regardless of key validity.

Common situations: User stores a Google AI Studio Gemini key and clicks 'use in app'; apps built before the OpenAI-compat route existed; users unaware Gemini offers an OpenAI-compatible endpoint.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/27cc3026244eb04a. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/ai_keys.rs:635

            }
            serde_json::to_string_pretty(&serde_json::json!({ "$schema": "https://opencode.ai/config.json", "provider": providers }))?
        }
        _ => return Err(anyhow!("formato desconhecido: {}", format)),
    })
}

/// Usa esta chave como a IA do OmniGet (Ajustes → IA).
pub fn use_in_app(id: &str) -> anyhow::Result<()> {
    let e = get(id)?;
    use crate::core::ai::{self, AiProvider};
    match e.kind.as_str() {
        "openai" => {
            ai::set(AiProvider::Openai, e.model.clone(), String::new(), Some(e.key.clone()), None);
        }
        "anthropic" => {
            ai::set(AiProvider::Anthropic, e.model.clone(), String::new(), None, Some(e.key.clone()));
        }
        "gemini" => return Err(anyhow!("o chat do OmniGet fala OpenAI/Anthropic; use a rota OpenAI-compatível do Gemini (…/v1beta/openai) como personalizado")),
        _ => {
            ai::set(AiProvider::Local, e.model.clone(), e.base_url.clone(), Some(e.key.clone()), None);
        }
    }
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn hints() {
        assert_eq!(hint(""), "");
        assert_eq!(hint("abc"), "•••");
        assert_eq!(hint("sk-1234567890abcd"), "sk-1…abcd");
        assert_eq!(site_of("https://x.com/v1/"), "https://x.com");
        assert_eq!(site_of("https://x.com"), "https://x.com");

View on GitHub (pinned to 8600b91f42)