import type { SharedV4ProviderMetadata, SharedV4ProviderOptions } from "@ai-sdk/provider"; import { type JSONValue, type ToolSet, type ModelMessage, type ToolChoice, type Output, type StopCondition } from "ai"; import type { ReasoningConfig, ReasoningEffort, CacheControl, ServiceTier } from "./schema"; /** * Runtime context type parameter for the AI SDK result types. * The gateway does not use runtime context, and `ai` does not re-export its * own `Context` alias, so mirror it here. */ export type RuntimeContext = Record; export type ToolChoiceOptions = { toolChoice?: ToolChoice; activeTools?: string[]; }; export type TextCallOptions = { messages: ModelMessage[]; tools?: ToolSet; toolChoice?: ToolChoice; activeTools?: string[]; output?: Output.Output; temperature?: number; maxOutputTokens?: number; frequencyPenalty?: number; presencePenalty?: number; seed?: number; topP?: number; stopSequences?: string[]; stopWhen?: StopCondition | Array>; providerOptions: SharedV4ProviderOptions; }; export declare function parseJsonOrText(content: string): { type: "json"; value: JSONValue; } | { type: "text"; value: string; }; export declare function parseBase64(base64: string): Uint8Array; /** * Parses arbitrary file input, which OpenAI clients send either as a data URL * (`data:application/pdf;base64,...`) or as bare base64. Returns the base64 * payload plus the declared media type when the data URL carried one. */ export declare function parseFileInput(data: string): { data: string; mediaType?: string; }; export declare function parseImageInput(url: string): { image: string | URL; mediaType?: string; }; export declare function parseReasoningOptions(reasoning_effort?: ReasoningEffort | null, reasoning?: ReasoningConfig | null): { reasoning: { enabled: boolean; effort: string; }; reasoning_effort: string; } | { reasoning?: undefined; reasoning_effort?: undefined; } | { reasoning: ReasoningConfig; reasoning_effort?: ReasoningEffort; }; export declare function parsePromptCachingOptions(prompt_cache_key?: string, prompt_cache_retention?: "in-memory" | "24h", cache_control?: CacheControl): Record; export declare function resolveResponseServiceTier(providerMetadata?: SharedV4ProviderMetadata): ServiceTier | undefined; export declare function normalizeToolName(name: string): string; export declare function stripEmptyKeys(obj: unknown): unknown; /** * `reasoning_details[].format` tags, as enumerated by OpenRouter. Clients use them to * tell which convention an opaque reasoning blob follows. * https://openrouter.ai/docs/use-cases/reasoning-tokens */ export type ReasoningFormat = "unknown" | "anthropic-claude-v1" | "google-gemini-v1" | "openai-responses-v1" | "azure-openai-responses-v1" | "xai-responses-v1"; export declare const GEMINI_REASONING_FORMAT = "google-gemini-v1"; export type ReasoningMetadata = { /** Anthropic thinking signature. */ signature?: string; /** Anthropic redacted thinking. */ redactedData?: string; /** OpenAI encrypted reasoning trace. */ encryptedContent?: string; /** OpenAI reasoning item id, the correlation key for its trace. */ itemId?: string; /** Gemini thought signature. */ thoughtSignature?: string; /** Convention followed by the blobs above, from the namespace they were found in. */ format: ReasoningFormat; }; /** * Collects the opaque reasoning artifacts a provider attaches to a reasoning, text or * tool-call part. Namespaces are scanned rather than named so a new host of the same * model needs no code change; both spellings of each key are read because the params * middleware snakizes response metadata. */ export declare function extractReasoningMetadata(providerMetadata?: SharedV4ProviderMetadata): ReasoningMetadata;