import { ProfileCatalogLane } from '@x12i/ai-profiles'; /** OpenRouter Models API — https://openrouter.ai/api/v1/models */ type OpenRouterOutputModality = "text" | "image" | "audio" | "embeddings" | "video" | "speech" | "transcription" | "all"; type OpenRouterModelsQuery = { /** Comma-separated or "all" — default on our sync is "all". */ output_modalities?: string; supported_parameters?: string; }; type OpenRouterPricingApi = { prompt: string; completion: string; request: string; image: string; web_search?: string; internal_reasoning?: string; input_cache_read?: string; input_cache_write?: string; }; type OpenRouterArchitectureApi = { modality?: string; input_modalities: string[]; output_modalities: string[]; tokenizer: string; instruct_type: string | null; }; type OpenRouterTopProviderApi = { context_length: number; max_completion_tokens: number | null; is_moderated: boolean; }; type OpenRouterDefaultParametersApi = { temperature?: number | null; top_p?: number | null; top_k?: number | null; frequency_penalty?: number | null; presence_penalty?: number | null; repetition_penalty?: number | null; }; type OpenRouterModelApi = { id: string; canonical_slug: string; hugging_face_id?: string | null; name: string; created: number; description: string; context_length: number; architecture: OpenRouterArchitectureApi; pricing: OpenRouterPricingApi; top_provider: OpenRouterTopProviderApi; per_request_limits: unknown | null; supported_parameters: string[]; default_parameters: OpenRouterDefaultParametersApi | null; supported_voices?: unknown | null; knowledge_cutoff?: string | null; expiration_date?: string | null; links?: { details?: string; } | null; }; type OpenRouterModelsResponse = { data: OpenRouterModelApi[]; }; type AiModelPricing = { promptUsdPerToken: number; completionUsdPerToken: number; imageUsdPerUnit: number; requestUsdPerRequest: number; cacheReadUsdPerToken?: number; cacheWriteUsdPerToken?: number; reasoningUsdPerToken?: number; webSearchUsdPerRequest?: number; openRouterMarkupUsdPerInputToken?: number; openRouterMarkupUsdPerOutputToken?: number; pricedAt: string; source: "openrouter" | "direct" | "manual"; }; /** * Canonical catalog record — mirrors OpenRouter Models API fields plus normalized pricing. * Canonical catalog record loaded from x12i open-assets JSON catalogs. */ type AiModelRecord = { modelId: string; name: string; providerId: string; canonicalSlug: string; status: "active" | "deprecated" | "unknown"; description: string; created: number; expirationDate: string | null; contextLength: number; maxCompletionTokens: number | null; isModerated: boolean; modality: string; inputModalities: string[]; outputModalities: string[]; tokenizer: string; instructType: string | null; supportedParameters: string[]; defaultParameters: OpenRouterDefaultParametersApi | null; perRequestLimits: unknown | null; pricing: AiModelPricing; /** Raw OpenRouter pricing strings (USD per token/request/unit). */ openRouterPricing: OpenRouterPricingApi; architecture: OpenRouterArchitectureApi; topProvider: OpenRouterTopProviderApi; /** Full OpenRouter API object — complete mirror for forward compatibility. */ openRouter: OpenRouterModelApi; aliases: string[]; availableOnOpenRouter: boolean; supportsStreaming: boolean; supportsTools: boolean; /** Exposes reasoning/thinking tokens (OpenRouter `reasoning` param and/or `internal_reasoning` pricing). */ supportsReasoning: boolean; primaryOutputModality: string; syncedAt: string; syncSource: "openrouter" | "manual"; }; type ModelListFilters = { providerId?: string; status?: AiModelRecord["status"]; outputModality?: string; inputModality?: string; supportedParameter?: string; supportsTools?: boolean; supportsReasoning?: boolean; search?: string; limit?: number; offset?: number; }; type ModelListResult = { models: AiModelRecord[]; total: number; limit: number; offset: number; }; /** * Env naming for vendor direct API keys: `{VENDOR}_API_KEY` * where VENDOR is the provider id in UPPER_SNAKE (hyphens → underscores). * * Examples: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `META_LLAMA_API_KEY`, `X_AI_API_KEY` */ declare function providerIdToEnvKeyPrefix(providerId: string): string; declare function vendorApiKeyEnvName(providerId: string): string; type OpenRouterRoutingConfig = { /** OPENROUTER_API_KEY is set and non-empty */ hasOpenRouterKey: boolean; /** From PREFER_OPENROUTER env; defaults to true when unset */ preferOpenRouter: boolean; /** Read `{PROVIDER}_API_KEY` for a catalog provider id */ getVendorApiKey(providerId: string): string | undefined; }; /** * Load routing hints from process env and optional `.env` (via @x12/env). */ declare function loadOpenRouterRoutingEnv(env?: Record): OpenRouterRoutingConfig; /** * Default route via OpenRouter when: * 1. OPENROUTER_API_KEY is set AND PREFER_OPENROUTER is true (default), or * 2. OPENROUTER_API_KEY is set AND the vendor's `{VENDOR}_API_KEY` is missing. */ declare function shouldDefaultRouteViaOpenRouter(providerId: string | undefined, config: OpenRouterRoutingConfig): boolean; type EffectiveOpenRouterTransportInput = { provider?: string; modelId?: string; routeViaOpenRouter?: boolean; }; /** * Whether the effective runtime transport is OpenRouter. * Honors explicit gateway override, then env defaults from {@link loadOpenRouterRoutingEnv}. */ declare function isEffectiveOpenRouterTransport(config: OpenRouterRoutingConfig, input?: EffectiveOpenRouterTransportInput): boolean; type ModelResolutionInput = { /** Provider hint (openrouter, openai, anthropic, …). May be omitted. */ provider?: string; /** Model id or partial name. Required. */ model: string; }; type ResolutionStrategy = "exact-match" | "catalog-alias-match" | "canonical-slug-match" | "provider-prefix-injection" | "cross-provider-correction" | "version-suffix-strip" | "date-suffix-strip" | "partial-name-match" | "local-provider-passthrough" | "ai-profiles-profile" | "ai-profiles-model-id"; type ModelResolutionSuccess = { found: true; modelId: string; record: AiModelRecord | null; routedViaOpenRouter: boolean; confidence: number; resolvedVia: ResolutionStrategy[]; resolvedReason: string; normalisedInput: string; /** Set when resolution went through @x12i/ai-profiles. */ profile?: string; choice?: string; }; type ModelResolutionNotFound = { found: false; modelId: null; record: null; attemptedStrategies: ResolutionStrategy[]; bestRejectedCandidate?: { modelId: string; confidence: number; reason: string; }; reason: string; }; type ModelResolutionResult = ModelResolutionSuccess | ModelResolutionNotFound; type ModelResolverOptions = { confidenceThreshold?: number; additionalProviderPatterns?: Array<{ pattern: RegExp; provider: string; }>; additionalLocalProviders?: string[]; /** Env-based OpenRouter vs direct routing. Defaults to loadOpenRouterRoutingEnv(). */ routingEnv?: OpenRouterRoutingConfig; /** * Explicit transport override from gateway/router. * When true, treat as OpenRouter regardless of vendor API keys. * When false, treat as direct regardless of env defaults. */ routeViaOpenRouter?: boolean; /** OpenRouter catalog lane for @x12i/ai-profiles resolution (default `text`). */ catalogLane?: ProfileCatalogLane; }; type CatalogIndexes = { aliasIndex: Map; slugIndex: Map; providerPrefixesBySize: string[]; }; type ResolvedModel = { catalogModel: AiModelRecord; matchedKey: string; routedViaOpenRouter: boolean; }; export { type AiModelPricing as A, type CatalogIndexes as C, type ModelListFilters as M, type OpenRouterArchitectureApi as O, type ResolutionStrategy as R, type AiModelRecord as a, type ModelListResult as b, type ModelResolutionInput as c, type ModelResolutionNotFound as d, type ModelResolutionResult as e, type ModelResolutionSuccess as f, type ModelResolverOptions as g, type OpenRouterModelApi as h, type OpenRouterModelsQuery as i, type OpenRouterModelsResponse as j, type OpenRouterOutputModality as k, type OpenRouterPricingApi as l, type OpenRouterRoutingConfig as m, type OpenRouterTopProviderApi as n, type ResolvedModel as o, isEffectiveOpenRouterTransport as p, loadOpenRouterRoutingEnv as q, providerIdToEnvKeyPrefix as r, shouldDefaultRouteViaOpenRouter as s, vendorApiKeyEnvName as v };