import type { AssistantMessageEventStream } from './utils/event-stream.js';
export type { AssistantMessageEventStream } from './utils/event-stream.js';
export type KnownApi = 'openai-completions' | 'openai-responses' | 'azure-openai-responses' | 'anthropic-messages' | 'google-generative-ai' | 'google-vertex';
export type Api = KnownApi | (string & {});
export type KnownProvider = 'anthropic' | 'google' | 'google-vertex' | 'openai' | 'azure-openai-responses' | 'xai' | 'groq' | 'cerebras' | 'openrouter' | 'vercel-ai-gateway' | 'zai' | 'minimax' | 'minimax-cn' | 'huggingface' | 'opencode' | 'kimi-coding';
export type Provider = KnownProvider | string;
export type ThinkingLevel = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
export type CacheRetention = 'none' | 'short' | 'long';
export type Transport = 'sse' | 'websocket' | 'auto';
export interface StreamOptions {
    temperature?: number;
    maxTokens?: number;
    signal?: AbortSignal;
    apiKey?: string;
    /**
     * Preferred transport for providers that support multiple transports.
     * Providers that do not support this option ignore it.
     */
    transport?: Transport;
    /**
     * Prompt cache retention preference. Providers map this to their supported values.
     * Default: "short".
     */
    cacheRetention?: CacheRetention;
    /**
     * Optional session identifier for providers that support session-based caching.
     * Providers can use this to enable prompt caching, request routing, or other
     * session-aware features. Ignored by providers that don't support it.
     */
    sessionId?: string;
    /**
     * Optional callback for inspecting provider payloads before sending.
     */
    onPayload?: (payload: unknown) => void;
    /**
     * Optional fetch settings for provider SDK calls.
     *
     * This is primarily used by first-party gateway transports that need browser
     * cookies for auth; direct provider calls should normally leave it unset.
     */
    fetchOptions?: RequestInit;
    /**
     * Optional custom HTTP headers to include in API requests.
     * Merged with provider defaults; can override default headers.
     * Not supported by all providers.
     */
    headers?: Record<string, string>;
    /**
     * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.
     * If the server's requested delay exceeds this value, the request fails immediately
     * with an error containing the requested delay, allowing higher-level retry logic
     * to handle it with user visibility.
     * Default: 60000 (60 seconds). Set to 0 to disable the cap.
     */
    maxRetryDelayMs?: number;
    /**
     * Optional metadata to include in API requests.
     * Providers extract the fields they understand and ignore the rest.
     * For example, Anthropic uses `user_id` for abuse tracking and rate limiting.
     */
    metadata?: Record<string, unknown>;
}
export type ProviderStreamOptions = StreamOptions & Record<string, unknown>;
export interface SimpleStreamOptions extends StreamOptions {
    reasoning?: ThinkingLevel;
}
export type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (model: Model<TApi>, context: Context, options?: TOptions) => AssistantMessageEventStream;
export type StreamFn = StreamFunction;
export interface TextContent {
    type: 'text';
    text: string;
    textSignature?: string;
}
export interface ThinkingContent {
    type: 'thinking';
    thinking: string;
    thinkingSignature?: string;
    /** When true, the thinking content was redacted by safety filters. The opaque
     *  encrypted payload is stored in `thinkingSignature` so it can be passed back
     *  to the API for multi-turn continuity. */
    redacted?: boolean;
}
export interface ImageContent {
    type: 'image';
    data: string;
    mimeType: string;
}
export interface DocumentContent {
    type: 'document';
    data: string;
    filename?: string;
    mimeType: string;
}
export type UserContent = TextContent | ImageContent | DocumentContent;
export type ToolResultContent = TextContent | ImageContent | DocumentContent;
export type AssistantContent = TextContent | ThinkingContent | ToolCall;
export interface ToolCall {
    type: 'toolCall';
    id: string;
    name: string;
    arguments: Record<string, any>;
    thoughtSignature?: string;
}
export interface Usage {
    /** Total input tokens, including cache read/write buckets when present. */
    input: number;
    output: number;
    cacheRead: number;
    cacheWrite: number;
    totalTokens: number;
    cost: {
        input: number;
        output: number;
        cacheRead: number;
        cacheWrite: number;
        total: number;
    };
}
export type StopReason = 'stop' | 'length' | 'toolUse' | 'error' | 'aborted';
export interface UserMessage {
    role: 'user';
    content: string | UserContent[];
    timestamp: number;
}
export interface AssistantMessage {
    role: 'assistant';
    content: AssistantContent[];
    api: Api;
    provider: Provider;
    model: string;
    usage: Usage;
    stopReason: StopReason;
    errorMessage?: string;
    timestamp: number;
}
export interface ToolResultMessage<TDetails = any> {
    role: 'toolResult';
    toolCallId: string;
    toolName: string;
    content: ToolResultContent[];
    details?: TDetails;
    isError: boolean;
    timestamp: number;
}
export type Message = UserMessage | AssistantMessage | ToolResultMessage;
import type { TSchema } from '@sinclair/typebox';
export interface Tool<TParameters extends TSchema = TSchema> {
    name: string;
    description: string;
    parameters: TParameters;
}
export interface Context {
    systemPrompt?: string;
    messages: Message[];
    tools?: Tool[];
}
export type AssistantMessageEvent = {
    type: 'start';
    partial: AssistantMessage;
} | {
    type: 'text_start';
    contentIndex: number;
    partial: AssistantMessage;
} | {
    type: 'text_delta';
    contentIndex: number;
    delta: string;
    partial: AssistantMessage;
} | {
    type: 'text_end';
    contentIndex: number;
    content: string;
    partial: AssistantMessage;
} | {
    type: 'thinking_start';
    contentIndex: number;
    partial: AssistantMessage;
} | {
    type: 'thinking_delta';
    contentIndex: number;
    delta: string;
    partial: AssistantMessage;
} | {
    type: 'thinking_end';
    contentIndex: number;
    content: string;
    partial: AssistantMessage;
} | {
    type: 'toolcall_start';
    contentIndex: number;
    partial: AssistantMessage;
} | {
    type: 'toolcall_delta';
    contentIndex: number;
    delta: string;
    partial: AssistantMessage;
} | {
    type: 'toolcall_end';
    contentIndex: number;
    toolCall: ToolCall;
    partial: AssistantMessage;
} | {
    type: 'done';
    reason: Extract<StopReason, 'stop' | 'length' | 'toolUse'>;
    message: AssistantMessage;
} | {
    type: 'error';
    reason: Extract<StopReason, 'aborted' | 'error'>;
    error: AssistantMessage;
};
/**
 * Compatibility settings for OpenAI-compatible completions APIs.
 * Use this to override URL-based auto-detection for custom providers.
 */
