import type { Api, FetchImpl, Model, Provider } from "../../types"; /** Catalog identities are rendered and used for routing; unsafe values are dropped, never rewritten. */ export declare function isSafeCatalogModelId(value: unknown): value is string; /** * Minimal OpenAI-style model entry shape consumed by discovery. * * Providers may return additional fields; this type only captures * fields that are useful for generic normalization. */ export interface OpenAICompatibleModelRecord { id?: unknown; name?: unknown; object?: unknown; owned_by?: unknown; [key: string]: unknown; } /** * Tolerant envelope for OpenAI-compatible `/models` responses. * * Common providers return `{ data: [...] }`, but variants such as * `{ models: [...] }`, `{ result: [...] }`, or direct arrays are also * accepted during extraction. */ export interface OpenAICompatibleModelsEnvelope { data?: unknown; models?: unknown; result?: unknown; items?: unknown; [key: string]: unknown; } /** * Context passed to custom OpenAI-compatible model mappers. */ export interface OpenAICompatibleModelMapperContext { api: TApi; provider: Provider; baseUrl: string; } /** * Options for fetching and normalizing OpenAI-compatible `/models` catalogs. */ export interface FetchOpenAICompatibleModelsOptions { /** API type assigned to normalized models. */ api: TApi; /** Provider id assigned to normalized models. */ provider: Provider; /** Provider base URL used for both fetch and normalized model records. */ baseUrl: string; /** Optional bearer token for Authorization header. */ apiKey?: string; /** Additional request headers. */ headers?: Record; /** Optional AbortSignal for request cancellation. */ signal?: AbortSignal; /** Optional fetch implementation override for testing/custom runtimes. */ fetch?: FetchImpl; /** Optional HTTP status predicate for provider-specific hard failures. */ throwOnStatus?: (response: Response) => Error | undefined; /** * Optional post-normalization filter. * Return false to skip a model. */ filterModel?: (entry: OpenAICompatibleModelRecord, model: Model) => boolean; /** * Optional mapper override for provider-specific quirks. * Return null to skip a model. */ mapModel?: (entry: OpenAICompatibleModelRecord, defaults: Model, context: OpenAICompatibleModelMapperContext) => Model | null; } /** * Resolves an endpoint for an implicit local provider without allowing an * environment override to turn its keyless discovery into a remote request. */ export declare function resolveLoopbackOpenAIBaseUrl(value: string | undefined, fallback: string): string; /** * Fetches and normalizes an OpenAI-compatible `/models` catalog. * * Returns `null` on transport/protocol failures. * Returns `[]` only when the endpoint responds successfully with no usable models. */ export declare function fetchOpenAICompatibleModels(options: FetchOpenAICompatibleModelsOptions): Promise[] | null>;