/** * LLM Client Factory * * Factory function for creating LLM client instances with auto-detection and validation. */ import { LLMClient, LLMClientConfig } from './client'; import { LLMProvider } from './config'; /** * Extended configuration for creating an LLM client */ export interface CreateLLMClientConfig extends LLMClientConfig { /** Provider type (auto-detected from model if not specified) */ provider?: LLMProvider; /** Model to use (required for auto-detection) */ model?: string; } /** * Create an LLM client instance * * This factory function creates the appropriate LLM client based on the configuration. * It supports auto-detection of providers from model names and automatic loading of * API keys from environment variables. * * @example * ```typescript * // Auto-detect provider from model name * const client = createLLMClient({ * model: 'gpt-4-turbo', * apiKey: process.env.OPENAI_API_KEY!, * }); * * // Explicit provider * const client = createLLMClient({ * provider: 'anthropic', * model: 'claude-3-opus-20240229', * apiKey: process.env.ANTHROPIC_API_KEY!, * }); * * // Use environment variables for API key * const client = createLLMClient({ * model: 'gpt-4-turbo', * // API key loaded from OPENAI_API_KEY env var * }); * ``` * * @param config - Client configuration * @returns LLM client instance * @throws LLMInvalidRequestError if configuration is invalid * @throws LLMAuthenticationError if API key is missing * @throws Error if provider is not supported */ export declare function createLLMClient(config: CreateLLMClientConfig): LLMClient; /** * Create an LLM client with simplified configuration * * Convenience function that only requires a model name and API key. * The provider is automatically detected from the model name. * * @example * ```typescript * const client = createSimpleLLMClient('gpt-4-turbo', process.env.OPENAI_API_KEY!); * const client = createSimpleLLMClient('claude-3-opus-20240229'); // Uses env var * ``` * * @param model - Model identifier * @param apiKey - Optional API key (loaded from env if not provided) * @returns LLM client instance */ export declare function createSimpleLLMClient(model: string, apiKey?: string): LLMClient; /** * Type guard to check if a client configuration is valid * * @param config - Configuration to check * @returns True if configuration is valid */ export declare function isValidLLMConfig(config: Partial): config is CreateLLMClientConfig; //# sourceMappingURL=factory.d.ts.map