import Anthropic from '@anthropic-ai/sdk'; import { GoogleGenerativeAI, CachedContent, EnhancedGenerateContentResponse, SafetySetting, GenerationConfig, Content, FunctionDeclaration, GroundingMetadata, FunctionCall } from '@google/generative-ai'; import OpenAI, { ClientOptions } from 'openai'; type Providers = "openai" | "anthropic" | "google"; type SupportedChatCompletionMessageParam = Omit & { content: string | (Anthropic.Messages.TextBlockParam | Anthropic.Messages.ImageBlockParam | Anthropic.Messages.ToolUseBlockParam | Anthropic.Messages.ToolResultBlockParam)[]; }; type ExtendedCompletionAnthropic = Partial & { originResponse: Anthropic.Messages.Message | Anthropic.Messages.ToolResultBlockParam; }; type ExtendedCompletionChunkAnthropic = Partial & { originResponse: Anthropic.Messages.Message | Anthropic.Messages.ToolResultBlockParam; }; type AnthropicChatCompletionParamsStream = Omit, "model" | "messages"> & { model: Anthropic.CompletionCreateParams["model"]; messages: SupportedChatCompletionMessageParam[]; stream: true; max_tokens: number; }; type AnthropicChatCompletionParamsNonStream = Omit, "model" | "messages"> & { model: Anthropic.CompletionCreateParams["model"]; messages: SupportedChatCompletionMessageParam[]; stream?: false | undefined; max_tokens: number; }; type AnthropicChatCompletionParams = AnthropicChatCompletionParamsStream | AnthropicChatCompletionParamsNonStream; /** Google types */ type GoogleChatCompletionParamsBase = Omit, "messages" | "model"> & { messages: SupportedChatCompletionMessageParam[]; max_tokens: number; additionalProperties?: { cacheName?: string; sessionId?: string; safetySettings?: SafetySetting[]; modelGenerationConfig?: GenerationConfig; }; groundingThreshold?: number; systemInstruction?: Content | string | undefined; tools?: Array<{ type: "function"; function: Omit & { parameters?: Record; }; }>; tool_choice?: { type: "function"; function: { name: string; }; }; }; type GoogleChatCompletionParamsStream = GoogleChatCompletionParamsBase & { stream: true; model: GeminiGenerativeModels | string; }; type GoogleChatCompletionParamsNonStream = GoogleChatCompletionParamsBase & { stream?: false | undefined; model: GeminiGenerativeModels; }; type GoogleChatCompletionParams = GoogleChatCompletionParamsStream | GoogleChatCompletionParamsNonStream; interface GoogleGroundingMetadata extends GroundingMetadata { search_queries: string[]; sources: Array<{ url: string; title: string; }>; search_suggestion_html?: string; supports?: Array<{ text: string; sources: Array<{ url: string; title: string; }>; confidence: number[]; }>; } interface GoogleToolCall { index: number; id: string; function: FunctionCall; type: string; } interface GoogleMessage { role: string; content: string; tool_calls?: GoogleToolCall[]; } interface GoogleChoice { index: number; message: GoogleMessage; finish_reason: string | null; logprobs?: null; grounding_metadata?: GoogleGroundingMetadata; } interface GoogleDeltaChoice extends Omit { delta: GoogleMessage; } type ExtendedCompletionGoogle = Partial & { originResponse: EnhancedGenerateContentResponse; choices: GoogleChoice[]; }; type ExtendedCompletionChunkGoogle = Partial & { originResponse: EnhancedGenerateContentResponse; choices: GoogleDeltaChoice[]; }; type GoogleCacheCreateParams = Omit & { ttlSeconds: number; }; type GeminiGenerativeModels = "gemini-1.5-pro" | "gemini-1.5-pro-latest" | "gemini-1.5-flash-8b" | "gemini-1.5-flash-8b-latest" | "gemini-1.5-flash" | "gemini-1.5-flash-latest" | (string & {}); /** General type for providers */ type OpenAILikeClient

= P extends "openai" | "azure" ? OpenAI : P extends "google" ? GoogleGenerativeAI & { chat: { completions: { create:

(params: P) => P extends { stream: true; } ? Promise> : Promise; }; }; cacheManager: { create: (params: GoogleCacheCreateParams) => Promise; get: (cacheName: string) => Promise; list: () => Promise<{ cachedContents: CachedContent[]; }>; delete: (cacheName: string) => Promise; update: (cacheName: string, params: GoogleCacheCreateParams) => Promise; }; } : P extends "anthropic" ? Anthropic & { [key: string]: unknown; chat: { completions: { create:

(params: P) => P extends { stream: true; } ? Promise> : Promise; }; }; } : never; declare class LLMClient

{ private providerInstance; constructor(opts: ClientOptions & { provider: P; }); getProviderInstance(): OpenAILikeClient

; } declare function createLLMClient

(opts?: ClientOptions & { provider: P; logLevel?: string; }): OpenAILikeClient

; export { LLMClient, createLLMClient };