Documentation
¶
Overview ¶
Package gemini implements models.Provider for the Gemini family, covering both the public Gemini API (API-key auth) and Vertex AI (Application Default Credentials + GCP project).
The two are exposed as distinct provider names ("gemini" and "vertex") so users and automation can pin to a backend explicitly. Both delegate to google.golang.org/adk/model/gemini under the hood.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuiltinTools ¶
type BuiltinTools struct {
GoogleSearch bool // Public web search grounding (default: on)
URLContext bool // Fetch + ground on URLs the model decides to visit (default: on)
CodeExecution bool // Sandboxed Python execution on Google's servers (default: off)
}
BuiltinTools toggles Gemini's server-side built-in tools surfaced by core-agent. Each enabled flag becomes its own *genai.Tool entry injected into the request's Config.Tools alongside any user-defined function declarations.
Defaults:
- GoogleSearch + URLContext are on (universally useful, no setup)
- CodeExecution is off (useful but a real action surface — opt in when you've decided sandboxed Python on Google's servers is acceptable for your security and cost posture)
To turn one off:
provider, _ := gemini.NewAPIKey(key, gemini.WithURLContext(false))
To turn CodeExecution on:
provider, _ := gemini.NewAPIKey(key, gemini.WithCodeExecution(true))
To replace the whole set:
provider, _ := gemini.NewAPIKey(key, gemini.WithBuiltinTools(gemini.BuiltinTools{
GoogleSearch: true, // URL context + CodeExecution off
}))
Other genai built-ins (FileSearch, GoogleMaps, ComputerUse, EnterpriseWebSearch, GoogleSearchRetrieval, Retrieval) aren't surfaced here. They require upstream setup (a corpus, a Maps API key, a hosted environment) or are Vertex-only — flipping them on without configuring the upstream resource yields an API error, not a working tool. Add them when an actual consumer needs them.
func DefaultBuiltinTools ¶
func DefaultBuiltinTools() BuiltinTools
DefaultBuiltinTools returns the on-by-default baseline applied to every Provider unless overridden via WithBuiltinTools or one of the per-tool helpers.
type Option ¶
type Option func(*Provider)
Option configures a Gemini Provider at construction time.
func WithBuiltinTools ¶
func WithBuiltinTools(b BuiltinTools) Option
WithBuiltinTools replaces the Provider's whole BuiltinTools set.
func WithCodeExecution ¶
WithCodeExecution toggles the CodeExecution built-in (sandboxed Python on Google's servers). Off by default.
func WithGoogleSearch ¶
WithGoogleSearch toggles the Google Search built-in.
func WithURLContext ¶
WithURLContext toggles the URL Context built-in.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the Gemini-family implementation of models.Provider.
func NewAPIKey ¶
NewAPIKey returns a Provider authenticated against the public Gemini API using key. Empty key is rejected so the failure mode is clear at startup.
Built-in tools (Google Search + URL Context) are enabled by default; pass WithBuiltinTools / WithGoogleSearch / WithURLContext to override.
func NewVertex ¶
NewVertex returns a Provider authenticated against Vertex AI for the given GCP project and location, using Application Default Credentials.
Built-in tools (Google Search + URL Context) are enabled by default; pass WithBuiltinTools / WithGoogleSearch / WithURLContext to override.