vertexai

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package vertexai exposes Google Gen AI capabilities through Vertex AI's GCP backend and Application Default Credentials.

Chat, transcription, speech, and text embedding share the official Google Gen AI SDK protocol mappers with package google while supplying genai.BackendVertexAI, project, and location. Image generation has its own adapter because the current Vertex contract is GenerateContent with Gemini image models, whereas the public Gemini Developer API now recommends the Interactions API. Treating those two transports as interchangeable would leak backend details and preserve deprecated Imagen behavior.

API keys are not used. Authenticate locally with Application Default Credentials or provide an authenticated HTTP client; production workloads normally use a service account or Workload Identity.

Model availability and regions change independently on Vertex AI. Select an explicit model id and location from the current Vertex model documentation.

See https://cloud.google.com/vertex-ai/generative-ai/docs.

Index

Constants

View Source
const (
	Provider = "VertexAI"

	RequestExtensionKey               = "vertexai/request"
	ResponseExtensionKey              = "vertexai/response"
	SpeechRequestExtensionKey         = "vertexai/speech_request"
	SpeechResponseExtensionKey        = "vertexai/speech_response"
	TranscriptionRequestExtensionKey  = "vertexai/transcription_request"
	TranscriptionResponseExtensionKey = "vertexai/transcription_response"
	EmbeddingRequestExtensionKey      = "vertexai/embedding_request"
	EmbeddingResponseExtensionKey     = "vertexai/embedding_response"
	ImageRequestExtensionKey          = "vertexai/image_request"
	ImageResponseExtensionKey         = "vertexai/image_response"

	ModelGemini25FlashImage = "gemini-2.5-flash-image"
	ModelGemini3ProImage    = "gemini-3-pro-image"
)
View Source
const (
	// LocationUSCentral1 is the global default for most generative
	// models (Gemini, Imagen, embedding).
	LocationUSCentral1 = "us-central1"

	// LocationGlobal is the multi-region endpoint — useful for
	// latency-sensitive workloads that can tolerate Google's
	// internal routing.
	LocationGlobal = "global"

	// LocationEuropeWest4 hosts Gemini and Imagen in the EU.
	LocationEuropeWest4 = "europe-west4"

	// LocationAsiaSoutheast1 (Singapore) hosts Gemini in APAC.
	LocationAsiaSoutheast1 = "asia-southeast1"

	// LocationAsiaNortheast1 (Tokyo) hosts Gemini in Japan.
	LocationAsiaNortheast1 = "asia-northeast1"
)

Common Vertex AI regions. See https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations for the full list — coverage varies by model.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioTTSModel

type AudioTTSModel protocol.AudioTTSModel

func NewAudioTTSModel

func NewAudioTTSModel(config AudioTTSModelConfig) (*AudioTTSModel, error)

func (*AudioTTSModel) Call

func (a *AudioTTSModel) Call(ctx context.Context, req *tts.Request) (*tts.Response, error)

func (*AudioTTSModel) Stream

func (a *AudioTTSModel) Stream(ctx context.Context, req *tts.Request) iter.Seq2[*tts.Response, error]

type AudioTTSModelConfig

type AudioTTSModelConfig struct {
	Client         ClientConfig
	DefaultOptions tts.Options
}

func (AudioTTSModelConfig) Validate

func (a AudioTTSModelConfig) Validate() error

type AudioTranscriptionModel

type AudioTranscriptionModel = callModel[transcription.Request, transcription.Response]

type AudioTranscriptionModelConfig

type AudioTranscriptionModelConfig struct {
	Client         ClientConfig
	DefaultOptions transcription.Options
}

func (AudioTranscriptionModelConfig) Validate

func (a AudioTranscriptionModelConfig) Validate() error

type Chat

type Chat protocol.Chat

func NewChat

func NewChat(config ChatConfig) (*Chat, error)

func (*Chat) Call

func (c *Chat) Call(ctx context.Context, req *corechat.Request) (*corechat.Response, error)

func (*Chat) Stream

type ChatConfig

type ChatConfig struct {
	Client         ClientConfig
	DefaultOptions corechat.Options
}

func (ChatConfig) Validate

func (c ChatConfig) Validate() error

type ClientConfig

type ClientConfig struct {
	Project    string
	Location   string
	BaseURL    string
	HTTPClient *http.Client
}

ClientConfig identifies the Vertex AI project endpoint shared by every modality. HTTPClient remains caller-owned and is never closed by a model; BaseURL is reserved for compatible gateways and test servers.

func (ClientConfig) Validate

func (c ClientConfig) Validate() error

type EmbeddingModel

type EmbeddingModel = callModel[embedding.Request, embedding.Response]

func NewEmbeddingModel

func NewEmbeddingModel(config EmbeddingModelConfig) (*EmbeddingModel, error)

type EmbeddingModelConfig

type EmbeddingModelConfig struct {
	Client         ClientConfig
	DefaultOptions embedding.Options
}

func (EmbeddingModelConfig) Validate

func (e EmbeddingModelConfig) Validate() error

type ImageGenerationOptions

type ImageGenerationOptions struct {
	InputImages              []*media.Media `json:"input_images,omitempty"`
	AspectRatio              string         `json:"aspect_ratio,omitempty"`
	ImageSize                string         `json:"image_size,omitempty"`
	PersonGeneration         string         `json:"person_generation,omitempty"`
	ProminentPeople          string         `json:"prominent_people,omitempty"`
	OutputCompressionQuality *int32         `json:"output_compression_quality,omitempty"`
}

ImageGenerationOptions carries Vertex-specific GenerateContent controls and optional source images for editing. Store it under ImageRequestExtensionKey.

type ImageModel

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

ImageModel implements Gemini native image generation on Vertex AI through GenerateContent. It intentionally does not expose Imagen's Predict endpoint: Google deprecated the Imagen GA endpoints in favor of Gemini image models.

func NewImageModel

func NewImageModel(config ImageModelConfig) (*ImageModel, error)

func (*ImageModel) Call

func (i *ImageModel) Call(ctx context.Context, req *image.Request) (*image.Response, error)

type ImageModelConfig

type ImageModelConfig struct {
	Client         ClientConfig
	DefaultOptions image.Options
}

func (ImageModelConfig) Validate

func (i ImageModelConfig) Validate() error

Jump to

Keyboard shortcuts

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