/** HTTP methods supported by the SDK. */ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'; /** Query parameters for HTTP requests. Null and undefined values are omitted. */ type QueryParams = Record; /** * Configuration options for API clients. * * @example * ```typescript * const client = new SunoClient({ * apiKey: 'your-api-key', * baseUrl: 'https://runapi.ai', * timeoutMs: 60000, * maxRetries: 3, * }); * ``` */ interface ClientOptions { /** * API key for authentication. If omitted, the SDK reads * `RUNAPI_API_KEY` from the environment (Node runtimes only). */ apiKey?: string; /** Base URL for API requests. Defaults to `https://runapi.ai`. */ baseUrl?: string; /** Request timeout in milliseconds. Defaults to 900000 (15 minutes). */ timeoutMs?: number; /** Maximum number of retry attempts. Defaults to 2. */ maxRetries?: number; /** Base delay between retries in milliseconds. Defaults to 500. */ retryBaseDelayMs?: number; /** Maximum delay between retries in milliseconds. Defaults to 5000. */ retryMaxDelayMs?: number; /** Custom `fetch` implementation. Defaults to the global `fetch`. */ fetch?: typeof fetch; /** * Extra options passed to every `fetch` call (e.g. `cache`, `credentials`, `keepalive`). * SDK-managed fields (`method`, `headers`, `body`, `signal`) cannot be overridden. */ fetchOptions?: Omit; } /** * Per-request options that override client-level defaults. * * @example * ```typescript * await client.textToImage.run( * { prompt: 'A sunset' }, * { timeoutMs: 30000, headers: { 'X-Custom': 'value' } } * ); * ``` */ interface RequestOptions { /** Additional HTTP headers. Merged with client-level headers. */ headers?: Record; /** Request timeout in milliseconds. Overrides client-level timeout. */ timeoutMs?: number; /** Maximum retry attempts. Overrides client-level maxRetries. */ maxRetries?: number; /** Abort signal for request cancellation. */ signal?: AbortSignal; /** * Per-request fetch options that override client-level `fetchOptions`. * SDK-managed fields (`method`, `headers`, `body`, `signal`) cannot be overridden. */ fetchOptions?: Omit; } /** * Options for polling async task completion. * Used internally by resource `run()` methods. */ interface PollingOptions { /** Polling interval in milliseconds. Defaults to 2000 (2 seconds). */ pollIntervalMs?: number; /** Maximum wait time in milliseconds. Defaults to 900000 (15 minutes). */ maxWaitMs?: number; } /** Task status values returned by async operations. */ type TaskStatus = 'pending' | 'processing' | 'completed' | 'failed'; /** * Status for async task results (excludes 'pending'). * Used for polling results that have already started processing. */ type AsyncTaskStatus = Exclude; /** * Persisted billing facts included in every task-based media response. * Create responses do not always have a status, so they use this separately * from TaskResponse. */ interface TaskBillingResponse { /** * Persisted billing facts for this Task. Older or incomplete responses may * omit this field; once present, unavailable individual facts are `null`. */ billing?: TaskBillingFacts; } /** * Response structure for async task operations. * Specific API methods extend this with additional fields. */ interface TaskResponse extends TaskBillingResponse { /** Task ID for tracking and retrieval. */ id?: string; /** Current task status. */ status: TaskStatus | string; /** Error message if task failed. */ error?: string; /** Additional task-specific fields. */ [key: string]: unknown; } interface TaskBillingFacts { reservation: TaskReservation | null; settlement: TaskSettlement | null; refund: TaskRefund | null; } interface TaskReservation { amount_cents: number; } interface TaskSettlement { charged_amount_cents: number; amount_micro_cents: number; } interface TaskRefund { refunded_at: string; } export type { AsyncTaskStatus as A, ClientOptions as C, HttpMethod as H, PollingOptions as P, QueryParams as Q, RequestOptions as R, TaskBillingFacts as T, TaskBillingResponse as a, TaskRefund as b, TaskReservation as c, TaskResponse as d, TaskSettlement as e, TaskStatus as f };