gcui-art / suno-api

Use API to call the music generation AI of suno.ai, and easily integrate it into agents like GPTs.
https://suno.gcui.ai
GNU Lesser General Public License v3.0
1.19k stars 268 forks source link

/api/generate does not work, returns 500 error #150

Open Exoplanetarium opened 1 month ago

Exoplanetarium commented 1 month ago

Describe the bug /api/generate returns Request failed with status code 500, but /api/get_limit returns expected:

{
  "credits_left": 50,
  "period": null,
  "monthly_limit": 50,
  "monthly_usage": 50
}

To Reproduce Steps to reproduce the behavior:

  1. Run this code snippet:
    
    const url = "https://suno-api-working.vercel.app/api/generate";
    const headers = { "Content-Type": "application/json" };
    const payload = {
    prompt: "A popular heavy metal song about war, sung by a deep-voiced male singer, slowly and melodiously. The lyrics depict the sorrow of people after the war.",
    make_instrumental: false,
    wait_audio: false,
    };

try { const response = await axios.post(url, payload, { headers: headers }); const data = response.data; } catch (error) { console.error("Error generating music:", error); }


2. Go to console
3. See error

**Expected behavior**
`/api/generate` works and returns a json object `audio_info` with a working url to the song.

**Desktop (please complete the following information):**
 - OS: Windows 11 Home
 - Browser: Google Chrome
 - Version: 127.0.6533.100
Exoplanetarium commented 1 month ago

@blueeon many users are struggling with this issue and have been for several weeks now. I understand you may be prioritizing some other projects (like Album AI), but please come back to this to at least figure out what went wrong.

drjakob commented 1 month ago

We are also struggling with the 500. Suno is sop a great service. A working API like this would be a win for all creatives.

sapph1re commented 2 weeks ago

Facing this too. Worked like a charmed just an hour ago, but suddenly started giving this error 500 on generate, exactly the same symptoms. At first I thought I ran out of free credits, so I purchased Premier, but it didn't help at all.

The log says: ⨯ TypeError: Cannot read properties of undefined (reading 'data') at c (/var/task/.next/server/app/api/generate/route.js:1:2160) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:42484 at async eI.execute (/var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:32486) at async eI.handle (/var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:43737) at async Y (/var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:24659) at async Q.responseCache.get.routeKind (/var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:1025) at async r2.renderToResponseWithComponentsImpl (/var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:507) at async r2.renderPageComponent (/var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:4784) at async r2.renderToResponseImpl (/var/task/node_modules/.pnpm/next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:5367)

k2helix commented 2 weeks ago

I debugged this for a bit removing the try/catch block to see the actual error. In my case it was Error: Failed to get session id, you may need to update the SUNO_COOKIE, so simply logging into Suno and getting new cookies solved it