export interface OpenAICompletionsCompat {
    /** Whether the provider supports the `store` field. Default: auto-detected from URL. */
    supportsStore?: boolean;
    /** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */
    supportsDeveloperRole?: boolean;
    /** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */
    supportsReasoningEffort?: boolean;
    /** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */
    supportsUsageInStreaming?: boolean;
    /** Which field to use for max tokens. Default: auto-detected from URL. */
    maxTokensField?: 'max_completion_tokens' | 'max_tokens';
    /** Whether tool results require the `name` field. Default: auto-detected from URL. */
    requiresToolResultName?: boolean;
    /** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */
    requiresAssistantAfterToolResult?: boolean;
    /** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */
    requiresThinkingAsText?: boolean;
    /** Whether tool call IDs must be normalized to Mistral format (exactly 9 alphanumeric chars). Default: auto-detected from URL. */
    requiresMistralToolIds?: boolean;
    /** Format for reasoning/thinking parameter. "openai" uses reasoning_effort, "zai" uses thinking: { type: "enabled" }, "qwen" uses enable_thinking: boolean. Default: "openai". */
    thinkingFormat?: 'openai' | 'zai' | 'qwen';
    /** OpenRouter-specific routing preferences. Only used when baseUrl points to OpenRouter. */
    openRouterRouting?: OpenRouterRouting;
    /** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */
    vercelGatewayRouting?: VercelGatewayRouting;
    /** Whether the provider supports the `strict` field in tool definitions. Default: true. */
    supportsStrictMode?: boolean;
}
/**
 * OpenRouter provider routing preferences.
 * Controls which upstream providers OpenRouter routes requests to.
 * @see https://openrouter.ai/docs/provider-routing
 */
export interface OpenRouterRouting {
    /** List of provider slugs to exclusively use for this request (e.g., ["anthropic"]). */
    only?: string[];
    /** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
    order?: string[];
}
/**
 * Vercel AI Gateway routing preferences.
 * Controls which upstream providers the gateway routes requests to.
 * @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options
 */
export interface VercelGatewayRouting {
    /** List of provider slugs to exclusively use for this request (e.g., ["bedrock", "anthropic"]). */
    only?: string[];
    /** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
    order?: string[];
}
export interface Model<TApi extends Api> {
    id: string;
    name: string;
    api: TApi;
    provider: Provider;
    baseUrl: string;
    reasoning: boolean;
    input: ('text' | 'image')[];
    cost: {
        input: number;
        output: number;
        cacheRead: number;
        cacheWrite: number;
    };
    contextWindow: number;
    maxTokens: number;
    headers?: Record<string, string>;
    /** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */
    compat?: TApi extends 'openai-completions' ? OpenAICompletionsCompat : never;
}
//# sourceMappingURL=types.d.ts.map