import { BaseProviderFetcher } from './base'; import { ProviderEntry, TogetherModel } from './types'; export class TogetherFetcher extends BaseProviderFetcher { name = 'together'; constructor(apiKey?: string) { super('https://api.together.ai', apiKey, { requestsPerMinute: 600 // Together rate limit from spec }); } async fetchModels(): Promise { try { const response = await this.fetchWithRetry( `${this.baseUrl}/v1/models` ); return response.map(model => this.mapModelToProviderEntry(model)); } catch (error) { console.error(`Failed to fetch Together models: ${error}`); return []; } } private mapModelToProviderEntry(model: TogetherModel): ProviderEntry { const entry: ProviderEntry = { provider: this.name, context_length: model.context_length, pricing: this.normalizePricing( model.pricing.input, model.pricing.output, 'per_million' ), owned_by: model.organization, model_type: model.type }; // Parse supported parameters from config if available if (model.config) { const configParams = this.parseConfigParameters(model.config); Object.assign(entry, configParams); } return entry; } private parseConfigParameters(config: TogetherModel['config']): Partial { const result: Partial = {}; // Check for stop sequences support if (config.stop && config.stop.length > 0) { result.supports_stop_sequences = true; } return result; } }