Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Music api is returning null - not sure what I'm doing wrong #3

Open
Keats0206 opened this issue Aug 27, 2023 · 1 comment
Open

Music api is returning null - not sure what I'm doing wrong #3

Keats0206 opened this issue Aug 27, 2023 · 1 comment

Comments

@Keats0206
Copy link

export async function POST(req: Request) {

// Removed the API key for this post but it's setup in my instance correctly.
const leap = new Leap(apiKey);

if (!prompt || prompt.length === 0 || !apiKey) {
console.log("Invalid request. Check key and prompt.")
return;
}
if (req.method === 'POST') {
try {
const { data, error } = await leap.music.submitMusicGenerationJob({
prompt: "A suspenseful orchestral piece for a thriller chase scene.",
duration: 30,
});
if (error) {
return {
status: 500,
body: JSON.stringify({ message: 'Internal Server Error' }),
};
}
return {
status: 200,
body: JSON.stringify(data),
};

} catch (err) {
  console.error(err);
  return {
    status: 500,
    body: JSON.stringify({ message: 'Internal Server Error' }),
  };
}

} else {
return {
status: 405,
headers: { Allow: 'POST' },
body: 'Method Not Allowed',
};
}
}

@alexschachne
Copy link

Hello, looks like the call was missing the mode parameter.

This SDK is now deprecated and we recommend using the newest version here: https://github.com/leap-ai/leap-sdks

You can read the docs here: https://github.com/leap-ai/leap-sdks/blob/main/sdks/typescript/README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants