@ai-sdk/google-vertex
Version:
The **[Google Vertex provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Google Vertex AI](https://cloud.google.com/vertex-ai) APIs.
93 lines (87 loc) • 3.51 kB
text/typescript
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
interface GoogleCredentials {
/**
* The client email for the Google Cloud service account. Defaults to the
* value of the `GOOGLE_CLIENT_EMAIL` environment variable.
*/
clientEmail: string;
/**
* The private key for the Google Cloud service account. Defaults to the
* value of the `GOOGLE_PRIVATE_KEY` environment variable.
*/
privateKey: string;
/**
* Optional. The private key ID for the Google Cloud service account. Defaults
* to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.
*/
privateKeyId?: string;
}
type GoogleVertexXaiModelId = 'xai/grok-4.20-reasoning' | 'xai/grok-4.20-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | (string & {});
interface GoogleVertexXaiProvider extends ProviderV3 {
/**
* Creates a model for text generation.
*/
(modelId: GoogleVertexXaiModelId): LanguageModelV3;
/**
* Creates a model for text generation.
*/
languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;
/**
* Creates a chat model for text generation.
*/
chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;
/**
* @deprecated Use `embeddingModel` instead.
*/
textEmbeddingModel(modelId: string): never;
}
interface GoogleVertexXaiProviderSettings$1 {
/**
* Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
*/
project?: string;
/**
* Google Cloud location/region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
* Use 'global' for the global endpoint.
*/
location?: string;
/**
* Base URL for the API calls. If not provided, will be constructed from project and location.
*/
baseURL?: string;
/**
* Headers to use for requests. Can be:
* - A headers object
* - A Promise that resolves to a headers object
* - A function that returns a headers object
* - A function that returns a Promise of a headers object
*/
headers?: Resolvable<Record<string, string | undefined>>;
/**
* Custom fetch implementation. You can use it as a middleware to intercept requests,
* or to provide a custom fetch implementation for e.g. testing.
*/
fetch?: FetchFunction;
}
interface GoogleVertexXaiProviderSettings extends GoogleVertexXaiProviderSettings$1 {
/**
* Optional. The Google credentials for the Google Cloud service account. If
* not provided, the Google Vertex provider will use environment variables to
* load the credentials.
*/
googleCredentials?: GoogleCredentials;
}
/**
* Create a Google Vertex AI xAI provider instance for Edge runtimes.
* Uses the OpenAI-compatible Chat Completions API for Grok partner models.
* Automatically handles Google Cloud authentication.
*
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok
*/
declare function createGoogleVertexXai(options?: GoogleVertexXaiProviderSettings): GoogleVertexXaiProvider;
/**
* Default Google Vertex AI xAI provider instance for Edge runtimes.
*/
declare const googleVertexXai: GoogleVertexXaiProvider;
export { type GoogleVertexXaiModelId, type GoogleVertexXaiProvider, type GoogleVertexXaiProviderSettings, createGoogleVertexXai, googleVertexXai };