/** * Request interface for creating a task */ export interface KieCreateTaskRequest { model: string; input: Record; callBackUrl?: string; } export interface KieCreateTaskResponse { code: number; message: string; data: { taskId: string; status: string; }; } export interface KieTaskStatusResponse { code: number; msg: string; data: { taskId: string; model: string; state: 'waiting' | 'queuing' | 'generating' | 'success' | 'fail'; resultJson?: string; failCode?: string | null; failMsg?: string | null; costTime?: number; completeTime?: number; createTime?: number; }; } export interface KieTaskOutput { url: string; type: 'image' | 'video' | 'audio' | 'text'; duration?: number; width?: number; height?: number; } export declare class KieApiError extends Error { code: number; response?: unknown | undefined; constructor(code: number, message: string, response?: unknown | undefined); } /** * Kie.ai API client */ export declare class KieClient { private baseUrl; constructor(baseUrl?: string); /** * Get the API key from config */ private getApiKey; /** * Make an authenticated request to the Kie.ai API */ private request; /** * Create a new task */ createTask(request: KieCreateTaskRequest): Promise; /** * Get task status */ getTaskStatus(taskId: string): Promise; /** * Check if the client is configured */ isConfigured(): boolean; /** * Make a generic request (for Suno endpoints that don't fit the standard pattern) */ private requestRaw; /** * Generate music using Suno API */ generateMusic(params: { prompt: string; customMode: boolean; instrumental: boolean; model: string; callBackUrl: string; style?: string; title?: string; negativeTags?: string; vocalGender?: 'm' | 'f'; styleWeight?: number; weirdnessConstraint?: number; audioWeight?: number; personaId?: string; }): Promise<{ code: number; msg: string; data: { taskId: string; }; }>; /** * Get music generation status */ getMusicStatus(taskId: string): Promise<{ code: number; msg: string; data: { taskId: string; parentMusicId?: string; param?: string; response?: { taskId: string; sunoData?: Array<{ id: string; audioUrl?: string; streamAudioUrl?: string; imageUrl?: string; prompt?: string; modelName?: string; title?: string; tags?: string; createTime?: string; duration?: number; }>; }; status: 'PENDING' | 'TEXT_SUCCESS' | 'FIRST_SUCCESS' | 'SUCCESS' | 'CREATE_TASK_FAILED' | 'GENERATE_AUDIO_FAILED' | 'CALLBACK_EXCEPTION' | 'SENSITIVE_WORD_ERROR'; type?: string; errorCode?: string | null; errorMessage?: string | null; }; }>; /** * Generate lyrics using Suno API */ generateLyrics(params: { prompt: string; callBackUrl: string; }): Promise<{ code: number; msg: string; data: { taskId: string; }; }>; /** * Get lyrics generation status */ getLyricsStatus(taskId: string): Promise<{ code: number; msg: string; data: { taskId: string; param?: string; response?: { taskId: string; data?: Array<{ text: string; title: string; status: string; errorMessage?: string; }>; }; status: 'PENDING' | 'SUCCESS' | 'CREATE_TASK_FAILED' | 'GENERATE_LYRICS_FAILED' | 'CALLBACK_EXCEPTION' | 'SENSITIVE_WORD_ERROR'; type?: string; errorCode?: string | null; errorMessage?: string | null; }; }>; /** * Get timestamped lyrics for a music track */ getTimestampedLyrics(params: { taskId: string; audioId: string; }): Promise<{ code: number; msg: string; data: { alignedWords: Array<{ word: string; success: boolean; startS: number; endS: number; palign: number; }>; waveformData: number[]; hootCer: number; isStreamed: boolean; }; }>; /** * Create music video */ createMusicVideo(params: { taskId: string; audioId: string; callBackUrl: string; author?: string; domainName?: string; }): Promise<{ code: number; msg: string; data: { taskId: string; }; }>; /** * Get music video generation status */ getMusicVideoStatus(taskId: string): Promise<{ code: number; msg: string; data: { taskId: string; musicId?: string; callbackUrl?: string; musicIndex?: number; completeTime?: string; response?: { videoUrl?: string; }; successFlag: 'PENDING' | 'SUCCESS' | 'CREATE_TASK_FAILED' | 'GENERATE_MP4_FAILED'; createTime?: string; errorCode?: string | null; errorMessage?: string | null; }; }>; }