gemini

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package gemini is a reference client emulator for the Google Gemini generateContent API, built on google.golang.org/genai.

Unlike openai-go and anthropic-sdk-go, the genai client's generateContent and streamGenerateContent paths issue a single HTTP round-trip per call (no built-in exponential retry on 429 for these RPCs). Credential tests can rely on one upstream hit when using refbackend ForcedHTTPStatus 429; see server tests in internal/refbackend/gemini.

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 wraps genai.Client for scriptable generateContent calls.

func New

func New(ctx context.Context, cfg Config) (*Client, error)

New builds a Gemini API reference client (BackendGeminiAPI).

func (*Client) GenerateContent

func (c *Client) GenerateContent(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)

GenerateContent calls the non-streaming generateContent RPC.

func (*Client) GenerateContentStream

func (c *Client) GenerateContentStream(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) iter.Seq2[*genai.GenerateContentResponse, error]

GenerateContentStream calls streamGenerateContent (?alt=sse).

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

Config configures the official GenAI Go client for the Gemini (Google AI) backend.

Jump to

Keyboard shortcuts

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