gemini

package
v1.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Package gemini connects to the Gemini API.

Index

Constants

View Source
const (
	ProviderOptionSafetySettings   = "safetySettings"
	ProviderOptionGenerationConfig = "generationConfig"
	ProviderOptionToolConfig       = "toolConfig"
	ProviderOptionCachedContent    = "cachedContent"
)

ProviderOptions are native request fields copied into the body. An option naming a generated object is merged into it, e.g. {"topK": 40} under "generationConfig". Gemini's built-in tools are not offered: their output parts have no block to land in.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name, when set, names the provider instead of "gemini", as a
	// compatible endpoint should: provider state and errors carry it.
	Name string
	// APIKey authenticates requests; APIKeyFunc, when set, resolves it per
	// request instead.
	APIKey     string
	APIKeyFunc func(context.Context) (string, error)
	// BaseURL is the API origin, https://generativelanguage.googleapis.com by
	// default.
	BaseURL string
	// HTTPClient sends requests; nil uses http.DefaultClient. Wrap it with
	// retry.NewHTTPClient to retry.
	HTTPClient litellm.HTTPClient
	UserAgent  string
	// Headers are set after the defaults, so they can override them.
	Headers map[string]string
}

Config configures the Gemini API client. An API key is required.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements litellm.Provider and litellm.CapabilityProvider.

func New

func New(cfg Config) (*Provider, error)

New returns a Provider for cfg.

func (*Provider) Capabilities added in v1.8.1

func (p *Provider) Capabilities() litellm.Capabilities

Capabilities reports the static protocol facts.

func (*Provider) Chat

func (p *Provider) Chat(ctx context.Context, req *litellm.Request) (*litellm.Response, error)

Chat sends a generateContent request.

func (*Provider) ListModels

func (p *Provider) ListModels(ctx context.Context) ([]litellm.ModelInfo, error)

ListModels lists the models of GET /v1beta/models that generate content. The vendor has far fewer than the 1000 one page holds.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the configured name.

func (*Provider) Stream

func (p *Provider) Stream(ctx context.Context, req *litellm.Request) (litellm.Stream, error)

Stream sends a streamGenerateContent request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL