gemini

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package gemini implements llm.Generator with Google's official Gemini SDK.

It targets the Gemini Developer API. Vertex AI configuration is intentionally outside this package's current surface. Assistant messages may contain opaque ProviderData that preserves Gemini thought signatures and part ordering; callers should pass that data back unchanged with conversation history.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an immutable Gemini Developer API client. It is safe for concurrent use when its configured HTTP client is safe for concurrent use.

func New

func New(config Config) (_ *Client, err error)

New constructs a Client from config.

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, request llm.Request) (_ *llm.Response, err error)

Generate performs one non-streaming GenerateContent request.

func (*Client) Info

func (c *Client) Info() llm.ModelInfo

Info describes the configured model and its explicitly declared optional capabilities.

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, request llm.Request) (_ llm.Stream, err error)

Stream starts one streaming GenerateContent request. Provider and transport failures after validation are delivered by the returned stream.

type Config

type Config struct {
	Provider     string
	Model        string
	Capabilities []llm.Capability
	APIKey       string
	BaseURL      string
	APIVersion   string
	HTTPClient   *http.Client
	Headers      http.Header
}

Config configures a Gemini Developer API client. Model and APIKey are required. Provider identifies the service in ModelInfo and errors; it defaults to "gemini". BaseURL and APIVersion default to Google's public Gemini endpoint and v1beta API.

Capabilities opts the configured model into optional protocol features; generation is always enabled, while streaming, tools, JSON mode, vision, and audio input must be listed explicitly. A non-nil HTTPClient and custom Headers are used as supplied, without being mutated by Client. A nil HTTPClient uses http.DefaultClient, which has no overall request timeout; callers should use context deadlines or configure a client timeout.

Jump to

Keyboard shortcuts

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