UNPKG

@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.

89 lines (81 loc) 3.83 kB
import { z } from 'zod/v4'; import { GoogleAuthOptions } from 'google-auth-library'; import { ProviderV2, LanguageModelV2, ImageModelV2 } from '@ai-sdk/provider'; import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils'; type GoogleVertexImageModelId = 'imagen-3.0-generate-001' | 'imagen-3.0-generate-002' | 'imagen-3.0-fast-generate-001' | 'imagen-4.0-generate-preview-06-06' | 'imagen-4.0-fast-generate-preview-06-06' | 'imagen-4.0-ultra-generate-preview-06-06' | (string & {}); declare const vertexImageProviderOptionsSchema: z.ZodObject<{ negativePrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>; personGeneration: z.ZodOptional<z.ZodNullable<z.ZodEnum<{ dont_allow: "dont_allow"; allow_adult: "allow_adult"; allow_all: "allow_all"; }>>>; safetySetting: z.ZodOptional<z.ZodNullable<z.ZodEnum<{ block_low_and_above: "block_low_and_above"; block_medium_and_above: "block_medium_and_above"; block_only_high: "block_only_high"; block_none: "block_none"; }>>>; addWatermark: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>; storageUri: z.ZodOptional<z.ZodNullable<z.ZodString>>; }, z.core.$strip>; type GoogleVertexImageProviderOptions = z.infer<typeof vertexImageProviderOptionsSchema>; type GoogleVertexModelId = '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-001' | 'gemini-1.0-pro-002' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-exp' | (string & {}); interface GoogleVertexProvider extends ProviderV2 { /** Creates a model for text generation. */ (modelId: GoogleVertexModelId): LanguageModelV2; languageModel: (modelId: GoogleVertexModelId) => LanguageModelV2; /** * Creates a model for image generation. */ image(modelId: GoogleVertexImageModelId): ImageModelV2; /** Creates a model for image generation. */ imageModel(modelId: GoogleVertexImageModelId): ImageModelV2; } interface GoogleVertexProviderSettings$1 { /** 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; } 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; } declare function createVertex(options?: GoogleVertexProviderSettings): GoogleVertexProvider; /** Default Google Vertex AI provider instance. */ declare const vertex: GoogleVertexProvider; export { type GoogleVertexImageProviderOptions, type GoogleVertexProvider, type GoogleVertexProviderSettings, createVertex, vertex };