ai.googleapis.vertex
Module ai.googleapis.vertex
API
Declarations
Definitions
sumudunissanka/ai.googleapis.vertex
Ballerina model provider
Clients
ai.googleapis.vertex: EmbeddingProvider
EmbeddingProvider is a client class that provides an interface for generating vector embeddings using Google Vertex AI text embedding models.
Constructor
Initializes the Vertex AI embedding provider with the given configuration.
init (string accessToken, string projectId, string location, VERTEX_AI_EMBEDDING_MODEL_NAMES modelType, string serviceUrl, *ConnectionConfig connectionConfig)- accessToken string - A valid Google Cloud OAuth2 bearer access token
- projectId string - The Google Cloud project ID
- location string "us-central1" - The Google Cloud region (e.g.,
"us-central1")
- modelType VERTEX_AI_EMBEDDING_MODEL_NAMES TEXT_EMBEDDING_005 - The embedding model to use
- serviceUrl string "" - The base URL of the Vertex AI API endpoint (defaults to the regional URL)
- connectionConfig *ConnectionConfig - Additional HTTP connection configuration
embed
Converts the given chunk into a vector embedding.
Parameters
- chunk Chunk - The chunk to convert into an embedding (only
ai:TextChunkandai:TextDocumentare supported)
Return Type
batchEmbed
Converts a batch of chunks into vector embeddings by calling the embed endpoint for each chunk. Chunks are processed sequentially. On the first failure, processing halts and no partial results are returned. Vertex AI does not expose a native batch embedding endpoint for Gemini models, so each chunk requires its own HTTP round trip.
Parameters
- chunks Chunk[] - The chunks to convert into embeddings (only
ai:TextChunkandai:TextDocumentare supported)
ai.googleapis.vertex: ModelProvider
ModelProvider is a client class that provides an interface for interacting with models hosted on Google Vertex AI, including Google Gemini models and partner models (Anthropic Claude, Mistral) available through Vertex AI Model Garden.
The model parameter uses "publisher/model-name" format, which determines both
the endpoint path and the wire format used for requests:
"google/gemini-2.0-flash"— Vertex AIgenerateContentAPI"anthropic/claude-sonnet-4-6"— Anthropic Messages API viarawPredict"mistralai/mistral-medium-3"— OpenAI-compatible format viarawPredict"meta/llama-4-maverick-17b-128e-instruct-maas"— OpenAI-compatible open-models endpoint"deepseek-ai/deepseek-v3-0324"— OpenAI-compatible open-models endpoint"qwen/qwen3-235b-a22b"— OpenAI-compatible open-models endpoint"kimi/kimi-k2"— OpenAI-compatible open-models endpoint"minimax/minimax-m2"— OpenAI-compatible open-models endpoint
Constructor
Initializes the Vertex AI model provider with the given configuration.
init (string accessToken, string projectId, string location, string model, string serviceUrl, int maxTokens, decimal? temperature, *ConnectionConfig connectionConfig)- accessToken string - A valid Google Cloud OAuth2 bearer access token
- projectId string - The Google Cloud project ID
- location string "us-central1" - The Google Cloud region (e.g.,
"us-central1")
- model string "google/gemini-2.0-flash" - The model in
"publisher/model-name"format, e.g.:"google/gemini-2.0-flash","anthropic/claude-sonnet-4-6","mistralai/mistral-medium-3". Omitting the publisher prefix defaults to"google".
- serviceUrl string "" - The base URL of the Vertex AI API endpoint. Defaults to the
regional URL
https://{location}-aiplatform.googleapis.com
- maxTokens int DEFAULT_MAX_TOKEN_COUNT - The upper limit for the number of tokens in the model's response
- temperature decimal? () - Controls randomness in the model's output. Pass
()to omit the field entirely (required for models that do not accept it)
- connectionConfig *ConnectionConfig - Additional HTTP connection configuration
chat
function chat(ChatMessage[]|ChatUserMessage messages, ChatCompletionFunctions[] tools, string? stop) returns ChatAssistantMessage|ErrorSends a chat request to the model. The request is routed to the correct publisher-specific endpoint and serialised using the appropriate wire format.
Parameters
- messages ChatMessage[]|ChatUserMessage - List of chat messages or a single user message
- tools ChatCompletionFunctions[] (default []) - Tool definitions to be used for tool calling
- stop string? (default ()) - Stop sequence to stop the completion
Return Type
- ChatAssistantMessage|Error - The assistant's response, or an error if the request fails
generate
Sends a prompt to the model and generates a value of the type specified by
the td type descriptor. Supports all publishers (Gemini, Anthropic, Mistral).
Parameters
- prompt Prompt - The prompt to use
- td typedesc<anydata> (default <>) - Type descriptor specifying the expected return type format
Return Type
- td|Error - Generates a value that belongs to the type, or an error if generation fails
Enums
ai.googleapis.vertex: ANTHROPIC_ON_VERTEX_MODEL_NAMES
Anthropic Claude model names available on Vertex AI Model Garden. Uses the rawPredict endpoint with the Anthropic Messages API wire format.
Members
ai.googleapis.vertex: DEEPSEEK_ON_VERTEX_MODEL_NAMES
DeepSeek model names available on Vertex AI Model Garden.
Uses the OpenAI-compatible /endpoints/openapi/chat/completions endpoint.
Members
ai.googleapis.vertex: KIMI_ON_VERTEX_MODEL_NAMES
Kimi model names available on Vertex AI Model Garden.
Uses the OpenAI-compatible /endpoints/openapi/chat/completions endpoint.
Members
ai.googleapis.vertex: META_ON_VERTEX_MODEL_NAMES
Meta Llama model names available on Vertex AI Model Garden.
Uses the OpenAI-compatible /endpoints/openapi/chat/completions endpoint.
Members
ai.googleapis.vertex: MINIMAX_ON_VERTEX_MODEL_NAMES
MiniMax model names available on Vertex AI Model Garden.
Uses the OpenAI-compatible /endpoints/openapi/chat/completions endpoint.
Members
ai.googleapis.vertex: MISTRAL_ON_VERTEX_MODEL_NAMES
Mistral model names available on Vertex AI Model Garden. Uses the rawPredict endpoint with the OpenAI-compatible wire format.
Members
ai.googleapis.vertex: QWEN_ON_VERTEX_MODEL_NAMES
Qwen (Alibaba) model names available on Vertex AI Model Garden.
Uses the OpenAI-compatible /endpoints/openapi/chat/completions endpoint.
Members
ai.googleapis.vertex: VERTEX_AI_EMBEDDING_MODEL_NAMES
Embedding model names supported by the Vertex AI embedding provider.
Members
ai.googleapis.vertex: VERTEX_AI_MODEL_NAMES
Vertex AI Gemini model names supported by the provider.
Members
ai.googleapis.vertex: VERTEX_AI_PUBLISHER
Publishers supported on Vertex AI Model Garden.
Members
Records
ai.googleapis.vertex: ConnectionConfig
Configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings? ClientHttp1Settings - Configurations related to HTTP/1.x protocol
- http2Settings? ClientHttp2Settings - Configurations related to HTTP/2 protocol
- timeout decimal(default 60) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded/x-forwardedheader
- poolConfig? PoolConfiguration - Configurations associated with request pooling
- cache? CacheConfig - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding) header
- circuitBreaker? CircuitBreakerConfig - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig? RetryConfig - Configurations associated with retrying
- responseLimits? ResponseLimitConfigs - Configurations associated with inbound response size limits
- secureSocket? ClientSecureSocket - SSL/TLS-related options
- proxy? ProxyConfig - Proxy server related options
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
Import
import sumudunissanka/ai.googleapis.vertex;Metadata
Released date: 5 days ago
Version: 1.0.0
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.12.6
GraalVM compatible: Yes
Pull count
Total: 18
Current verison: 3
Weekly downloads
Keywords
Agent
Model
Provider
Vendor/Google
Area/AI & Machine Learning
Type/Connector
Contributors