pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
41 lines (40 loc) • 1.87 kB
TypeScript
import OpenAI from 'openai';
import { LLMBase, LLMConfig } from './llm-base';
/**
* OpenRouter Helper - Can use any model via OpenRouter API
* Supports: Gemini, Claude, GPT, Llama, and many others
* OpenRouter provides access to multiple model providers through a unified API
*/
export default class OpenRouter extends LLMBase {
constructor(apiKey?: string, openaiInstance?: OpenAI, baseURL?: string, model?: string, providerKey?: string);
protected createOpenAIInstance(config: LLMConfig): OpenAI;
protected getApiKey(): string;
protected getProviderName(): string;
getAvailableModels(): Promise<Array<{
id: string;
name: string;
provider: string;
}>>;
/**
* Create OpenRouter with model from remote config
* Falls back to env vars and defaults if remote config fails
*/
static createWithRemoteConfig(openRouterKey?: string, providerKey?: string, baseURL?: string): Promise<OpenRouter>;
/**
* Create OpenRouter specifically optimized for web fetching scenarios
* Uses pulse-ai-web-openrouter-model remote config
*/
static createForWebFetching(openRouterKey?: string, providerKey?: string, baseURL?: string): Promise<OpenRouter>;
/**
* Update the model from remote config
* Useful for long-running instances that need to pick up config changes
*/
updateModelFromRemoteConfig(useWebModel?: boolean): Promise<void>;
static forGemini(openRouterKey?: string, geminiKey?: string, model?: string): OpenRouter;
/**
* Create Gemini helper with model from remote config
*/
static forGeminiWithRemoteConfig(openRouterKey?: string, geminiKey?: string): Promise<OpenRouter>;
static forClaude(openRouterKey?: string, claudeKey?: string, model?: string): OpenRouter;
static forGPT(openRouterKey?: string, model?: string): OpenRouter;
}