const axios = require('axios'); async function aimusic(prompt, { tags = 'pop, romantic' } = {}) { try { if (!prompt) throw new Error('Prompt is required'); const { data: ai } = await axios.get('https://8pe3nv3qha.execute-api.us-east-1.amazonaws.com/default/llm_chat', { params: { query: JSON.stringify([ { role: 'system', content: 'You are a professional lyricist AI trained to write poetic and rhythmic song lyrics. Respond with lyrics only, using [verse], [chorus], [bridge], and [instrumental] or [inst] tags to structure the song. Use only the tag (e.g., [verse]) without any numbering or extra text (e.g., do not write [verse 1], [chorus x2], etc). Do not add explanations, titles, or any other text outside of the lyrics. Focus on vivid imagery, emotional flow, and strong lyrical rhythm. Refrain from labeling genre or giving commentary. Respond in clean plain text, exactly as if it were a song lyric sheet.' }, { role: 'user', content: prompt } ]), link: 'writecream.com' } }); const session_hash = Math.random().toString(36).substring(2); const d = await axios.post(`https://ace-step-ace-step.hf.space/gradio_api/queue/join?`, { data: [ 240, tags, ai.response_content, 60, 15, 'euler', 'apg', 10, '', 0.5, 0, 3, true, false, true, '', 0, 0, false, 0.5, null, 'none' ], event_data: null, fn_index: 11, trigger_id: 45, session_hash: session_hash }); const { data } = await axios.get(`https://ace-step-ace-step.hf.space/gradio_api/queue/data?session_hash=${session_hash}`); let result; const lines = data.split('\n\n'); for (const line of lines) { if (line.startsWith('data:')) { const d = JSON.parse(line.substring(6)); if (d.msg === 'process_completed') result = d.output.data[0].url; } } return result; } catch (error) { throw new Error(error.message); } } // Usage: const resp = await aimusic('a song about my love for her, with a male vocalist'); console.log(resp);