google

package
v0.63.8 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 14 Imported by: 2

Documentation

Overview

ABOUTME: Google Gemini API adapter implementing the ProviderAdapter interface. ABOUTME: Handles HTTP communication, SSE stream parsing, and request/response lifecycle.

ABOUTME: Request/response translation between the unified llm types and Google Gemini API format. ABOUTME: Handles systemInstruction extraction, model role mapping, synthetic tool call IDs, and finish reasons.

ABOUTME: Translates Gemini usageMetadata into the unified llm.Usage shape. ABOUTME: Thinking sits outside the candidate count; cached content sits inside the prompt count.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements llm.ProviderAdapter for the Google Gemini API.

func New

func New(apiKey string, opts ...Option) *Adapter

New creates a new Gemini adapter with the given API key and options.

func (*Adapter) Close

func (a *Adapter) Close() error

Close releases resources held by the adapter.

func (*Adapter) Complete

func (a *Adapter) Complete(ctx context.Context, req *llm.Request) (*llm.Response, error)

Complete sends a synchronous request to the Gemini API.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the provider identifier.

func (*Adapter) Stream

func (a *Adapter) Stream(ctx context.Context, req *llm.Request) <-chan llm.StreamEvent

Stream sends a streaming request and returns a channel of events.

type Option

type Option func(*Adapter)

Option configures an Adapter.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL overrides the default Gemini API base URL.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient provides a custom http.Client.

Jump to

Keyboard shortcuts

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