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.

266 lines (261 loc) 10.3 kB
import { GoogleAuthOptions } from 'google-auth-library'; import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils'; import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider'; type GoogleVertexAnthropicMessagesModelId = 'claude-opus-4-7' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-opus-4-5@20251101' | 'claude-sonnet-4-5@20250929' | 'claude-opus-4-1@20250805' | 'claude-opus-4@20250514' | 'claude-sonnet-4@20250514' | 'claude-3-7-sonnet@20250219' | 'claude-3-5-sonnet-v2@20241022' | 'claude-3-5-haiku@20241022' | 'claude-3-5-sonnet@20240620' | 'claude-3-haiku@20240307' | 'claude-3-sonnet@20240229' | 'claude-3-opus@20240229' | (string & {}); /** * Tools supported by Google Vertex Anthropic. * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API. */ declare const vertexAnthropicTools: { /** * The bash tool enables Claude to execute shell commands in a persistent bash session, * allowing system operations, script execution, and command-line automation. * * Image results are supported. */ bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{ command: string; restart?: boolean; }, {}>; /** * The bash tool enables Claude to execute shell commands in a persistent bash session, * allowing system operations, script execution, and command-line automation. * * Image results are supported. */ bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{ command: string; restart?: boolean; }, {}>; /** * Claude can use an Anthropic-defined text editor tool to view and modify text files, * helping you debug, fix, and improve your code or other text documents. * * Supported models: Claude Sonnet 3.5 */ textEditor_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{ command: "view" | "create" | "str_replace" | "insert" | "undo_edit"; path: string; file_text?: string; insert_line?: number; new_str?: string; insert_text?: string; old_str?: string; view_range?: number[]; }, {}>; /** * Claude can use an Anthropic-defined text editor tool to view and modify text files, * helping you debug, fix, and improve your code or other text documents. * * Supported models: Claude Sonnet 3.7 */ textEditor_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{ command: "view" | "create" | "str_replace" | "insert" | "undo_edit"; path: string; file_text?: string; insert_line?: number; new_str?: string; insert_text?: string; old_str?: string; view_range?: number[]; }, {}>; /** * Claude can use an Anthropic-defined text editor tool to view and modify text files. * Note: This version does not support the "undo_edit" command. * @deprecated Use textEditor_20250728 instead */ textEditor_20250429: _ai_sdk_provider_utils.ProviderToolFactory<{ command: "view" | "create" | "str_replace" | "insert"; path: string; file_text?: string; insert_line?: number; new_str?: string; insert_text?: string; old_str?: string; view_range?: number[]; }, {}>; /** * Claude can use an Anthropic-defined text editor tool to view and modify text files. * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter. * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1 */ textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactory<{ command: "view" | "create" | "str_replace" | "insert"; path: string; file_text?: string; insert_line?: number; new_str?: string; insert_text?: string; old_str?: string; view_range?: number[]; }, { maxCharacters?: number; }>>[0]) => _ai_sdk_provider_utils.Tool<{ command: "view" | "create" | "str_replace" | "insert"; path: string; file_text?: string; insert_line?: number; new_str?: string; insert_text?: string; old_str?: string; view_range?: number[]; }, unknown>; /** * Claude can interact with computer environments through the computer use tool, which * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction. * * Image results are supported. */ computer_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{ action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position"; coordinate?: number[]; text?: string; }, { displayWidthPx: number; displayHeightPx: number; displayNumber?: number; }>; /** * Creates a web search tool that gives Claude direct access to real-time web content. */ webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{ query: string; }, { type: "web_search_result"; url: string; title: string | null; pageAge: string | null; encryptedContent: string; }[], { maxUses?: number; allowedDomains?: string[]; blockedDomains?: string[]; userLocation?: { type: "approximate"; city?: string; region?: string; country?: string; timezone?: string; }; }>>[0]) => _ai_sdk_provider_utils.Tool<{ query: string; }, { type: "web_search_result"; url: string; title: string | null; pageAge: string | null; encryptedContent: string; }[]>; /** * Creates a tool search tool that uses regex patterns to find tools. * * The tool search tool enables Claude to work with hundreds or thousands of tools * by dynamically discovering and loading them on-demand. * * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools * to mark them for deferred loading. */ toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{ pattern: string; limit?: number; }, { type: "tool_reference"; toolName: string; }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{ pattern: string; limit?: number; }, { type: "tool_reference"; toolName: string; }[]>; /** * Creates a tool search tool that uses BM25 (natural language) to find tools. * * The tool search tool enables Claude to work with hundreds or thousands of tools * by dynamically discovering and loading them on-demand. * * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools * to mark them for deferred loading. */ toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{ query: string; limit?: number; }, { type: "tool_reference"; toolName: string; }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{ query: string; limit?: number; }, { type: "tool_reference"; toolName: string; }[]>; }; interface GoogleVertexAnthropicProvider extends ProviderV3 { /** * Creates a model for text generation. */ (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3; /** * Creates a model for text generation. */ languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3; /** * Anthropic tools supported by Google Vertex. * Note: Only a subset of Anthropic tools are available on Vertex. * Supported tools: bash_20241022, bash_20250124, textEditor_20241022, * textEditor_20250124, textEditor_20250429, textEditor_20250728, * computer_20241022, webSearch_20250305, toolSearchRegex_20251119, * toolSearchBm25_20251119 */ tools: typeof vertexAnthropicTools; /** * @deprecated Use `embeddingModel` instead. */ textEmbeddingModel(modelId: string): never; } interface GoogleVertexAnthropicProviderSettings$1 { /** * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable. */ project?: string; /** * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable. */ location?: string; /** * Use a different URL prefix for API calls, e.g. to use proxy servers. * The default prefix is `https://api.anthropic.com/v1`. */ baseURL?: string; /** * Custom headers to include in the requests. */ 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 GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettings$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; /** * Optional. Override the Bearer token generator. Defaults to OAuth exchange * via `google-auth-library` with `googleAuthOptions`. */ generateAuthToken?: () => Promise<string | null>; } declare function createVertexAnthropic(options?: GoogleVertexAnthropicProviderSettings): GoogleVertexAnthropicProvider; /** * Default Google Vertex Anthropic provider instance. */ declare const vertexAnthropic: GoogleVertexAnthropicProvider; export { type GoogleVertexAnthropicProvider, type GoogleVertexAnthropicProviderSettings, createVertexAnthropic, vertexAnthropic };