UNPKG

@nomyx/assistant

Version:

A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)

58 lines (45 loc) 1.29 kB
import { ILogger } from '../../../types/common'; import { OpenRouterProviderConfig } from './types'; import { DEFAULT_OPENROUTER_MODEL } from './modelConfig'; export class OpenRouterConfig { private config: OpenRouterProviderConfig; private logger: ILogger; constructor(config: OpenRouterProviderConfig, logger: ILogger) { this.config = config; this.logger = logger; } get apiKey(): string { return this.config.apiKey; } get model(): string { return this.config.model || DEFAULT_OPENROUTER_MODEL; } get baseUrl(): string { return this.config.baseUrl || 'https://openrouter.ai/api/v1'; } get httpReferer(): string | undefined { return this.config.httpReferer; } get xTitle(): string | undefined { return this.config.xTitle; } getApiUrl(endpoint: string): string { return `${this.baseUrl}/${endpoint}`; } getHeaders(): Record<string, string> { const headers: Record<string, string> = { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json', }; if (this.httpReferer) { headers['HTTP-Referer'] = this.httpReferer; } if (this.xTitle) { headers['X-Title'] = this.xTitle; } return headers; } getLogger(): ILogger { return this.logger; } }