/** * kosha-discovery — OpenRouter aggregator discoverer. * * OpenRouter is a unified gateway that proxies requests to many upstream * providers (OpenAI, Anthropic, Google, Meta, Mistral, etc.). Its model * list endpoint returns rich metadata including pricing, context lengths, * and architecture info — making it one of the most informative sources. * @module */ import type { CredentialResult, ModelCard } from "../types.js"; import { BaseDiscoverer } from "./base.js"; /** * Discovers models available through the OpenRouter aggregator. * * OpenRouter acts as a single gateway to dozens of providers. Its model * list is publicly accessible (no API key required), though an * authenticated request gets higher rate limits. */ export declare class OpenRouterDiscoverer extends BaseDiscoverer { readonly providerId = "openrouter"; readonly providerName = "OpenRouter"; readonly baseUrl = "https://openrouter.ai"; /** * Fetch the full model catalogue from OpenRouter. * * @param credential - API key is **optional** for this provider. * The endpoint works without auth, just with stricter rate limits. * @param options - Optional timeout override (default 15 s — larger because the * response contains hundreds of models). */ discover(credential: CredentialResult, options?: { timeout?: number; }): Promise; /** * Filter out unavailable models. OpenRouter marks delisted models * with `pricing.prompt === "-1"`. */ private isAvailable; /** Convert an OpenRouter model object into a normalized {@link ModelCard}. */ private toModelCard; /** * Extract the canonical origin-provider slug from an OpenRouter compound * model ID of the form `{vendor}/{model-name}`. * * Delegates to the shared normalizer (`extractOriginProvider` in * `src/normalize.ts`) so the vendor→origin mapping lives in one place * rather than being re-maintained per discoverer. OpenRouter IDs are * always vendor-namespaced; when the canonical helper doesn't recognise * the vendor we fall back to the raw prefix (e.g. `"stabilityai"`, * `"nvidia"`) rather than collapsing to the serving provider, because * the prefix still identifies the original creator. * * @param modelId - Raw OpenRouter model ID. * @returns Canonical provider slug (e.g. `"anthropic"`, `"meta"`, `"openai"`), * or the raw vendor prefix when the creator is unknown. */ private extractOriginProvider; /** * Derive lifecycle status and deprecation date from OpenRouter's * `expiration_date` signal. * * OpenRouter surfaces a single sunset signal per model: `expiration_date` * — an ISO date string (or `null`) describing when the endpoint goes away. * We map it conservatively, mirroring the convention used by the litellm * enricher's `inferStatus`: * - date in the future → `"deprecated"` (still served, plan migration) * - date in the past → `"retired"` (sunset has passed) * - `null` / absent → no status (treated as active downstream) * * OpenRouter does not publish a successor model, so `replacedBy` is left * untouched here. * * @param expirationDate - Raw `expiration_date` from the OpenRouter payload. * @returns Partial lifecycle fields to merge into the {@link ModelCard}; * keys are omitted entirely when no signal is present. */ private inferLifecycleStatus; /** Infer the primary {@link ModelMode} from modality and naming patterns. */ private inferMode; /** * Infer capability flags from architecture modality and model ID. */ private inferCapabilities; /** * Heuristic to identify "modern chat models" that support structured * tool use (function calling), code generation, and NLU. * * We match on known provider/model family prefixes. This is intentionally * broad — false positives are benign (extra capability flags), while false * negatives would hide useful features. */ private isModernChatModel; /** * Parse OpenRouter's per-token pricing into our per-million format. * * OpenRouter returns pricing as **cost per single token** (stringified * floats). We multiply by 1,000,000 to convert to our standard * per-million-token pricing representation. */ private parsePricing; } //# sourceMappingURL=openrouter.d.ts.map