Documentation
¶
Overview ¶
Package gemini implements the llmrouter.Provider interface for Google Gemini models using the official Google Generative AI Go SDK.
Gemini requires a context during initialisation:
p, err := gemini.NewFromEnv(ctx) // reads GEMINI_API_KEY
Or with an explicit key:
p, err := gemini.New(ctx, gemini.Config{APIKey: "..."})
Supported models include gemini-2.0-flash, gemini-1.5-pro, and gemini-1.5-flash. The provider supports streaming, tool calling, and multimodal inputs (text + images + documents).
Index ¶
- Variables
- type Provider
- func (p *Provider) Close() error
- func (p *Provider) Complete(ctx context.Context, req *llmrouter.Request) (*llmrouter.Response, error)
- func (p *Provider) Models() []string
- func (p *Provider) Name() string
- func (p *Provider) Stream(ctx context.Context, req *llmrouter.Request) (*llmrouter.StreamResult, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultModels = []string{
"gemini-1.5-pro",
"gemini-1.5-flash",
"gemini-2.0-flash-exp",
"gemini-1.0-pro",
}
DefaultModels is the list of available Gemini models
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider handles Google Gemini API
func New ¶
func New(cfg llmrouter.ProviderConfig) (*Provider, error)
New creates a new Gemini provider. The Gemini SDK requires a context for client construction; context.Background() is used internally so the provider lifetime is not tied to a caller's context.
func NewFromEnv ¶
NewFromEnv creates a provider using the GEMINI_API_KEY environment variable