@ai-sdk/google-vertex
Version:
459 lines • 19.2 kB
TypeScript
import { FetchFunction, InferSchema, Resolvable, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, WebSocketConstructor } from "@ai-sdk/provider-utils";
import { GoogleAuthOptions } from "google-auth-library";
import { GoogleInteractionsAgentName, GoogleInteractionsModelId } from "@ai-sdk/google/internal";
import { EmbeddingModelV4, Experimental_TranscriptionModelV4StreamOptions, Experimental_VideoModelV4, ImageModelV4, JSONObject, LanguageModelV4, ProviderV4, SpeechModelV4, TranscriptionModelV4 } from "@ai-sdk/provider";
import { GoogleLanguageModelOptions, GoogleSpeechModelOptions } from "@ai-sdk/google";
//#region src/google-vertex-model-catalog.d.ts
declare const languageModelIds: readonly ["gemini-nano-banana-2.1", "gemini-4-argon", "gemini-4-carbon", "gemini-4-hydrogen", "gemini-3.8-flash", "gemini-3.7-flash", "gemini-3.6-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "gemini-2.0-flash-lite", "gemini-2.0-flash", "gemini-2.0-flash-001", "gemini-1.5-flash", "gemini-1.5-flash-001", "gemini-1.5-flash-002", "gemini-1.5-pro", "gemini-1.5-pro-001", "gemini-1.5-pro-002", "gemini-1.0-pro-001", "gemini-1.0-pro-vision-001", "gemini-1.0-pro", "gemini-1.0-pro-002", "gemini-2.0-flash-lite-preview-02-05", "gemini-2.5-flash-preview-09-2025", "gemini-3-pro-preview", "gemini-3-pro-image-preview", "gemini-3-flash-preview", "gemini-3.1-pro-preview", "gemini-3.1-flash-image-preview", "gemini-3.1-flash-lite-preview", "gemini-2.0-pro-exp-02-05", "gemini-2.0-flash-exp"];
declare const imageModelIds: readonly ["gemini-2.5-flash-image", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview", "gemini-nano-banana-2.1"];
declare const embeddingModelIds: readonly ["textembedding-gecko", "textembedding-gecko@001", "textembedding-gecko@003", "textembedding-gecko-multilingual", "textembedding-gecko-multilingual@001", "text-multilingual-embedding-002", "text-embedding-004", "text-embedding-005", "gemini-embedding-001", "gemini-embedding-2", "gemini-embedding-2-preview"];
declare const videoModelIds: readonly ["veo-2.0-generate-preview", "veo-2.0-generate-exp", "veo-2.0-generate-001", "veo-3.0-generate-001", "veo-3.0-fast-generate-001", "veo-3.0-generate-preview", "veo-3.0-fast-generate-preview", "veo-3.1-generate-001", "veo-3.1-fast-generate-001", "veo-3.1-generate-preview", "veo-3.1-fast-generate-preview"];
declare const speechModelIds: readonly ["gemini-2.5-flash-tts", "gemini-2.5-pro-tts", "gemini-2.5-flash-lite-preview-tts", "gemini-3.1-flash-tts-preview", "chirp-3-hd"];
declare const transcriptionModelIds: readonly ["chirp_2", "chirp_3", "telephony"];
declare const geminiTranscriptionModelIds: readonly ["gemini-3.5-transcribe", "gemini-3.5-transcribe-live"];
declare const vertexAnthropicModels: {
'claude-fable-5-1': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-fable-5-2': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-3-7-sonnet@20250219': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-3-5-sonnet-v2@20241022': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-3-5-sonnet@20240620': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-3-5-haiku@20241022': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-3-sonnet@20240229': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-3-haiku@20240307': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-3-opus@20240229': {
image: boolean;
objectGeneration: boolean;
tools: boolean;
streaming: boolean;
computerUse: boolean;
};
'claude-fable-5': undefined;
'claude-haiku-5-5': undefined;
'claude-opus-4-1@20250805': undefined;
'claude-opus-4-5@20251101': undefined;
'claude-opus-4-6': undefined;
'claude-opus-4-7': undefined;
'claude-opus-4-8': undefined;
'claude-opus-4@20250514': undefined;
'claude-opus-5': undefined;
'claude-opus-5-5': undefined;
'claude-sonnet-4-5@20250929': undefined;
'claude-sonnet-4-6': undefined;
'claude-sonnet-4@20250514': undefined;
'claude-sonnet-5': undefined;
'claude-sonnet-5-5': undefined;
};
declare const vertexXaiModels: {
'xai/grok-4.20-reasoning': {
reasoning: boolean;
};
'xai/grok-4.20-non-reasoning': {
reasoning: boolean;
};
'xai/grok-4.1-fast-reasoning': {
reasoning: boolean;
};
'xai/grok-4.1-fast-non-reasoning': {
reasoning: boolean;
};
};
declare const vertexMaasModels: {
'deepseek-ai/deepseek-r1-0528-maas': {
publisher: string;
};
'deepseek-ai/deepseek-v3.1-maas': {
publisher: string;
};
'deepseek-ai/deepseek-v3.2-maas': {
publisher: string;
};
'openai/gpt-oss-120b-maas': {
publisher: string;
};
'openai/gpt-oss-20b-maas': {
publisher: string;
};
'meta/llama-4-maverick-17b-128e-instruct-maas': {
publisher: string;
};
'meta/llama-4-scout-17b-16e-instruct-maas': {
publisher: string;
};
'minimax/minimax-m2-maas': {
publisher: string;
};
'qwen/qwen3-coder-480b-a35b-instruct-maas': {
publisher: string;
};
'qwen/qwen3-next-80b-a3b-instruct-maas': {
publisher: string;
};
'qwen/qwen3-next-80b-a3b-thinking-maas': {
publisher: string;
};
'moonshotai/kimi-k2-thinking-maas': {
publisher: string;
};
};
/** Known model IDs, derived from the declarations used to build the catalog. */
type GoogleVertexModelIds = {
language: (typeof languageModelIds)[number];
image: (typeof imageModelIds)[number];
embedding: (typeof embeddingModelIds)[number];
video: (typeof videoModelIds)[number];
speech: (typeof speechModelIds)[number];
transcription: (typeof transcriptionModelIds)[number];
geminiTranscription: (typeof geminiTranscriptionModelIds)[number];
anthropic: keyof typeof vertexAnthropicModels;
xai: keyof typeof vertexXaiModels;
maas: keyof typeof vertexMaasModels;
};
//#endregion
//#region src/google-vertex-embedding-model-options.d.ts
type GoogleVertexEmbeddingModelId = GoogleVertexModelIds['embedding'] | (string & {});
declare const googleVertexEmbeddingModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
outputDimensionality?: number | undefined;
taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
title?: string | undefined;
autoTruncate?: boolean | undefined;
}>;
type GoogleVertexEmbeddingModelOptions = InferSchema<typeof googleVertexEmbeddingModelOptions>;
//#endregion
//#region src/google-vertex-transcription-model-options.d.ts
type GoogleVertexTranscriptionModelId = GoogleVertexModelIds['transcription'] | (string & {});
declare const googleVertexTranscriptionProviderOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
languageCodes?: string[] | undefined;
enableAutomaticPunctuation?: boolean | undefined;
enableWordTimeOffsets?: boolean | undefined;
region?: string | undefined;
}>;
type GoogleVertexTranscriptionModelOptions = InferSchema<typeof googleVertexTranscriptionProviderOptionsSchema>;
//#endregion
//#region src/google-vertex-image-model-options.d.ts
type GoogleVertexImageModelOptions = Omit<GoogleLanguageModelOptions, 'responseModalities'>;
//#endregion
//#region src/google-vertex-video-model-options.d.ts
type GoogleVertexVideoModelOptions = {
pollIntervalMs?: number | null;
pollTimeoutMs?: number | null;
personGeneration?: 'dont_allow' | 'allow_adult' | 'allow_all' | null;
negativePrompt?: string | null;
generateAudio?: boolean | null;
gcsOutputDirectory?: string | null;
referenceImages?: Array<{
bytesBase64Encoded?: string;
gcsUri?: string;
}> | null;
[key: string]: unknown;
};
//#endregion
//#region src/google-vertex-video-settings.d.ts
type GoogleVertexVideoModelId = GoogleVertexModelIds['video'] | (string & {});
//#endregion
//#region src/google-vertex-speech-model-options.d.ts
type GoogleVertexSpeechModelId = GoogleVertexModelIds['speech'] | (string & {});
type GoogleVertexSpeechModelOptions = GoogleSpeechModelOptions;
//#endregion
//#region src/google-vertex-config.d.ts
interface GoogleVertexConfig {
provider: string;
baseURL: string;
headers?: Resolvable<Record<string, string | undefined>>;
fetch?: FetchFunction;
}
//#endregion
//#region src/google-vertex-embedding-model.d.ts
declare class GoogleVertexEmbeddingModel implements EmbeddingModelV4 {
readonly specificationVersion = "v4";
readonly modelId: GoogleVertexEmbeddingModelId;
readonly supportsParallelCalls = true;
private readonly config;
static [WORKFLOW_SERIALIZE](model: GoogleVertexEmbeddingModel): {
modelId: string;
config: import("@ai-sdk/provider").JSONObject;
};
static [WORKFLOW_DESERIALIZE](options: {
modelId: string;
config: GoogleVertexConfig;
}): GoogleVertexEmbeddingModel;
get provider(): string;
get maxEmbeddingsPerCall(): number;
constructor(modelId: GoogleVertexEmbeddingModelId, config: GoogleVertexConfig);
doEmbed({ values, dimensions, headers, abortSignal, providerOptions }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
}
//#endregion
//#region src/google-vertex-image-settings.d.ts
type GoogleVertexImageModelId = GoogleVertexModelIds['image'] | (string & {});
//#endregion
//#region src/google-vertex-options.d.ts
type GoogleVertexModelId = GoogleVertexModelIds['language'] | (string & {});
//#endregion
//#region src/google-vertex-tools.d.ts
declare const googleVertexTools: {
googleSearch: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{}, {}, {
[x: string]: unknown;
searchTypes?: {
webSearch?: Record<string, never> | undefined;
imageSearch?: Record<string, never> | undefined;
} | undefined;
timeRangeFilter?: {
startTime: string;
endTime: string;
} | undefined;
}, {}>;
enterpriseWebSearch: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{}, {}, {}, {}>;
googleMaps: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{}, {}, {}, {}>;
urlContext: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{}, {}, {}, {}>;
fileSearch: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{}, {}, {
[x: string]: unknown;
fileSearchStoreNames: string[];
topK?: number | undefined;
metadataFilter?: string | undefined;
}, {}>;
codeExecution: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{
language: string;
code: string;
}, {
outcome: string;
output: string;
}, {}, {}>;
vertexRagStore: import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{}, {}, {
ragCorpus: string;
topK?: number;
}, {}>;
};
//#endregion
//#region src/google-vertex-provider-base.d.ts
interface GoogleVertexProvider extends ProviderV4 {
/**
* Creates a model for text generation.
*/
(modelId: GoogleVertexModelId): LanguageModelV4;
languageModel: (modelId: GoogleVertexModelId) => LanguageModelV4;
/**
* Creates a language model targeting the Gemini Interactions API
* (`.../locations/{region}/interactions`) on Vertex, reusing the Vertex
* OAuth credentials. Pass a model id (e.g. `gemini-omni-flash-preview`) or an
* `{ agent }` / `{ managedAgent }` reference.
*/
interactions(modelIdOrAgent: GoogleInteractionsModelId | {
agent: GoogleInteractionsAgentName;
} | {
managedAgent: string;
}): LanguageModelV4;
/**
* Creates a model for image generation.
*/
image(modelId: GoogleVertexImageModelId): ImageModelV4;
/**
* Creates a model for image generation.
*/
imageModel(modelId: GoogleVertexImageModelId): ImageModelV4;
tools: typeof googleVertexTools;
/**
* @deprecated Use `embeddingModel` instead.
*/
textEmbeddingModel(modelId: GoogleVertexEmbeddingModelId): GoogleVertexEmbeddingModel;
/**
* Creates a model for video generation.
*/
video(modelId: GoogleVertexVideoModelId): Experimental_VideoModelV4;
/**
* Creates a model for video generation.
*/
videoModel(modelId: GoogleVertexVideoModelId): Experimental_VideoModelV4;
/**
* Creates a model for speech generation (text-to-speech).
*/
speech(modelId: GoogleVertexSpeechModelId): SpeechModelV4;
/**
* Creates a model for speech generation (text-to-speech).
*/
speechModel(modelId: GoogleVertexSpeechModelId): SpeechModelV4;
/**
* Creates a model for transcription (speech-to-text).
*/
transcription(modelId: GoogleVertexTranscriptionModelId): TranscriptionModelV4;
/**
* Creates a model for transcription (speech-to-text).
*/
transcriptionModel(modelId: GoogleVertexTranscriptionModelId): TranscriptionModelV4;
}
interface GoogleVertexProviderSettings$1 {
/**
* Optional. The API key for the Google Cloud project. If provided, the
* provider will use express mode with API key authentication. Defaults to
* the value of the `GOOGLE_VERTEX_API_KEY` environment variable.
* A callback is resolved before each request and must return a non-empty key.
*/
apiKey?: Resolvable<string>;
/**
* Your Google Vertex location. Defaults to the environment variable `GOOGLE_VERTEX_LOCATION`.
*/
location?: string;
/**
* Your Google Vertex project. Defaults to the environment variable `GOOGLE_VERTEX_PROJECT`.
*/
project?: 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;
generateId?: () => string;
/**
* Base URL for the Google Vertex API calls.
*/
baseURL?: string;
/**
* Custom WebSocket implementation for streaming transcription. Useful for
* runtimes that need a WebSocket constructor with header support (e.g. the
* `ws` package in Node.js, which Vertex's OAuth Bearer header requires).
*/
webSocket?: WebSocketConstructor;
/**
* Settings for downloading remote files in tool results before sending them
* to Vertex as inline data.
*/
toolResultDownloads?: {
/**
* Maximum size in bytes for each downloaded file. Defaults to 7 MiB.
*/
maxBytes?: number;
};
}
//#endregion
//#region src/google-vertex-provider.d.ts
interface GoogleVertexProviderSettings extends GoogleVertexProviderSettings$1 {
/**
* Optional. The Authentication options provided by google-auth-library.
* Complete list of authentication options is documented in the
* GoogleAuthOptions interface:
* https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.
*/
googleAuthOptions?: GoogleAuthOptions;
}
export declare function createGoogleVertex(options?: GoogleVertexProviderSettings): GoogleVertexProvider;
/**
* Default Google Vertex AI provider instance.
*/
export declare const googleVertex: GoogleVertexProvider;
//#endregion
//#region src/gemini-transcription/google-vertex-gemini-transcription-model-options.d.ts
type GoogleVertexGeminiTranscriptionModelId = GoogleVertexModelIds['geminiTranscription'] | (string & {});
/**
* Speech recognition options for Gemini transcription models on Vertex,
* shared by unary (`gemini-3.5-transcribe`) and live
* (`gemini-3.5-transcribe-live`) variants. Maps onto Google's
* `AudioTranscriptionConfig`.
*/
declare const googleVertexGeminiTranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
languageCodes?: string[] | undefined;
customVocabulary?: string[] | undefined;
wordTimestamp?: boolean | undefined;
diarization?: boolean | undefined;
mode?: "SMART" | "VERBATIM" | undefined;
}>;
type GoogleVertexTranscriptionModelGeminiOptions = InferSchema<typeof googleVertexGeminiTranscriptionModelOptions>;
//#endregion
//#region src/gemini-transcription/google-vertex-gemini-transcription-model.d.ts
interface GoogleVertexGeminiTranscriptionModelConfig {
provider: string;
/** Regional base URL ending in `/publishers/google`. */
baseURL: string;
headers?: Resolvable<Record<string, string | undefined>>;
fetch?: FetchFunction;
webSocket?: WebSocketConstructor;
project: string;
location: string;
_internal?: {
currentDate?: () => Date;
finishGraceMs?: number;
};
}
/**
* Gemini transcription on Vertex AI. Unary variants transcribe via
* `generateContent`; live variants stream over the Vertex Live API WebSocket
* (`LlmBidiService/BidiGenerateContent`) with OAuth Bearer authentication
* from the provider's resolved headers.
*/
export declare class GoogleVertexGeminiTranscriptionModel implements TranscriptionModelV4 {
readonly modelId: GoogleVertexGeminiTranscriptionModelId;
private readonly config;
readonly specificationVersion = "v4";
static [WORKFLOW_SERIALIZE](model: GoogleVertexGeminiTranscriptionModel): {
modelId: string;
config: JSONObject;
};
static [WORKFLOW_DESERIALIZE](options: {
modelId: GoogleVertexGeminiTranscriptionModelId;
config: GoogleVertexGeminiTranscriptionModelConfig;
}): GoogleVertexGeminiTranscriptionModel;
get provider(): string;
constructor(modelId: GoogleVertexGeminiTranscriptionModelId, config: GoogleVertexGeminiTranscriptionModelConfig);
private parseOptions;
doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>>;
doStream(options: Experimental_TranscriptionModelV4StreamOptions): Promise<Awaited<ReturnType<NonNullable<TranscriptionModelV4['doStream']>>>>;
}
//#endregion
//#region src/version.d.ts
export declare const VERSION: string;
//#endregion
export { type GoogleVertexEmbeddingModelOptions, type GoogleVertexGeminiTranscriptionModelId, type GoogleVertexImageModelOptions, type GoogleVertexImageModelOptions as GoogleVertexImageProviderOptions, type GoogleVertexProvider, type GoogleVertexProviderSettings, type GoogleVertexSpeechModelId, type GoogleVertexSpeechModelOptions, type GoogleVertexTranscriptionModelGeminiOptions, type GoogleVertexTranscriptionModelId, type GoogleVertexTranscriptionModelOptions, type GoogleVertexVideoModelId, type GoogleVertexVideoModelOptions, type GoogleVertexVideoModelOptions as GoogleVertexVideoProviderOptions, createGoogleVertex as createVertex, googleVertex as vertex };
//# sourceMappingURL=index.d.ts.map