export type RtaErrorKind = 'auth' | 'scope' | 'billing' | 'not_found' | 'conflict' | 'too_large' | 'validation' | 'concurrency' | 'queue' | 'rate_limit' | 'upstream' | 'unavailable' | 'http' | 'network' | 'timeout' | 'cancelled'; /** A failed API call. `message` is redacted and never carries the raw body or headers. */ export declare class RtaApiError extends Error { readonly kind: RtaErrorKind; readonly status?: number | undefined; readonly code?: string | undefined; readonly retryable?: boolean | undefined; readonly billingUrl?: string | undefined; /** Queue contract on a capacity-full mint (429 without a code). */ readonly queue?: { queueSize: number; recommendedRetryMs: number; queueTicketId?: string; queuePosition?: number; } | undefined; constructor(kind: RtaErrorKind, message: string, status?: number | undefined, code?: string | undefined, retryable?: boolean | undefined, billingUrl?: string | undefined, /** Queue contract on a capacity-full mint (429 without a code). */ queue?: { queueSize: number; recommendedRetryMs: number; queueTicketId?: string; queuePosition?: number; } | undefined); } export interface RequestOptions { method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; /** Path relative to the API base, e.g. `/v1/avatars`. */ path: string; query?: Record; body?: unknown; idempotencyKey?: string; signal?: AbortSignal; timeoutMs: number; /** Bearer key for this request only. */ apiKey: string; /** * Retry once after a transient failure (429 rate limit, 502, 503, network * error), honouring Retry-After / recommended_retry_ms and the overall * timeout. Defaults to true for GET and false otherwise; idempotent POSTs * (session release) opt in. */ retry?: boolean; } export interface ApiResponse { status: number; /** Parsed JSON body, or null for 204 / empty bodies. */ json: unknown; } /** Build the error for a non-2xx response from the parsed body (never the raw text). */ export declare function classifyFailure(status: number, body: unknown, known: readonly string[]): RtaApiError; /** Longest wait a retry honours; a longer Retry-After is handed back to the caller as the error. */ export declare const MAX_RETRY_DELAY_MS = 5000; /** * How long a retry should wait: `Retry-After` (delay-seconds or HTTP-date), * else the body's `recommended_retry_ms`, else one second. */ export declare function retryDelayMs(retryAfter: string | null, body: unknown, now?: number): number; /** * Perform one request, retrying once after a transient failure when the * method is idempotent. The key is used for the Authorization header only. */ export declare function request(options: RequestOptions): Promise;