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; /** * The two wire families a mixed OpenAI-compatible gateway (e.g. CLIProxyAPI) * can front. A gateway exposes an OpenAI-shaped `/v1/models` catalog but may * proxy Anthropic models that must be driven through the Anthropic Messages * transport rather than OpenAI Chat Completions. */ export type DiscoveredApiFamily = "anthropic-messages" | "openai-completions"; /** * Infer the wire API family for one discovered model on a mixed * OpenAI-compatible gateway. * * Uses the `owned_by` owner string first (authoritative when the gateway * populates it — `"anthropic"` / `"openai"`), then falls back to the model id * (`claude-*` → Anthropic, `gpt-*`/`o1`/`codex`/… → OpenAI). Returns * `undefined` when neither signal is conclusive so the caller can keep the * provider-level default instead of guessing. */ export declare function detectDiscoveredApiFamily(entry: { id?: unknown; owned_by?: unknown; }): DiscoveredApiFamily | undefined; /** * 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>;