gemini

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package gemini provides a Google Gemini API client implementing the ai.Provider interface. It supports both AI Studio (API key) and Vertex AI (ADC) authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthType

type AuthType string

AuthType indicates the authentication method.

const (
	// AuthAPIKey uses API key authentication (AI Studio).
	AuthAPIKey AuthType = "apikey"

	// AuthADC uses Application Default Credentials (Vertex AI).
	AuthADC AuthType = "adc"
)

type Client

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

Client implements ai.Provider for Google's Gemini API. It supports both AI Studio and Vertex AI endpoints.

func NewClient

func NewClient(apiKey string, opts ...ClientOption) *Client

NewClient creates a new Gemini client using API key (AI Studio).

func NewVertexAIClient

func NewVertexAIClient(projectID string, opts ...ClientOption) (*Client, error)

NewVertexAIClient creates a new Gemini client using ADC (Vertex AI). If projectID is empty, it will be fetched from gcloud config.

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, req *ai.Request) (*ai.Response, error)

Generate implements ai.Provider.

func (*Client) Name

func (c *Client) Name() string

Name implements ai.Provider.

func (*Client) NewHandler

func (c *Client) NewHandler(model string, opts ...ai.HandlerOption) *ai.Handler

NewHandler creates an ai.Handler wrapping this client.

type ClientOption

type ClientOption func(*Client)

ClientOption configures a Client.

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL sets a custom base URL (useful for testing).

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient sets a custom HTTP client.

func WithLocation

func WithLocation(location string) ClientOption

WithLocation sets the GCP location for Vertex AI.

Jump to

Keyboard shortcuts

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