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: 6 Imported by: 0

Documentation

Overview

Package gemini implements the Google Gemini generateContent backend connector using google.golang.org/genai. It maps lipapi.Call to streamGenerateContent (?alt=sse) and emits canonical events from streamed [genai.GenerateContentResponse] chunks.

BaseURL must be the API origin only (for example https://generativelanguage.googleapis.com), without a model path suffix; the SDK constructs /v1beta/models/{model}:streamGenerateContent.

Model resolution uses the route candidate when present, otherwise the JSON string stored under the gemini.model extension key (same key as the Gemini frontend decoder).

Index

Constants

View Source
const DefaultBaseURL = "https://generativelanguage.googleapis.com"
View Source
const ID = "gemini"

ID is the reserved plugin identifier for the Gemini backend.

Variables

This section is empty.

Functions

func ModelCapabilities

func ModelCapabilities(model string) lipapi.BackendCaps

ModelCapabilities returns negotiated backend caps for a resolved Gemini model id.

func New

func New(cfg Config) execbackend.Backend

New returns a runtime backend that invokes Gemini generateContent streaming via google.golang.org/genai.

Types

type Config

type Config struct {
	BaseURL string
	APIKey  string
	// APIKeys is the ordered credential list for this backend instance.
	// When non-empty, APIKey should match APIKeys[0] for SDK compatibility.
	APIKeys []string
	// Credentials is the structured credential list. When set, it takes precedence
	// over APIKey/APIKeys and preserves non-secret credential IDs for diagnostics.
	Credentials []credpool.Credential
	// HTTPClient is optional; when nil the SDK default is used.
	HTTPClient *http.Client
}

Config configures the Gemini generateContent backend connector (official genai SDK). BaseURL is the API origin (e.g. https://generativelanguage.googleapis.com) without a path suffix; the SDK appends /v1beta/models/... for Google AI backend.

google.golang.org/genai does not apply the same automatic multi-attempt retries on generateContent/streamGenerateContent as openai-go and anthropic-sdk-go; credential tests can count httptest invocations without an SDKMaxRetries-style knob.

Jump to

Keyboard shortcuts

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