Documentation
¶
Overview ¶
Package vertexai provides support for non-Gemini models hosted on Google Cloud's Vertex AI Model Garden.
Vertex AI Model Garden hosts models from various publishers (Anthropic, Meta, Mistral, etc.) and exposes them through two different APIs:
- Anthropic Claude models: the Anthropic-native `:rawPredict` / `:streamRawPredict` endpoints. Claude models do not support the OpenAI-compatible path.
- Other publishers: Vertex AI's OpenAI-compatible `/chat/completions` endpoint.
Authentication uses Google Cloud Application Default Credentials, or the token source given to NewClientWithTokenSource.
Usage in agent config:
models:
claude-on-vertex:
provider: google
model: claude-sonnet-4-20250514
provider_opts:
project: my-gcp-project
location: us-east5
publisher: anthropic
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsModelGardenConfig ¶
func IsModelGardenConfig(cfg *latest.ModelConfig) bool
IsModelGardenConfig returns true when the ModelConfig describes a non-Gemini model on Vertex AI (i.e. the "publisher" provider_opt is set to something other than "google").
Types ¶
type Client ¶ added in v1.51.0
Client is the canonical provider contract returned by NewClient. Both anthropic.Client and openai.Client satisfy it.
func NewClient ¶
func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, opts ...options.Opt) (Client, error)
NewClient creates a client for a non-Gemini model on Vertex AI Model Garden, choosing the right endpoint based on the publisher:
- publisher: anthropic → Anthropic-native `:streamRawPredict` endpoint.
- other publishers → Vertex AI's OpenAI-compatible `/chat/completions`.
The underlying client is constructed with a Provider field rewritten so that downstream capability lookups against models.dev resolve correctly. Without this rewrite, attachments and other capability-gated features are silently dropped because `<provider>/<model>` IDs like `google/claude-sonnet-4-20250514` do not exist in the models.dev database. See modelsDevProvider for the exact mapping.
func NewClientWithTokenSource ¶ added in v1.142.0
func NewClientWithTokenSource(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, source options.TokenSource, opts ...options.Opt) (Client, error)
NewClientWithTokenSource is NewClient authenticated with source instead of Application Default Credentials, which are never looked up. The token is resolved with each request's context.