UNPKG

anthropic-vertex-ai

Version:

[nalaso/anthropic-vertex-ai](https://github.com/nalaso/anthropic-vertex-ai) is a community provider that uses Anthropic models through Vertex AI to provide language model support for the Vercel AI SDK.

103 lines (96 loc) 3.93 kB
import { GoogleAuth } from 'google-auth-library'; import { LanguageModelV1 } from '@ai-sdk/provider'; type AnthropicMessagesModelId = 'claude-3-5-sonnet-v2@20241022' | 'claude-3-5-haiku@20241022' | 'claude-3-5-sonnet@20240620' | 'claude-3-opus@20240229' | 'claude-3-sonnet@20240229' | 'claude-3-haiku@20240307' | (string & {}); interface AnthropicMessagesSettings { /** Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature. @deprecated use the topK setting on the request instead. */ topK?: number; } type AnthropicMessagesConfig = { provider: string; baseURL: string; headers: () => Record<string, string | undefined>; fetch?: typeof fetch; projectId?: string; region?: string; googleAuth?: GoogleAuth; }; declare class AnthropicMessagesLanguageModel implements LanguageModelV1 { readonly specificationVersion = "v1"; readonly defaultObjectGenerationMode = "tool"; readonly supportsImageUrls = false; readonly defaultVersion = "vertex-2023-10-16"; readonly modelId: AnthropicMessagesModelId; readonly settings: AnthropicMessagesSettings; readonly path: string; private readonly config; constructor(modelId: AnthropicMessagesModelId, settings: AnthropicMessagesSettings, config: AnthropicMessagesConfig); get provider(): string; private getArgs; doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>; doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>; } interface AnthropicVertexProvider { /** Creates a model for text generation. */ (modelId: AnthropicMessagesModelId, settings?: AnthropicMessagesSettings): AnthropicMessagesLanguageModel; /** Creates a model for text generation. */ languageModel(modelId: AnthropicMessagesModelId, settings?: AnthropicMessagesSettings): AnthropicMessagesLanguageModel; /** Creates a model for text generation. */ chat(modelId: AnthropicMessagesModelId, settings?: AnthropicMessagesSettings): AnthropicMessagesLanguageModel; } interface AnthropicVertexProviderSettings { /** Your Google Vertex region. Defaults to the environment variable `GOOGLE_VERTEX_REGION`. */ region?: string; /** Your Google Vertex project. Defaults to the environment variable `GOOGLE_VERTEX_PROJECT_ID`. */ projectId?: string; /** 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. */ googleAuth?: GoogleAuth; /** 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; /** API key that is being send using the `x-api-key` header. It defaults to the `ANTHROPIC_API_KEY` environment variable. */ apiKey?: string; /** Custom headers to include in the requests. */ headers?: Record<string, string>; /** 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?: typeof fetch; generateId?: () => string; } /** Create an Anthropic provider instance. */ declare function createAnthropicVertex(options?: AnthropicVertexProviderSettings): AnthropicVertexProvider; /** Default Anthropic provider instance. */ declare const anthropicVertex: AnthropicVertexProvider; export { type AnthropicVertexProvider, type AnthropicVertexProviderSettings, anthropicVertex, createAnthropicVertex };