Create a new VertexLLM instance
JSON string containing Vertex AI credentials. Must include at minimum: { project: 'id', location?: 'region' } Can include full service account JSON or keyFilePath for authentication.
If neither service account fields nor keyFilePath are provided, will use Application Default Credentials (ADC).
Protected_Protected property to store additional provider-specific settings
Protected_ProtectedthinkingState tracking for streaming thinking extraction Providers should initialize this if they support thinking models
Get the current additional settings
ProtectedapiOnly sub-classes can access the API key
Get Vertex AI credentials (for debugging/logging)
Note: Returns a copy to prevent external modification. Sensitive fields like private_key are included, so be careful when logging.
Read only getter method to get the Gemini client instance Note: This is async now because the client may not be initialized yet
Whether this LLM provider supports assistant prefill (pre-seeding the start of the model's response). Providers that support prefill should override this to return true. This is used as a code-level default when database metadata (AIModelType/AIModel/AIModelVendor.SupportsPrefill) is null. Database values of true/false override this getter.
Gemini supports streaming
ProtectedaddAdd thinking content to a chat completion message
OptionalthinkingContent: stringProcess a chat completion request. If streaming is enabled and supported, this will route to the streaming implementation.
Process multiple chat completion requests in parallel. This is useful for:
Array of chat completion parameter objects
Optionalcallbacks: ParallelChatCompletionsCallbacksOptional callbacks for progress and individual completions
Promise resolving to an array of ChatResults in the same order as the input params
Clear all additional settings This is useful for resetting the state of the provider or when switching between different configurations.
ProtectedcreateOverride parent's createClient() factory method to create Vertex AI client
This factory method is called lazily on first use, so _credentials will always be set. The rest of the functionality (chat, streaming, etc.) remains identical.
ProtectedcreateProtectedextractExtract thinking content from non-streaming content This method handles case-insensitive extraction of thinking blocks
ProtectedfinalizeCreate the final response from streaming results for Gemini
ProtectedgeminiGemini supports a wide range of file types natively, including via the Files API.
ProtectedgetGet the thinking tag format for this provider Providers can override this to customize the thinking tag format
ProtectedhandleTemplate method for handling streaming chat completion This implements the common pattern across providers while delegating provider-specific logic to abstract methods.
ProtectedinitializeInitialize thinking stream state for streaming extraction
ProtectednonImplementation of non-streaming chat completion for Gemini
ProtectedprocessProcess streaming chunk with thinking extraction This method handles case-insensitive extraction across chunk boundaries
ProtectedprocessProcess a streaming chunk from Gemini
ProtectedresetReset streaming state for a new request
ProtectedresetReset thinking stream state
Set additional provider-specific settings Subclasses should override this method to validate required settings
Provider-specific settings
ProtectedsupportsCheck if the provider supports thinking models Providers should override this to return true if they support thinking extraction
StaticMapStaticMap
VertexLLM - Google Vertex AI implementation
Extends GeminiLLM and reuses all its logic (chat, streaming, thinking, parameters, multimodal content, message alternation, error handling, etc.).
The only difference is authentication - this class overrides the constructor to handle GCP authentication instead of API keys.
Example
Example
Example
Example