This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/backend/gemini.go

30 lines
842 B
Go

package backend
import "os"
const (
geminiBaseURL = "https://generativelanguage.googleapis.com/v1beta/openai/"
geminiDefaultModel = "gemini-2.5-flash-preview-05-20"
)
// NewGemini constructs an OpenAI-compatible backend pointed at Google AI Studio.
// apiKey is the Google AI Studio key (OLLIE_GEMINI_KEY).
// If model is empty the default model is used.
func NewGemini(apiKey string) (*OpenAIBackend, error) {
b, err := NewOpenAI("gemini", geminiBaseURL, apiKey)
if err != nil {
return nil, err
}
b.model = geminiDefaultModel
return b, nil
}
// geminiKey returns the API key from OLLIE_GEMINI_KEY, falling back to
// OLLIE_OPENAI_KEY so existing env files that set the generic key still work.
func geminiKey() string {
if k := os.Getenv("OLLIE_GEMINI_KEY"); k != "" {
return k
}
return os.Getenv("OLLIE_OPENAI_KEY")
}