suno-api icon indicating copy to clipboard operation
suno-api copied to clipboard

/api/generate does not work, returns 500 error

Open Exoplanetarium opened this issue 1 year ago • 8 comments

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);
    }
  1. Go to console
  2. 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 avatar Aug 12 '24 02:08 Exoplanetarium

@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.

Exoplanetarium avatar Aug 12 '24 02:08 Exoplanetarium

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.

drjakob avatar Aug 14 '24 11:08 drjakob

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/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:42484 at async eI.execute (/var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:32486) at async eI.handle (/var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:43737) at async Y (/var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:24659) at async Q.responseCache.get.routeKind (/var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:1025) at async r2.renderToResponseWithComponentsImpl (/var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:507) at async r2.renderPageComponent (/var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:4784) at async r2.renderToResponseImpl (/var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:5367)

sapph1re avatar Aug 26 '24 22:08 sapph1re

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

k2helix avatar Aug 30 '24 12:08 k2helix

Hi @k2helix, since today I get the same error. But new cookies - even from different accounts and different browser etc. - do not help. So does it still work for you? How's your setup look like? Thanks!

markus583 avatar Oct 01 '24 09:10 markus583

Hi @markus583 , I just tested and it keeps working for me. Last time I refreshed cookies was when I sent the last message.

Maybe your issue is different? What I did to know what was happenig was removing the try/catch block where the issue is thrown.

k2helix avatar Oct 01 '24 10:10 k2helix

@k2helix thx for the fast reply! Interesting that the cookies lasted so long, over a month. How would removing the try/catch block help? I see I get the same Error: Failed to get session id, you may need to update the SUNO_COOKIE when using the get_limit request instead.

Could you maybe share the structure of your cookies? I think this could be quite helpful, thanks!

markus583 avatar Oct 01 '24 10:10 markus583

@markus583 Sure! So I have this in my .env file in the root of the project:

SUNO_COOKIE=__client_uat=172****401; __client=*********************************************; __stripe_mid=*********************************************; ajs_anonymous_id=*********************; __cf_bm=*********************************************; _cfuvid=*********************************************

It's everything in the same line

k2helix avatar Oct 01 '24 11:10 k2helix