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.
Constructors take a context because construction reaches the network. On the Vertex AI backend with application default credentials, building the client resolves them and then asks the resolved credential for its quota project, which is a metadata-server call the context governs — so a caller can bound or cancel its own wiring instead of a background context deciding for it.
Index ¶
Constants ¶
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" )
Exported identifiers keep provider-owned names and defaults out of caller literals.
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
AudioTTSModel wraps this provider's protocol implementation so the wire type stays unexported. Callers depend on the Core modality contract, which lets the protocol change without breaking this module's public surface.
func NewAudioTTSModel ¶
func NewAudioTTSModel(ctx context.Context, config AudioTTSModelConfig) (*AudioTTSModel, error)
NewAudioTTSModel rejects an invalid provider binding before the first speech call.
type AudioTTSModelConfig ¶
type AudioTTSModelConfig struct {
Client ClientConfig
DefaultOptions tts.Options
}
AudioTTSModelConfig binds provider access and defaults shared by every speech call.
func (AudioTTSModelConfig) Validate ¶
func (a AudioTTSModelConfig) Validate() error
type AudioTranscriptionModel ¶
type AudioTranscriptionModel = callModel[transcription.Request, transcription.Response]
AudioTranscriptionModel is the shared protocol type itself rather than a wrapper, so this provider adds no second public surface for callers to choose between.
func NewAudioTranscriptionModel ¶
func NewAudioTranscriptionModel(ctx context.Context, config AudioTranscriptionModelConfig) (*AudioTranscriptionModel, error)
NewAudioTranscriptionModel rejects an invalid provider binding before the first transcription call.
type AudioTranscriptionModelConfig ¶
type AudioTranscriptionModelConfig struct {
Client ClientConfig
DefaultOptions transcription.Options
}
AudioTranscriptionModelConfig binds provider access and defaults shared by every transcription call.
func (AudioTranscriptionModelConfig) Validate ¶
func (a AudioTranscriptionModelConfig) Validate() error
type Chat ¶
Chat wraps this provider's protocol implementation so the wire type stays unexported. Callers depend on the Core modality contract, which lets the protocol change without breaking this module's public surface.
func NewChat ¶
func NewChat(ctx context.Context, config ChatConfig) (*Chat, error)
NewChat rejects an invalid provider binding before the first chat call.
type ChatConfig ¶
type ChatConfig struct {
Client ClientConfig
DefaultOptions corechat.Options
}
ChatConfig binds provider access and defaults shared by every chat call.
func (ChatConfig) Validate ¶
func (c ChatConfig) Validate() error
type ClientConfig ¶
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 ¶
EmbeddingModel is the shared protocol type itself rather than a wrapper, so this provider adds no second public surface for callers to choose between.
func NewEmbeddingModel ¶
func NewEmbeddingModel(ctx context.Context, config EmbeddingModelConfig) (*EmbeddingModel, error)
NewEmbeddingModel rejects an invalid provider binding before the first embedding call.
type EmbeddingModelConfig ¶
type EmbeddingModelConfig struct {
Client ClientConfig
DefaultOptions embedding.Options
}
EmbeddingModelConfig binds provider access and defaults shared by every embedding call.
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(ctx context.Context, config ImageModelConfig) (*ImageModel, error)
NewImageModel rejects an invalid provider binding before the first image call.
type ImageModelConfig ¶
type ImageModelConfig struct {
Client ClientConfig
DefaultOptions image.Options
}
ImageModelConfig binds provider access and defaults shared by every image call.
func (ImageModelConfig) Validate ¶
func (i ImageModelConfig) Validate() error