google

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package google implements Gemini Live realtime sessions with the official Google Gen AI Go SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

Connection adapts one official SDK live session.

func (*Connection) AnswersToolCallsPerResponse added in v0.5.0

func (connection *Connection) AnswersToolCallsPerResponse() bool

AnswersToolCallsPerResponse reports that blocking tool results share one reply.

func (*Connection) CanReconnect added in v0.5.0

func (connection *Connection) CanReconnect() bool

CanReconnect reports whether another transport recovery is available.

func (*Connection) Close

func (connection *Connection) Close(context.Context) error

Close closes the official SDK session once.

func (*Connection) Events

func (connection *Connection) Events(ctx context.Context) iter.Seq2[realtime.CodecEvent, error]

func (*Connection) InputTranscriptionEnabled

func (connection *Connection) InputTranscriptionEnabled() bool

InputTranscriptionEnabled reports configured native transcription.

func (*Connection) IsReconnecting added in v0.5.0

func (connection *Connection) IsReconnecting() bool

IsReconnecting reports that the current transport is being replaced.

func (*Connection) ModelName

func (connection *Connection) ModelName() string

ModelName returns the requested model because Gemini Live does not report a replacement.

func (*Connection) ReconnectRestoresInFlightState

func (*Connection) ReconnectRestoresInFlightState() bool

ReconnectRestoresInFlightState reports Gemini's native session behavior.

func (*Connection) Send

func (connection *Connection) Send(ctx context.Context, input realtime.Input) error

Send writes one normalized input through the official SDK.

type Connector

type Connector interface {
	Connect(ctx context.Context, model string, config *genai.LiveConnectConfig) (LiveSession, error)
}

Connector opens official SDK live sessions.

type LiveSession

type LiveSession interface {
	SendClientContent(input genai.LiveClientContentInput) error
	SendRealtimeInput(input genai.LiveRealtimeInput) error
	SendToolResponse(input genai.LiveToolResponseInput) error
	Receive() (*genai.LiveServerMessage, error)
	Close() error
}

LiveSession is the official SDK session surface used by Connection.

type Model

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

Model opens Gemini Live sessions.

func NewModel

func NewModel(name string, options ...Option) *Model

NewModel creates a Gemini Live model.

func (*Model) Connect

func (model *Model) Connect(ctx context.Context, params realtime.ConnectParams) (realtime.Connection, error)

Connect opens and configures a Gemini Live session.

func (*Model) Name

func (model *Model) Name() string

Name returns the requested Gemini Live model name.

func (*Model) Profile

func (model *Model) Profile() realtime.Profile

Profile returns detached realtime capabilities.

func (*Model) ProviderName

func (model *Model) ProviderName() string

ProviderName returns the durable provider identity.

type Option

type Option func(*Model)

Option configures a Model.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets a Gemini Developer API key instead of reading GOOGLE_API_KEY or GEMINI_API_KEY.

func WithAPIVersion added in v0.5.0

func WithAPIVersion(version string) Option

WithAPIVersion selects the Google API version. Gemini Developer API proactive audio requires v1alpha. The default is v1beta.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets a custom official SDK endpoint.

func WithClient

func WithClient(client *genai.Client) Option

WithClient uses an existing official Google Gen AI client.

func WithConnector

func WithConnector(connector Connector) Option

WithConnector injects an official-SDK-compatible live connector.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient selects the client used by the official SDK.

func WithProfile

func WithProfile(override realtime.ProfileOverride) Option

WithProfile applies a partial profile override.

func WithSettings

func WithSettings(settings Settings) Option

WithSettings adds model-level Gemini Live defaults.

func WithVertex

func WithVertex(project, location string) Option

WithVertex selects Vertex AI and its project and location.

type Settings

type Settings struct {
	// Temperature controls response randomness.
	Temperature *float32
	// TopP controls nucleus sampling.
	TopP *float32
	// TopK limits the candidate tokens considered at each step.
	TopK *float32
	// Seed requests best-effort deterministic sampling.
	Seed *int32
	// Voice selects a Gemini prebuilt voice.
	Voice string
	// LanguageCode is the BCP 47 speech output language.
	LanguageCode string
	// InputTranscription enables native user speech transcription.
	InputTranscription *bool
	// OutputTranscription enables model speech transcription.
	OutputTranscription *bool
	// AffectiveDialog enables emotion-aware delivery where supported.
	AffectiveDialog *bool
	// ProactiveAudio allows the model to decide whether input needs a response.
	ProactiveAudio *bool
	// AsyncToolCalls keeps supported native-audio generation active while tools run.
	AsyncToolCalls bool
	// EnableSessionResumption explicitly controls provider resume handles.
	EnableSessionResumption *bool
	// ConfigOverrides applies advanced official SDK configuration last.
	ConfigOverrides func(*genai.LiveConnectConfig)
}

Settings configures Gemini Live-specific generation, speech, and session behavior.

Jump to

Keyboard shortcuts

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