Suno-API / README.md
PiAPI's picture
Update README.md
f3666c0 verified
---
license: mit
---
# Suno API
**Model Page:** [Suno API](https://piapi.ai/suno-api)
This model card illustartes the steps to use Suno API's endpoint.
You can also check out other model cards:
- [Midjourney API](https://huggingface.co/PiAPI/Midjourney-API)
- [Faceswap API](https://huggingface.co/PiAPI/Faceswap-API)
- [Dream Machine API](https://huggingface.co/PiAPI/Dream-Machine-API)
**Model Information**
Developed by the Suno team in Cambridge, MA, Suno is a leading-edge text-to-music model. While it doesn't have an official API service, PiAPI has introduced an unofficial Suno API, allowing developers globally to integrate Suno’s music creation capabilities into their applications.
## Usage Steps
Below we share the code snippets on how to use the Suno API's "Generate Full Song" endpoint.
- The programming language is Python
- This is only applicable for Extended Clips generated from the "Extend" function of the "Generate Music" endpoint.
**Create a task ID from the "Generate Full Song" endpoint**
<pre><code class="language-python">
<span class="hljs-keyword">import</span> http.client
conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>)
payload = <span class="hljs-string">"{\n \"clip_id\": \"0e764cab****************55f76ca44ed6\"\n}"</span>
headers = {
<span class="hljs-built_in">'X-API-Key': "{{x-api-key}}"</span>, //Insert your API Key here
<span class="hljs-built_in">'Content-Type': "application/json"</span>,
<span class="hljs-built_in">'Accept': "application/json"</span>
}
conn.request("POST", "/api/suno/v1/music/concat", payload, headers)
res = conn.getresponse()
data = res.read()
<span class="hljs-keyword">print</span>(data.decode("utf-8"))
</code></pre>
**Retrieve the task ID**
<pre><code class="language-python">
{
<span class="hljs-built_in">"code"</span>: 200,
<span class="hljs-built_in">"data"</span>: {
<span class="hljs-built_in">"task_id"</span>: "5440b19a*****************e92de94d5110" //Record the taskID provided in your response terminal
},
<span class="hljs-built_in">"message"</span>: "success"
}
</code></pre>
**Insert the "Generate Full Song" task ID into the fetch endpoint**
<pre><code class="language-python">
<span class="hljs-keyword">import</span> http.client
conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>)
headers = {
<span class="hljs-built_in">'Content-Type': "application/json"</span>,
<span class="hljs-built_in">'Accept': "application/json"</span>
}
conn.request("GET", "/api/suno/v1/music/task_id", headers=headers) //Replace the "task_id" with your task ID
res = conn.getresponse()
data = res.read()
<span class="hljs-keyword">print</span>(data.decode("utf-8"))
</code></pre>
**For fetch endpoint responses** - Refer to our [documentation](https://piapi.ai/docs/suno-api/get-music) for more detailed information.
<br>
## Contact us
Contact us at <a href="mailto:[email protected]">[email protected]</a> for any inquires.
<br>