import { AIProviderName } from "../constants/enums.js"; import type { NeurolinkCredentials } from "../types/index.js"; import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js"; /** * OpenRouter Provider — direct HTTP, no AI SDK. * * OpenAI-compatible unified gateway to 300+ models from 60+ providers. All * request/stream/tool-loop orchestration lives in * `OpenAIChatCompletionsProvider`; this class declares configuration plus the * OpenRouter-specific behaviour: * * 1. Attribution headers — optional `HTTP-Referer` / `X-Title` (from * `OPENROUTER_REFERER` / `OPENROUTER_APP_NAME`) are merged into every * request via `getAuthHeaders` so usage shows up on the openrouter.ai * activity dashboard. * 2. Per-model tool gating — OpenRouter proxies many models with varying * tool support, so `supportsTools()` consults a cached capability set * (populated by `cacheModelCapabilities()`) and falls back to a * conservative known-capable pattern list. * 3. Dynamic model discovery — `getAvailableModels()` fetches the live * `/models` list (10-minute cache) with a hardcoded fallback. * * @see https://openrouter.ai/docs */ export declare class OpenRouterProvider extends OpenAIChatCompletionsProvider { private readonly referer?; private readonly appName?; private static modelsCache; private static modelsCacheTime; private static readonly MODELS_CACHE_DURATION; private static toolCapableModels; private static capabilitiesCached; constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["openrouter"]); protected getProviderName(): AIProviderName; protected getDefaultModel(): string; protected formatProviderError(error: unknown): Error; protected getFallbackModelName(): string; /** * Attribution headers are merged into every request alongside the bearer * token so OpenRouter can attribute usage on its activity dashboard. */ protected getAuthHeaders(): Record; /** * OpenRouter proxies models with varying tool support. Use cached * capabilities when available (populated by `cacheModelCapabilities()`), * otherwise fall back to a conservative known-capable pattern list and * disable tools for unknown models. */ supportsTools(): boolean; /** * Models/capabilities endpoint, derived from the configured `baseURL` so a * custom OpenRouter-compatible gateway is honoured for discovery too. */ private getModelsUrl; /** * Get available models from the OpenRouter `/models` endpoint, with a * 10-minute cache and a hardcoded fallback when the fetch fails. */ getAvailableModels(): Promise; /** * Fetch available models from the OpenRouter `/models` endpoint. * @private */ private fetchModelsFromAPI; /** * Type guard to validate the models API response structure. * @private */ private isValidModelsResponse; /** * Fetch and cache model capabilities from the OpenRouter `/models` endpoint. * Call this to enable accurate per-model tool support detection. */ cacheModelCapabilities(): Promise; }