import { type Api, type Credential, type Model, type Provider } from "@bastani/pi-ai"; import type { ModelsJsonModelOverride } from "./model-config.ts"; /** Canonical suffix every selectable fast model variant carries. */ export declare const FAST_MODEL_ID_SUFFIX = "-fast"; /** Service tier OpenAI-style providers use to route fast traffic. */ export declare const FAST_MODEL_SERVICE_TIER: "priority"; /** Codex's Ultrafast tier, offered only for models that advertise it; access depends on the account. */ export declare const ULTRAFAST_MODEL_ID_SUFFIX = "-ultrafast"; export declare const ULTRAFAST_MODEL_SERVICE_TIER: "ultrafast"; /** Inference speed Anthropic's Messages API uses to route fast traffic. */ export declare const FAST_MODEL_SPEED: "fast"; /** * Claude models Anthropic's fast mode accepts. Requesting `speed: "fast"` on any other model is an * error, so the list is explicit rather than a family-name pattern. * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models */ export declare const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet; /** A derived fast variant that was suppressed because something already owns its exact model ID. */ export interface FastModelVariantDiagnostic { provider: string; /** The exact selectable model ID that collided. */ modelId: string; message: string; } export interface FastModelVariantDerivation { models: readonly Model[]; diagnostics: readonly FastModelVariantDiagnostic[]; } export interface DeriveFastModelVariantsOptions { /** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */ copilotFastModelIds?: readonly string[]; /** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */ modelOverrides?: Readonly>; /** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */ extensionOwnedApis?: ReadonlySet; /** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */ customModelIds?: ReadonlySet; } export interface FastModelVariantsOptions { /** * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises. * Read per call so a credential that lands after provider composition still takes effect. */ getCopilotFastModelIds?: () => readonly string[] | undefined; /** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */ getModelOverrides?: () => Readonly> | undefined; /** Read current custom model IDs per pass so models.json reloads update eligibility. */ getCustomModelIds?: () => ReadonlySet; /** * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call * because extensions register after initial composition on some paths. */ getExtensionOwnedApis?: () => ReadonlySet | undefined; /** Called after every derivation pass with the complete diagnostic list for this provider. */ onDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void; } /** Canonical selectable ID of the fast variant of `baseModelId`. */ export declare function fastModelId(baseModelId: string): string; /** * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on * any other API would silently degrade to an ordinary request. */ export declare function isNativeFastRouteApi(api: Api): api is "openai-responses" | "openai-codex-responses"; /** * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier. * * Eligibility requires both a first-party provider ID and an adapter that serializes * `service_tier`. A renamed provider, proxy, Azure (`azure`), OpenRouter * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant, * because selecting it would send an ordinary request under a name that promises otherwise. */ export declare function usesOpenAIFastServiceTier(model: Pick, "api" | "provider">): boolean; /** * xAI Priority Processing keeps the base upstream Grok model ID and adds the same * `service_tier: "priority"` field on the Responses API. xAI has no `-fast` model slugs for current * Grok models; priority is billed at twice the standard token rates, and only when the response * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing * * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI * Gateway, and renamed or proxied xAI-compatible providers do not qualify. */ export declare function usesXaiFastServiceTier(model: Pick, "api" | "provider">): boolean; /** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */ export declare function isGitHubCopilotModel(model: Pick, "provider">): boolean; /** * Anthropic fast mode keeps the base upstream model ID and adds `speed: "fast"` with the fast-mode beta. * * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model. * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a * renamed or proxied Anthropic-compatible provider. */ export declare function usesAnthropicFastMode(model: Pick, "api" | "id" | "provider">): boolean; /** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */ export declare function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined; /** * Whether a stored GitHub Copilot OAuth credential advertises this exact model ID at all — as a * selectable picker/policy model or as a fast sibling. * * Copilot's per-account advertisement is the authority the provider's own `filterModels` uses, so * restoration consults the same lists. An ID the account advertises as an ordinary model is ordinary, * whatever its name ends in. */ export declare function copilotAdvertisesModelId(credential: Credential | undefined, modelId: string): boolean; /** * Add a selectable `-fast` entry for every eligible model, carrying the explicit * {@link ModelFastRoute} metadata that gives it fast semantics. The input list is preserved verbatim * and in order; each derived entry is appended directly after the model it derives from. * * A model whose exact `-fast` ID is already owned by the provider, a `models.json` custom model, or an * extension wins: derivation is suppressed for it and a diagnostic is recorded. The owning model keeps * whatever semantics it declares, because fast behavior comes only from `fastRoute`, never from the * `-fast` suffix. For the same reason a base model whose ID already ends in `-fast` is never used to * derive a `-fast-fast` variant: that is not a canonical ID this scheme defines. * * A derived entry is a real catalog model, so a `modelOverrides` entry keyed on its exact `-fast` ID * applies to it after derivation. Without that pass the derived entry would inherit the *base* model's * overrides and its own would be silently inert. * * No variant is derived for an API whose transport a registered extension owns, because Atomic cannot * enforce the route through a transport it does not serialize. */ export declare function deriveFastModelVariants(providerId: string, models: readonly Model[], options?: DeriveFastModelVariantsOptions): FastModelVariantDerivation; /** * Overlay derived fast model variants onto a composed provider. Apply this after built-in, * `models.json`, extension, and `modelOverrides` composition so exact user-owned `-fast` IDs are * already present and win the collision. */ export declare function withFastModelVariants(provider: Provider, options?: FastModelVariantsOptions): Provider; //# sourceMappingURL=fast-model-variants.d.ts.map