Documentation
¶
Overview ¶
Package google exposes native Gemini chat, embedding, image, speech, transcription, and token-estimation adapters. NewChatCompletions targets Gemini's OpenAI-compatible chat endpoint. Native chat maps a natural stop with function calls to Core tool_calls while preserving interrupted and invalid-call outcomes and the native finish reason.
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. NewChatCompletions is the exception: it builds an OpenAI-compatible client and performs no I/O.
Index ¶
- Constants
- type AudioTTSModel
- type AudioTTSModelConfig
- type AudioTranscriptionModel
- type AudioTranscriptionModelConfig
- type Chat
- type ChatCompletions
- type ChatCompletionsConfig
- type ChatConfig
- type EmbeddingModel
- type EmbeddingModelConfig
- type ImageGenerationOptions
- type ImageGoogleSearchOptions
- type ImageModel
- type ImageModelConfig
- type ImageSafetySetting
- type TextCounter
- type TextCounterConfig
Constants ¶
const ( Provider = "Google" DefaultBaseURL = protocol.DefaultBaseURL BaseURLOpenAI = "https://generativelanguage.googleapis.com/v1beta/openai" RequestExtensionKey = "google/request" ResponseExtensionKey = "google/response" SpeechRequestExtensionKey = "google/speech_request" SpeechResponseExtensionKey = "google/speech_response" TranscriptionRequestExtensionKey = "google/transcription_request" TranscriptionResponseExtensionKey = "google/transcription_response" EmbeddingRequestExtensionKey = "google/embedding_request" EmbeddingResponseExtensionKey = "google/embedding_response" ImageRequestExtensionKey = "google/image_request" ImageResponseExtensionKey = "google/image_response" OpenAIRequestExtensionKey = "google/openai_request" OpenAIResponseExtensionKey = "google/openai_response" OpenAIStreamChunkExtensionKey = "google/openai_stream_chunk" ModelGemini36Flash = protocol.ModelGemini36Flash ModelGemini35Flash = protocol.ModelGemini35Flash ModelGemini35FlashLite = protocol.ModelGemini35FlashLite ModelGemini31ProPreview = protocol.ModelGemini31ProPreview ModelGemini25FlashPreviewTTS = protocol.ModelGemini25FlashPreviewTTS ModelGemini25ProPreviewTTS = protocol.ModelGemini25ProPreviewTTS ModelGemini31FlashTTSPreview = protocol.ModelGemini31FlashTTSPreview ModelGemini25FlashImage = protocol.ModelGemini25FlashImage ModelGemini3ProImage = protocol.ModelGemini3ProImage ModelGemini31FlashImage = protocol.ModelGemini31FlashImage ModelGemini31FlashLiteImage = protocol.ModelGemini31FlashLiteImage ModelGeminiEmbedding2 = protocol.ModelGeminiEmbedding2 )
Exported identifiers keep provider-owned names and defaults out of caller literals.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioTTSModel ¶
type AudioTTSModel struct {
// contains filtered or unexported fields
}
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 {
APIKey string
DefaultOptions tts.Options
BaseURL string
HTTPClient *http.Client
}
AudioTTSModelConfig binds provider access and defaults shared by every speech call.
func (AudioTTSModelConfig) Validate ¶
func (a AudioTTSModelConfig) Validate() error
type AudioTranscriptionModel ¶
type AudioTranscriptionModel struct {
// contains filtered or unexported fields
}
AudioTranscriptionModel 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 NewAudioTranscriptionModel ¶
func NewAudioTranscriptionModel(ctx context.Context, config AudioTranscriptionModelConfig) (*AudioTranscriptionModel, error)
NewAudioTranscriptionModel rejects an invalid provider binding before the first transcription call.
func (*AudioTranscriptionModel) Call ¶
func (a *AudioTranscriptionModel) Call(ctx context.Context, req *transcription.Request) (*transcription.Response, error)
type AudioTranscriptionModelConfig ¶
type AudioTranscriptionModelConfig struct {
APIKey string
DefaultOptions transcription.Options
BaseURL string
HTTPClient *http.Client
}
AudioTranscriptionModelConfig binds provider access and defaults shared by every transcription call.
func (AudioTranscriptionModelConfig) Validate ¶
func (a AudioTranscriptionModelConfig) Validate() error
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
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 ChatCompletions ¶ added in v0.13.0
type ChatCompletions = openaiprotocol.ChatCompletions
ChatCompletions is Google's OpenAI-compatible protocol model. It is a distinct endpoint from the native Gemini protocol exposed by Chat.
func NewChatCompletions ¶ added in v0.13.0
func NewChatCompletions(ctx context.Context, config ChatCompletionsConfig) (*ChatCompletions, error)
NewChatCompletions rejects an invalid provider binding before the first Chat Completions call.
type ChatCompletionsConfig ¶ added in v0.13.0
type ChatCompletionsConfig struct {
APIKey string
DefaultOptions corechat.Options
BaseURL string
HTTPClient *http.Client
}
ChatCompletionsConfig binds provider access and defaults shared by every Chat Completions call.
func (ChatCompletionsConfig) Validate ¶ added in v0.13.0
func (c ChatCompletionsConfig) Validate() error
type ChatConfig ¶
type ChatConfig struct {
APIKey string
DefaultOptions corechat.Options
BaseURL string
HTTPClient *http.Client
}
ChatConfig binds provider access and defaults shared by every chat call.
func (ChatConfig) Validate ¶
func (c ChatConfig) Validate() error
type EmbeddingModel ¶
type EmbeddingModel struct {
// contains filtered or unexported fields
}
EmbeddingModel 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 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 {
APIKey string
DefaultOptions embedding.Options
BaseURL string
HTTPClient *http.Client
}
EmbeddingModelConfig binds provider access and defaults shared by every embedding call.
func (EmbeddingModelConfig) Validate ¶
func (e EmbeddingModelConfig) Validate() error
type ImageGenerationOptions ¶
type ImageGenerationOptions struct {
AspectRatio string `json:"aspect_ratio,omitempty"`
ImageSize string `json:"image_size,omitempty"`
Delivery string `json:"delivery,omitempty"`
PreviousInteractionID string `json:"previous_interaction_id,omitempty"`
Store *bool `json:"store,omitempty"`
ThinkingLevel string `json:"thinking_level,omitempty"`
ThinkingSummaries string `json:"thinking_summaries,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
InputImages []*media.Media `json:"input_images,omitempty"`
GoogleSearch *ImageGoogleSearchOptions `json:"google_search,omitempty"`
SafetySettings []ImageSafetySetting `json:"safety_settings,omitempty"`
}
ImageGenerationOptions carries Gemini Interactions controls that have no provider-neutral image option.
type ImageGoogleSearchOptions ¶
type ImageGoogleSearchOptions struct {
SearchTypes []string `json:"search_types,omitempty"`
}
ImageGoogleSearchOptions selects the Google Search sources available during image generation.
type ImageModel ¶
type ImageModel struct {
// contains filtered or unexported fields
}
ImageModel 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 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 {
APIKey string
DefaultOptions image.Options
BaseURL string
HTTPClient *http.Client
}
ImageModelConfig binds provider access and defaults shared by every image call.
func (ImageModelConfig) Validate ¶
func (i ImageModelConfig) Validate() error
type ImageSafetySetting ¶
type ImageSafetySetting struct {
Type string `json:"type"`
Threshold string `json:"threshold"`
Method string `json:"method,omitempty"`
}
ImageSafetySetting carries one Gemini image-safety threshold.
type TextCounter ¶ added in v0.21.0
type TextCounter struct {
// contains filtered or unexported fields
}
TextCounter 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 NewTextCounter ¶ added in v0.21.0
func NewTextCounter(ctx context.Context, config TextCounterConfig) (*TextCounter, error)
NewTextCounter rejects an invalid provider/model binding before counting begins.
type TextCounterConfig ¶ added in v0.21.0
TextCounterConfig binds provider access and the model shared by every count.
func (TextCounterConfig) Validate ¶ added in v0.21.0
func (t TextCounterConfig) Validate() error
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
protocol
Package protocol implements the Google Gen AI wire protocol reused by Gemini and Vertex AI provider endpoints inside the models module.
|
Package protocol implements the Google Gen AI wire protocol reused by Gemini and Vertex AI provider endpoints inside the models module. |
|
Package vertexai exposes Google Gen AI capabilities through Vertex AI's GCP backend and Application Default Credentials.
|
Package vertexai exposes Google Gen AI capabilities through Vertex AI's GCP backend and Application Default Credentials. |