import { type AIProviderInfo, type AIModelInfo } from '@pipeline-builder/api-core'; import type { LanguageModel } from 'ai'; /** Registered provider with model factory function. */ export interface ProviderEntry { info: AIProviderInfo; createModel: (modelId: string) => LanguageModel; } /** * Returns the list of providers that have API keys configured via env vars. * * @returns Array of configured provider info with model lists */ export declare function getAvailableProviders(): AIProviderInfo[]; /** * Returns the model list for a given provider ID (regardless of env var config). * * @param providerId - Provider identifier * @returns Array of models, or empty array if provider is unknown */ export declare function getProviderModels(providerId: string): AIModelInfo[]; /** * Resolve a LanguageModel from the registry for a configured provider. * * @param providerId - Provider identifier * @param modelId - Model identifier * @returns LanguageModel instance * @throws Error if provider is not configured or model is invalid */ export declare function resolveModel(providerId: string, modelId: string): LanguageModel; /** * Create a temporary LanguageModel using a custom API key (not cached in registry). * * @param providerId - Provider identifier * @param modelId - Model identifier * @param apiKey - Custom API key * @returns LanguageModel instance * @throws Error if provider or model is unknown */ export declare function createModelWithKey(providerId: string, modelId: string, apiKey: string): LanguageModel; /** What a caller asked for; every field optional (see {@link resolveModelSelection}). */ export interface ModelSelection { provider?: string; model?: string; /** Ephemeral bring-your-own key — the request is billed to it, never to a platform key. */ apiKey?: string; /** Platform providers to try, in order, with their first model if the requested one can't be resolved. */ fallbacks?: string[]; } /** A resolved model plus who actually serves it. */ export interface ResolvedModelSelection { model: LanguageModel; provider: string; modelId: string; /** Set when a fallback provider serves the request: the provider originally asked for. */ fallbackFrom?: string; } /** * Resolve a LanguageModel for a request: * - `provider` + `model` → use them (with an optional ephemeral BYO key); * - `provider` only → the provider's first catalog model; * - `model` only → error (ambiguous — the provider is unknown); * - neither → the first env-configured provider (a cloud key or the local * OpenAI-compatible endpoint) so AI features work out of the box. * * If the requested provider/model can't be resolved, `fallbacks` are tried in * order with each provider's first model — EXCEPT for a BYO-key request: the * fallbacks resolve through the platform's env-configured keys, which would * silently spend the platform's AI budget on a request the caller meant to bill * to their own key. A BYO failure is terminal. * * @throws Error when nothing resolves (the original error when fallbacks are exhausted) */ export declare function resolveModelSelection(selection: ModelSelection): ResolvedModelSelection;