diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.ts index 390c746776..883a55d149 100644 --- a/open-sse/config/providerRegistry.ts +++ b/open-sse/config/providerRegistry.ts @@ -1986,7 +1986,7 @@ export const REGISTRY: Record = { format: "openai", executor: "default", baseUrl: "https://studio-api.suno.ai/api/generate/v2/", - authType: "apikey", + authType: "cookie", authHeader: "cookie", models: [ { id: "chirp-v3-5", name: "Chirp V3.5" }, diff --git a/open-sse/handlers/imageGeneration.ts b/open-sse/handlers/imageGeneration.ts index 2291e34819..5dbb3eff02 100644 --- a/open-sse/handlers/imageGeneration.ts +++ b/open-sse/handlers/imageGeneration.ts @@ -3018,7 +3018,7 @@ async function handleHaiperImageGeneration({ const res = await fetch(providerConfig.baseUrl, { method: "POST", headers: { "Content-Type": "application/json", HAIPER_KEY: token }, - body: JSON.stringify({ prompt, aspect_ratio: "16:9" }), + body: JSON.stringify({ prompt, aspect_ratio: body.aspect_ratio || "16:9" }), }); if (!res.ok) { const errorText = await res.text(); @@ -3045,6 +3045,13 @@ async function handleHaiperImageGeneration({ const imgUrl = status.creation_url || status.output?.image_url; if (imgUrl) { const imgRes = await fetch(imgUrl); + if (!imgRes.ok) { + return { + success: false, + status: imgRes.status, + error: `Failed to download image: ${imgRes.status}`, + }; + } const buf = await imgRes.arrayBuffer(); saveCallLog({ method: "POST", @@ -3166,6 +3173,13 @@ async function handleLeonardoImageGeneration({ const imgUrl = gen.generated_images?.[0]?.url; if (imgUrl) { const imgRes = await fetch(imgUrl); + if (!imgRes.ok) { + return { + success: false, + status: imgRes.status, + error: `Failed to download image: ${imgRes.status}`, + }; + } const buf = await imgRes.arrayBuffer(); saveCallLog({ method: "POST", @@ -3259,6 +3273,13 @@ async function handleIdeogramImageGeneration({ if (data.data && data.data.length > 0) { const imgUrl = data.data[0].url; const imgRes = await fetch(imgUrl); + if (!imgRes.ok) { + return { + success: false, + status: imgRes.status, + error: `Failed to download image: ${imgRes.status}`, + }; + } const buf = await imgRes.arrayBuffer(); saveCallLog({ method: "POST", diff --git a/open-sse/handlers/musicGeneration.ts b/open-sse/handlers/musicGeneration.ts index bebfeb703c..6528f3ec6d 100644 --- a/open-sse/handlers/musicGeneration.ts +++ b/open-sse/handlers/musicGeneration.ts @@ -434,13 +434,20 @@ async function handleSunoMusicGeneration({ const deadline = Date.now() + 300000; while (Date.now() < deadline) { await new Promise((r) => setTimeout(r, 5000)); - const feedRes = await fetch(`https://studio-api.suno.ai/api/feed/?ids=${ids.join(",")}`, { + const feedRes = await fetch(`${providerConfig.statusUrl}?ids=${ids.join(",")}`, { headers: { Cookie: cookie }, }); const songs = await feedRes.json(); const ready = songs.filter((s) => s.audio_url); if (ready.length > 0) { const audioRes = await fetch(ready[0].audio_url); + if (!audioRes.ok) { + return { + success: false, + status: audioRes.status, + error: `Failed to download audio: ${audioRes.status}`, + }; + } const buf = await audioRes.arrayBuffer(); saveCallLog({ method: "POST", @@ -545,6 +552,13 @@ async function handleUdioMusicGeneration({ const ready = songs.filter((s) => s.finished && s.song_path); if (ready.length > 0) { const audioRes = await fetch(ready[0].song_path); + if (!audioRes.ok) { + return { + success: false, + status: audioRes.status, + error: `Failed to download audio: ${audioRes.status}`, + }; + } const buf = await audioRes.arrayBuffer(); saveCallLog({ method: "POST",