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
904 stars 204 forks source link

给AI agent 能够调用suno api #4

Closed guoyuaarg closed 3 months ago

guoyuaarg commented 3 months ago

怎么用python的方式写一个调用suno ai API作为GPTs或者Autogen studio的动作指令呢

blueeon commented 3 months ago

Forgive me, I’m not quite sure what you’re referring to. The suno-api can be seamlessly integrated into GPTs as Actions.

guoyuaarg commented 3 months ago

对,我今天花了一整天,把这个api在vercel上跑通了,自动生成了音乐,但是我尝试把同样的api 请求代码用python的方式写到GPTs和autogen 里面,却没法正确调用,老是显示错误,能提供一下Agent中怎么调用suno的api的案例么,感谢感谢!因为我看gitup 上面那块信息写成 comming soon,目前还没更新

blueeon commented 3 months ago

@guoyuaarg Got it, crystal clear. We’re in the process of drafting a guide for integrating with GPTs, and the feature for this part is good to go but not yet merged. We are aiming to launch it by next Monday: Effortless integration into GPTs, no coding necessary!

guoyuaarg commented 3 months ago

thanks a lot, cause I have been trying a whole day, but I'm still cannot use API in my GPTS action or Autogen studio. below are two version of my python code that is tying to get request from suno but not working. Hope you guys could have a look, and give me some advice, and hope to get your correct API file for GPTs or other ai agent next monday!

thanks again, sincerely, Guoyu

import requests import json

def make_music(input_text): """ 根据提示生成音乐。

参数:
input_text (str): 制作歌曲的具体描述文本内容。

返回:
str: 程序是否成功执行。
"""

try:
    # 设置请求URL
    url = 'https://suno-ai-api.vercel.app/api/generate'

    # 设置请求头部
    headers = {
        'accept': 'application/json',
        'Content-Type': 'application/json',
        'Cookie': '__client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; __client_uat=1711510296; _cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; __cf_bm=a2K6j1aBiKNqU22u4HzKQHeG3quvM5imLTRezKPdVew-1711715360-1.0.1.1-4r7ywiJ5W3gkNqBRXa3HsCyoD1jqOUUx81xxZR7Ps90mBEPqcTXJn24Jh5FxUzBsCajyzT9jLg9NFYMLm_ABWQ; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D'
        # 假设API需要Cookie进行认证
    }

    # 设置请求体(Payload)
    data = {
        "prompt": input_text,
        "make_instrumental": False,
        "wait_audio": True
    }

    # 将字典转换为JSON字符串
    data_json = json.dumps(data)

    # 发送POST请求
    response = requests.post(url, headers=headers, data=data_json)

    # 检查响应
    if response.status_code == 200:
        print("请求成功!")
        # 这里处理你的逻辑,例如打印响应内容
        print(response.json())
    else:
        print("请求失败,状态码:", response.status_code)

except Exception as e:
    print(e)
    return f"发生错误: {str(e)}"

import requests

def make_music(input_text, project_id, suno_cookie): """ generating musics base on the prompt

Parameters:
input_text (str): The specific description text contents for make a song
project_id (str): The Vercel Project ID for API interaction.
suno_cookie (str): Authentication cookie required by the API.

Returns:
str: Is the program executed successfully.
"""

try:
    url = "https://suno-ai-4axfz9hp4-guoyuaargs-projects.vercel.app/api/generate"
    headers = {
        'accept': 'application/json',
        'Content-Type': 'application/json',
        'Cookie': f'SUNO_COOKIE={suno_cookie}',  # Assuming the cookie key is SUNO_COOKIE
        'Vercel-Project-ID': project_id # Custom header for Project ID, the actual header name may vary
    }
    data = {
        "prompt": input_text,
        "make_instrumental": False,
        "wait_audio": True  # 修改这里将 wait_audio 设置为 true
    }

    response = requests.post(url, json=data, headers=headers)
    print(response.json())

except Exception as e:
    # Return the error message in case of an exception
        print(e)
        return f"An error occurred: {str(e)}"

# Example usage
project_id_value = "prj_9PwhdWnK7VG09opoPSmmiP48LFB"  # Your actual Project ID
suno_cookie_value = "__client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; __client_uat=1711510296; __cf_bm=UxA_108CwZPjAJAWQ.7AcLi6XVSyxVqn0HbF5IpbBFY-1711692273-1.0.1.1-mlm2xFErcfa385hfoMgrcRR.z7LYv4WmoHxV0FSG4qFBrVe4.5lwhlxnsENDiSSAADI77E7OHmF6n6qCFQIv1Q; _cfuvid=FdlXAGvaYohPkFXgSXxx5EUYJGopmy8EDsqxvryaqxM-1711692273164-0.0.1.1-604800000; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D"  # Replace with your actual SUNO_COOKIE value
print(make_music("A description for a song", project_id_value, suno_cookie_value))

发件人: blueeon @.> 发送时间: 2024年3月29日 22:41 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4)

@guoyuaarghttps://github.com/guoyuaarg Got it, crystal clear. We’re in the process of drafting a guide for integrating with GPTs, and the feature for this part is good to go but not yet merged. We are aiming to launch it by next Monday: Effortless integration into GPTs, no coding necessary!

― Reply to this email directly, view it on GitHubhttps://github.com/gcui-art/suno-api/issues/4#issuecomment-2027334265, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F7YVLH5VHKCCR7JGSDY2V4QLAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGMZTIMRWGU. You are receiving this because you were mentioned.Message ID: @.***>

blueeon commented 3 months ago

That’s awesome, it’s super helpful for me to grasp this requirement.

I’ll toss in a Python code snippet for calling the API in the documentation as well.

blueeon commented 3 months ago

Let me break down the three needs mentioned in this issue:

  1. Enhance the documentation with API calling example codes, like Python, JavaScript, etc., to facilitate a seamless integration for developers.
  2. Customize the support for Agents like GPTs to produce relevant description files.
  3. Provide integration instructions for custom Agents like GPTs.

@GitPusher99 Sync it with you.

GitPusher99 commented 3 months ago

thanks a lot, cause I have been trying a whole day, but I'm still cannot use API in my GPTS action or Autogen studio. below are two version of my python code that is tying to get request from suno but not working. Hope you guys could have a look, and give me some advice, and hope to get your correct API file for GPTs or other ai agent next monday! thanks again, sincerely, Guoyu import requests import json def make_music(input_text): """ 根据提示生成音乐。 参数: input_text (str): 制作歌曲的具体描述文本内容。 返回: str: 程序是否成功执行。 """ try: # 设置请求URL url = 'https://suno-ai-api.vercel.app/api/generate' # 设置请求头部 headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': 'client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; client_uat=1711510296; _cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; cf_bm=a2K6j1aBiKNqU22u4HzKQHeG3quvM5imLTRezKPdVew-1711715360-1.0.1.1-4r7ywiJ5W3gkNqBRXa3HsCyoD1jqOUUx81xxZR7Ps90mBEPqcTXJn24Jh5FxUzBsCajyzT9jLg9NFYMLm_ABWQ; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D' # 假设API需要Cookie进行认证 } # 设置请求体(Payload) data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True } # 将字典转换为JSON字符串 data_json = json.dumps(data) # 发送POST请求 response = requests.post(url, headers=headers, data=data_json) # 检查响应 if response.status_code == 200: print("请求成功!") # 这里处理你的逻辑,例如打印响应内容 print(response.json()) else: print("请求失败,状态码:", response.status_code) except Exception as e: print(e) return f"发生错误: {str(e)}" import requests def make_music(input_text, project_id, suno_cookie): """ generating musics base on the prompt Parameters: input_text (str): The specific description text contents for make a song project_id (str): The Vercel Project ID for API interaction. suno_cookie (str): Authentication cookie required by the API. Returns: str: Is the program executed successfully. """ try: url = "https://suno-ai-4axfz9hp4-guoyuaargs-projects.vercel.app/api/generate" headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': f'SUNO_COOKIE={suno_cookie}', # Assuming the cookie key is SUNO_COOKIE 'Vercel-Project-ID': project_id # Custom header for Project ID, the actual header name may vary } data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True # 修改这里将 wait_audio 设置为 true } response = requests.post(url, json=data, headers=headers) print(response.json()) except Exception as e: # Return the error message in case of an exception print(e) return f"An error occurred: {str(e)}" # Example usage project_id_value = "prj_9PwhdWnK7VG09opoPSmmiP48LFB" # Your actual Project ID suno_cookie_value = "client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; __client_uat=1711510296; cf_bm=UxA_108CwZPjAJAWQ.7AcLi6XVSyxVqn0HbF5IpbBFY-1711692273-1.0.1.1-mlm2xFErcfa385hfoMgrcRR.z7LYv4WmoHxV0FSG4qFBrVe4.5lwhlxnsENDiSSAADI77E7OHmF6n6qCFQIv1Q; _cfuvid=FdlXAGvaYohPkFXgSXxx5EUYJGopmy8EDsqxvryaqxM-1711692273164-0.0.1.1-604800000; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D" # Replace with your actual SUNO_COOKIE value print(make_music("A description for a song", project_id_value, suno_cookie_value)) __ 发件人: blueeon @.> 发送时间: 2024年3月29日 22:41 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4) @guoyuaarghttps://github.com/guoyuaarg Got it, crystal clear. We’re in the process of drafting a guide for integrating with GPTs, and the feature for this part is good to go but not yet merged. We are aiming to launch it by next Monday: Effortless integration into GPTs, no coding necessary! ― Reply to this email directly, view it on GitHub<#4 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F7YVLH5VHKCCR7JGSDY2V4QLAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGMZTIMRWGU. You are receiving this because you were mentioned.Message ID: @.***>

@guoyuaarg 我测试了下 你的 cookie ,是有问题的,你能重新贴一个最新的 cookie 吗?

guoyuaarg commented 3 months ago

对的,这个cookie的账号今日的credits用完了,我换了一个账号,目前还有40 credits,今日还能够测试生成四次作品,下面是新的cookie号

_cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZU1nSmpkWXdtU05YQ1c4Z3d5Q3VUa2lKdE4iLCJyb3RhdGluZ190b2tlbiI6IjVmNHg4dWZkdW4yejdqbTFkbjJ1em5qcThkY2FtZHgyaXIxY3hzZXMifQ.vytNDawrnKkuUJTEWEZRPjlQ8Dsox7w-S6TWWvVRJFAaXENGEIneTDLtJpt2s-UfcKXj0_EwjJLQv4vBbqXwi2xkIFgmaLZzMgQovJdW5ty-RqiarLXgd9sb1CIzUye1y9gDYeYmqkzyPYG7XAQf0S0oBp8ycGgC4nGZlxy480dyZZvmojoVyBmMCD-YpELOdSACLl2OEmWjQyVkcveUf-djSXqK6kxOZxk9AHpmGLA6wzyAYAKkbgYZLaC8YN92lTrxxnTRI4isUcxsOVUNuto6XhXMkavcIZxkCzDk-c2Gv_Uds7fuVPFLiCVR6mjAroZCKshgPrk2G6xBXcn5Qg; client_uat=1711719932; __cf_bm=FF4vePicn0UefGKpXEGOaWQPvbpKXzGAmxVd6rzg5MY-1711720972-1.0.1.1-0ndjEG9OyOziUMwzJCSwF8IgjxpA59R7eULOjwvu7oI8Gg9GVcYv0MyUpx3YYdUbDZ4DRX.K2LidCXvR.e2O2w; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%2C%22%24search_engine%22%3A%20%22google%22%7D


发件人: GitPusher99 @.> 发送时间: 2024年3月30日 0:08 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4)

thanks a lot, cause I have been trying a whole day, but I'm still cannot use API in my GPTS action or Autogen studio. below are two version of my python code that is tying to get request from suno but not working. Hope you guys could have a look, and give me some advice, and hope to get your correct API file for GPTs or other ai agent next monday! thanks again, sincerely, Guoyu import requests import json def make_music(input_text): """ 根据提示生成音乐。 参数: input_text (str): 制作歌曲的具体描述文本内容。 返回: str: 程序是否成功执行。 """ try: # 设置请求URL url = 'https://suno-ai-api.vercel.app/api/generate' # 设置请求头部 headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': 'client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; client_uat=1711510296; _cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; cf_bm=a2K6j1aBiKNqU22u4HzKQHeG3quvM5imLTRezKPdVew-1711715360-1.0.1.1-4r7ywiJ5W3gkNqBRXa3HsCyoD1jqOUUx81xxZR7Ps90mBEPqcTXJn24Jh5FxUzBsCajyzT9jLg9NFYMLm_ABWQ; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D' # 假设API需要Cookie进行认证 } # 设置请求体(Payload) data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True } # 将字典转换为JSON字符串 data_json = json.dumps(data) # 发送POST请求 response = requests.post(url, headers=headers, data=data_json) # 检查响应 if response.status_code == 200: print("请求成功!") # 这里处理你的逻辑,例如打印响应内容 print(response.json()) else: print("请求失败,状态码:", response.status_code) except Exception as e: print(e) return f"发生错误: {str(e)}" import requests def make_music(input_text, project_id, suno_cookie): """ generating musics base on the prompt Parameters: input_text (str): The specific description text contents for make a song project_id (str): The Vercel Project ID for API interaction. suno_cookie (str): Authentication cookie required by the API. Returns: str: Is the program executed successfully. """ try: url = "https://suno-ai-4axfz9hp4-guoyuaargs-projects.vercel.app/api/generate" headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': f'SUNO_COOKIE={suno_cookie}', # Assuming the cookie key is SUNO_COOKIE 'Vercel-Project-ID': project_id # Custom header for Project ID, the actual header name may vary } data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True # 修改这里将 wait_audio 设置为 true } response = requests.post(url, json=data, headers=headers) print(response.json()) except Exception as e: # Return the error message in case of an exception print(e) return f"An error occurred: {str(e)}" # Example usage project_id_value = "prj_9PwhdWnK7VG09opoPSmmiP48LFB" # Your actual Project ID suno_cookie_value = "client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; __client_uat=1711510296; cf_bm=UxA_108CwZPjAJAWQ.7AcLi6XVSyxVqn0HbF5IpbBFY-1711692273-1.0.1.1-mlm2xFErcfa385hfoMgrcRR.z7LYv4WmoHxV0FSG4qFBrVe4.5lwhlxnsENDiSSAADI77E7OHmF6n6qCFQIv1Q; _cfuvid=FdlXAGvaYohPkFXgSXxx5EUYJGopmy8EDsqxvryaqxM-1711692273164-0.0.1.1-604800000; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D" # Replace with your actual SUNO_COOKIE value print(make_music("A description for a song", project_id_value, suno_cookie_value)) … __ 发件人: blueeon @.> 发送时间: 2024年3月29日 22:41 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4https://github.com/gcui-art/suno-api/issues/4) @guoyuaarghttps://github.com/guoyuaarghttps://github.com/guoyuaarg Got it, crystal clear. We’re in the process of drafting a guide for integrating with GPTs, and the feature for this part is good to go but not yet merged. We are aiming to launch it by next Monday: Effortless integration into GPTs, no coding necessary! D Reply to this email directly, view it on GitHub<#4 (comment)https://github.com/gcui-art/suno-api/issues/4#issuecomment-2027334265>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F7YVLH5VHKCCR7JGSDY2V4QLAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGMZTIMRWGU. You are receiving this because you were mentioned.Message ID: @.***>

@guoyuaarghttps://github.com/guoyuaarg 我测试了下 你的 cookie ,是有问题的,你能重新贴一个最新的 cookie 吗?

― Reply to this email directly, view it on GitHubhttps://github.com/gcui-art/suno-api/issues/4#issuecomment-2027429768, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F5ANKR235MTJH55AKDY2WGWTAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGQZDSNZWHA. You are receiving this because you were mentioned.Message ID: @.***>

GitPusher99 commented 3 months ago

对的,这个cookie的账号今日的credits用完了,我换了一个账号,目前还有40 credits,今日还能够测试生成四次作品,下面是新的cookie号 _cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZU1nSmpkWXdtU05YQ1c4Z3d5Q3VUa2lKdE4iLCJyb3RhdGluZ190b2tlbiI6IjVmNHg4dWZkdW4yejdqbTFkbjJ1em5qcThkY2FtZHgyaXIxY3hzZXMifQ.vytNDawrnKkuUJTEWEZRPjlQ8Dsox7w-S6TWWvVRJFAaXENGEIneTDLtJpt2s-UfcKXj0_EwjJLQv4vBbqXwi2xkIFgmaLZzMgQovJdW5ty-RqiarLXgd9sb1CIzUye1y9gDYeYmqkzyPYG7XAQf0S0oBp8ycGgC4nGZlxy480dyZZvmojoVyBmMCD-YpELOdSACLl2OEmWjQyVkcveUf-djSXqK6kxOZxk9AHpmGLA6wzyAYAKkbgYZLaC8YN92lTrxxnTRI4isUcxsOVUNuto6XhXMkavcIZxkCzDk-c2Gv_Uds7fuVPFLiCVR6mjAroZCKshgPrk2G6xBXcn5Qg; client_uat=1711719932; cf_bm=FF4vePicn0UefGKpXEGOaWQPvbpKXzGAmxVd6rzg5MY-1711720972-1.0.1.1-0ndjEG9OyOziUMwzJCSwF8IgjxpA59R7eULOjwvu7oI8Gg9GVcYv0MyUpx3YYdUbDZ4DRX.K2LidCXvR.e2O2w; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%2C%22%24search_engine%22%3A%20%22google%22%7D ____ 发件人: GitPusher99 @.> 发送时间: 2024年3月30日 0:08 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4) thanks a lot, cause I have been trying a whole day, but I'm still cannot use API in my GPTS action or Autogen studio. below are two version of my python code that is tying to get request from suno but not working. Hope you guys could have a look, and give me some advice, and hope to get your correct API file for GPTs or other ai agent next monday! thanks again, sincerely, Guoyu import requests import json def make_music(input_text): """ 根据提示生成音乐。 参数: input_text (str): 制作歌曲的具体描述文本内容。 返回: str: 程序是否成功执行。 """ try: # 设置请求URL url = 'https://suno-ai-api.vercel.app/api/generate' # 设置请求头部 headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': 'client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; client_uat=1711510296; _cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; cf_bm=a2K6j1aBiKNqU22u4HzKQHeG3quvM5imLTRezKPdVew-1711715360-1.0.1.1-4r7ywiJ5W3gkNqBRXa3HsCyoD1jqOUUx81xxZR7Ps90mBEPqcTXJn24Jh5FxUzBsCajyzT9jLg9NFYMLm_ABWQ; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D' # 假设API需要Cookie进行认证 } # 设置请求体(Payload) data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True } # 将字典转换为JSON字符串 data_json = json.dumps(data) # 发送POST请求 response = requests.post(url, headers=headers, data=data_json) # 检查响应 if response.status_code == 200: print("请求成功!") # 这里处理你的逻辑,例如打印响应内容 print(response.json()) else: print("请求失败,状态码:", response.status_code) except Exception as e: print(e) return f"发生错误: {str(e)}" import requests def make_music(input_text, project_id, suno_cookie): """ generating musics base on the prompt Parameters: input_text (str): The specific description text contents for make a song project_id (str): The Vercel Project ID for API interaction. suno_cookie (str): Authentication cookie required by the API. Returns: str: Is the program executed successfully. """ try: url = "https://suno-ai-4axfz9hp4-guoyuaargs-projects.vercel.app/api/generate" headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': f'SUNO_COOKIE={suno_cookie}', # Assuming the cookie key is SUNO_COOKIE 'Vercel-Project-ID': project_id # Custom header for Project ID, the actual header name may vary } data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True # 修改这里将 wait_audio 设置为 true } response = requests.post(url, json=data, headers=headers) print(response.json()) except Exception as e: # Return the error message in case of an exception print(e) return f"An error occurred: {str(e)}" # Example usage project_id_value = "prj_9PwhdWnK7VG09opoPSmmiP48LFB" # Your actual Project ID suno_cookie_value = "client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; __client_uat=1711510296; cf_bm=UxA_108CwZPjAJAWQ.7AcLi6XVSyxVqn0HbF5IpbBFY-1711692273-1.0.1.1-mlm2xFErcfa385hfoMgrcRR.z7LYv4WmoHxV0FSG4qFBrVe4.5lwhlxnsENDiSSAADI77E7OHmF6n6qCFQIv1Q; _cfuvid=FdlXAGvaYohPkFXgSXxx5EUYJGopmy8EDsqxvryaqxM-1711692273164-0.0.1.1-604800000; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D" # Replace with your actual SUNO_COOKIE value print(make_music("A description for a song", project_id_value, suno_cookie_value)) … ____ 发件人: blueeon @.> 发送时间: 2024年3月29日 22:41 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4<#4>) @guoyuaarghttps://github.com/guoyuaarghttps://github.com/guoyuaarg Got it, crystal clear. We’re in the process of drafting a guide for integrating with GPTs, and the feature for this part is good to go but not yet merged. We are aiming to launch it by next Monday: Effortless integration into GPTs, no coding necessary! D Reply to this email directly, view it on GitHub<#4 (comment)<#4 (comment)>>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F7YVLH5VHKCCR7JGSDY2V4QLAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGMZTIMRWGU. You are receiving this because you were mentioned.Message ID: @.> @guoyuaarghttps://github.com/guoyuaarg 我测试了下 你的 cookie ,是有问题的,你能重新贴一个最新的 cookie 吗? ― Reply to this email directly, view it on GitHub<#4 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F5ANKR235MTJH55AKDY2WGWTAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGQZDSNZWHA. You are receiving this because you were mentioned.Message ID: @.>

@guoyuaarg 这个 cookie 是有效的,你可以在你的 vercel 服务上 重置 这个 cookie ,重置方式如下(重置完后,需要重新发布重启服务才能生效):

image
guoyuaarg commented 3 months ago

对的,这个号我新开的,我在vercel服务器上之前也测试成功了,我主要是想自己用python写一个类似的api请求整合到我agent的框架里作为一个动作和其他的动作进行联动,用我自己写的python上传到autogen studio或者gpts 的这样的agent上去调用时就显示失败了[cid:260f3206-6459-402d-a2af-119d3ff669f9]


发件人: GitPusher99 @.> 发送时间: 2024年3月30日 1:04 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4)

对的,这个cookie的账号今日的credits用完了,我换了一个账号,目前还有40 credits,今日还能够测试生成四次作品,下面是新的cookie号 _cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZU1nSmpkWXdtU05YQ1c4Z3d5Q3VUa2lKdE4iLCJyb3RhdGluZ190b2tlbiI6IjVmNHg4dWZkdW4yejdqbTFkbjJ1em5qcThkY2FtZHgyaXIxY3hzZXMifQ.vytNDawrnKkuUJTEWEZRPjlQ8Dsox7w-S6TWWvVRJFAaXENGEIneTDLtJpt2s-UfcKXj0_EwjJLQv4vBbqXwi2xkIFgmaLZzMgQovJdW5ty-RqiarLXgd9sb1CIzUye1y9gDYeYmqkzyPYG7XAQf0S0oBp8ycGgC4nGZlxy480dyZZvmojoVyBmMCD-YpELOdSACLl2OEmWjQyVkcveUf-djSXqK6kxOZxk9AHpmGLA6wzyAYAKkbgYZLaC8YN92lTrxxnTRI4isUcxsOVUNuto6XhXMkavcIZxkCzDk-c2Gv_Uds7fuVPFLiCVR6mjAroZCKshgPrk2G6xBXcn5Qg; client_uat=1711719932; cf_bm=FF4vePicn0UefGKpXEGOaWQPvbpKXzGAmxVd6rzg5MY-1711720972-1.0.1.1-0ndjEG9OyOziUMwzJCSwF8IgjxpA59R7eULOjwvu7oI8Gg9GVcYv0MyUpx3YYdUbDZ4DRX.K2LidCXvR.e2O2w; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%2C%22%24search_engine%22%3A%20%22google%22%7D … ____ 发件人: GitPusher99 @.> 发送时间: 2024年3月30日 0:08 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4https://github.com/gcui-art/suno-api/issues/4) thanks a lot, cause I have been trying a whole day, but I'm still cannot use API in my GPTS action or Autogen studio. below are two version of my python code that is tying to get request from suno but not working. Hope you guys could have a look, and give me some advice, and hope to get your correct API file for GPTs or other ai agent next monday! thanks again, sincerely, Guoyu import requests import json def make_music(input_text): """ 根据提示生成音乐。 参数: input_text (str): 制作歌曲的具体描述文本内容。 返回: str: 程序是否成功执行。 """ try: # 设置请求URL url = 'https://suno-ai-api.vercel.app/api/generate' # 设置请求头部 headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': 'client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; client_uat=1711510296; _cfuvid=DE9lp.PAJQ3upaLk15TnqIPeqiBGWkXW_15sq6mw2JA-1711694974404-0.0.1.1-604800000; cf_bm=a2K6j1aBiKNqU22u4HzKQHeG3quvM5imLTRezKPdVew-1711715360-1.0.1.1-4r7ywiJ5W3gkNqBRXa3HsCyoD1jqOUUx81xxZR7Ps90mBEPqcTXJn24Jh5FxUzBsCajyzT9jLg9NFYMLm_ABWQ; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D' # 假设API需要Cookie进行认证 } # 设置请求体(Payload) data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True } # 将字典转换为JSON字符串 data_json = json.dumps(data) # 发送POST请求 response = requests.post(url, headers=headers, data=data_json) # 检查响应 if response.status_code == 200: print("请求成功!") # 这里处理你的逻辑,例如打印响应内容 print(response.json()) else: print("请求失败,状态码:", response.status_code) except Exception as e: print(e) return f"发生错误: {str(e)}" import requests def make_music(input_text, project_id, suno_cookie): """ generating musics base on the prompt Parameters: input_text (str): The specific description text contents for make a song project_id (str): The Vercel Project ID for API interaction. suno_cookie (str): Authentication cookie required by the API. Returns: str: Is the program executed successfully. """ try: url = "https://suno-ai-4axfz9hp4-guoyuaargs-projects.vercel.app/api/generate" headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Cookie': f'SUNO_COOKIE={suno_cookie}', # Assuming the cookie key is SUNO_COOKIE 'Vercel-Project-ID': project_id # Custom header for Project ID, the actual header name may vary } data = { "prompt": input_text, "make_instrumental": False, "wait_audio": True # 修改这里将 wait_audio 设置为 true } response = requests.post(url, json=data, headers=headers) print(response.json()) except Exception as e: # Return the error message in case of an exception print(e) return f"An error occurred: {str(e)}" # Example usage project_id_value = "prj_9PwhdWnK7VG09opoPSmmiP48LFB" # Your actual Project ID suno_cookie_value = "client=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsaWVudF8yZUZwZmVOdkR3RVJ1WmZ0eW1lWjhDdGhGTWgiLCJyb3RhdGluZ190b2tlbiI6IjY0a2hmZHlkeWFsbWkxeWh3Z252NDUyM3VhMDlzYWx6bXFzbnMxd3QifQ.BR4ZvoFGpHIIxeIYUkPvy4NIJ_bB5yB3u3eOTmcsS8VIsrkh8yWk3SbNl5Xrmd-Lo7RsRyzu0eyq2H0jvckJ6tNA4zcV31MC53BN-Cu68BXDN1RBwU4K7th944k8-WvK1BviZzCUnX_1LdP2odqlJ5NShQCqCWfyYvPWqi_tVxc2spzN3AKVUPY9BTd7poTgGnKqNQqENov44XmKu2S7yjSnERls241BwsZYIw4O1E-wUC4XRB2nQlEu3F9C0OJjspNlrBKlNXVMAanLTvyuvLcjf6tuTkZ76U8d3gbP0d79595m41CHZYSozg_BcwnU30mmTU278llr8enhBNSVEQ; __client_uat=1711510296; cf_bm=UxA_108CwZPjAJAWQ.7AcLi6XVSyxVqn0HbF5IpbBFY-1711692273-1.0.1.1-mlm2xFErcfa385hfoMgrcRR.z7LYv4WmoHxV0FSG4qFBrVe4.5lwhlxnsENDiSSAADI77E7OHmF6n6qCFQIv1Q; _cfuvid=FdlXAGvaYohPkFXgSXxx5EUYJGopmy8EDsqxvryaqxM-1711692273164-0.0.1.1-604800000; mp_26ced217328f4737497bd6ba6641ca1c_mixpanel=%7B%22distinct_id%22%3A%20%22%24device%3A18e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24device_id%22%3A%20%2218e7df600351ff-0a1adb40112b1f-4c657b58-1fa400-18e7df600351ff%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D" # Replace with your actual SUNO_COOKIE value print(make_music("A description for a song", project_id_value, suno_cookie_value)) … ____ 发件人: blueeon @.> 发送时间: 2024年3月29日 22:41 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4https://github.com/gcui-art/suno-api/issues/4<#4https://github.com/gcui-art/suno-api/issues/4>) @guoyuaarghttps://github.com/guoyuaarghttps://github.com/guoyuaarghttps://github.com/guoyuaarg Got it, crystal clear. We’re in the process of drafting a guide for integrating with GPTs, and the feature for this part is good to go but not yet merged. We are aiming to launch it by next Monday: Effortless integration into GPTs, no coding necessary! D Reply to this email directly, view it on GitHub<#4https://github.com/gcui-art/suno-api/issues/4 (comment)<#4 (comment)https://github.com/gcui-art/suno-api/issues/4#issuecomment-2027334265>>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F7YVLH5VHKCCR7JGSDY2V4QLAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGMZTIMRWGU. You are receiving this because you were mentioned.Message ID: @.> @guoyuaarghttps://github.com/guoyuaarghttps://github.com/guoyuaarg 我测试了下 你的 cookie ,是有问题的,你能重新贴一个最新的 cookie 吗? D Reply to this email directly, view it on GitHub<#4 (comment)https://github.com/gcui-art/suno-api/issues/4#issuecomment-2027429768>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F5ANKR235MTJH55AKDY2WGWTAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGQZDSNZWHA. You are receiving this because you were mentioned.Message ID: @.>

@guoyuaarghttps://github.com/guoyuaarg 这个 cookie 是有效的,你可以在你的 vercel 服务上 重置 这个 cookie ,重置方式如下(重置完后,需要重新发布重启服务才能生效): image.png (view on web)https://github.com/gcui-art/suno-api/assets/165138458/86e166f7-89e0-4bcc-bcc2-41a4c62dc571

― Reply to this email directly, view it on GitHubhttps://github.com/gcui-art/suno-api/issues/4#issuecomment-2027496177, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F6APMLWBSIRL7OM5SLY2WNIJAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGQ4TMMJXG4. You are receiving this because you were mentioned.Message ID: @.***>

GitPusher99 commented 3 months ago

@guoyuaarg 这个暂时还没支持,一个 vercel 服务,只能支持一个 cookie 调用,你想要的能力,也许未来可能会支持

buyeach commented 3 months ago

对,我今天花了一整天,把这个api在vercel上跑通了,自动生成了音乐,但是我尝试把同样的api 请求代码用python的方式写到GPTs和autogen 里面,却没法正确调用,老是显示错误,能提供一下Agent中怎么调用suno的api的案例么,感谢感谢!因为我看gitup 上面那块信息写成 comming soon,目前还没更新

按照教程部署到vervel了,然后再怎么操作,才能让它自动生成音乐呢

GitPusher99 commented 3 months ago

@guoyuaarg @buyeach readme 教程给出了代码,可以试试下

guoyuaarg commented 3 months ago

I have try the python code you guys updated in the gitup website as below, and I changed the base url to my own vercel domain, but I still cannot succeed to call the sunoai API outside the vercel platform in a AI agent like Autogen or GPTs. Could you have a look and tell me how to solve the problem? Thanks a lot.

import time import requests

replace your vercel domain

base_url = 'https://suno-ai-api.vercel.app'

def custom_generate_audio(payload): url = f"{base_url}/api/custom_generate" response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'}) return response.json()

def generate_audio_by_prompt(payload): url = f"{base_url}/api/generate" response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'}) return response.json()

def get_audio_information(audio_ids): url = f"{base_url}/api/get?ids={audio_ids}" response = requests.get(url) return response.json()

def get_quota_information(): url = f"{base_url}/api/get_limit" response = requests.get(url) return response.json()

if name == 'main': data = generate_audio_by_prompt({ "prompt": "A popular song about future, sung by a deep-voiced male singer, slowly and melodiously. The lyrics depict the happiness of people in the future.", "make_instrumental": False, "wait_audio": False })

ids = f"{data[0]['id']},{data[1]['id']}"
print(f"ids: {ids}")

for _ in range(60):
    data = get_audio_information(ids)
    if data[0]["status"] == 'streaming':
        print(f"{data[0]['id']} ==> {data[0]['audio_url']}")
        print(f"{data[1]['id']} ==> {data[1]['audio_url']}")
        break
    # sleep 5s
    time.sleep(5)

import time import requests

def generate_audio_by_prompt(payload): """ generating musics based on the prompt

Parameters:
payload (dict): The specific description text contents for making a song

Returns:
dict: The response from the API.
"""
url = f"{base_url}/api/generate"
response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'})
return response.json()

def get_audio_information(audio_ids): """ Fetch audio information based on IDs.

Parameters:
ids (str): Comma-separated IDs to fetch information for.

Returns:
dict: The response from the API.
"""
# This is a placeholder function; you'll need to implement the actual request to the API here.
pass

url = f"{base_url}/api/get?ids={audio_ids}"
response = requests.get(url)
return response.json()

if name == 'main': try: base_url = 'https://suno-ai-api.vercel.app' data = generate_audio_by_prompt({ "prompt": "A popular song about future, sung by a deep-voiced male singer, slowly and melodiously. The lyrics depict the happiness of people in the future.", "make_instrumental": False, "wait_audio": False })

    ids = f"{data[0]['id']},{data[1]['id']}"
    print(f"ids: {ids}")

    for _ in range(60):
        data = get_audio_information(ids)
        if data[0]["status"] == 'streaming':
            print(f"{data[0]['id']} ==> {data[0]['audio_url']}")
            print(f"{data[1]['id']} ==> {data[1]['audio_url']}")
            break
        time.sleep(5)  # sleep 5s
except Exception as e:
    print(f"发生错误: {str(e)}")

[cid:a777c779-32f9-4d66-a3c7-0dc124e5ab99] [cid:f222bc79-909e-449c-a54d-e135415e3d55]


发件人: blueeon @.> 发送时间: 2024年3月29日 23:14 收件人: gcui-art/suno-api @.> 抄送: guoyuaarg @.>; Mention @.> 主题: Re: [gcui-art/suno-api] 给AI agent 能够调用suno api (Issue #4)

That’s awesome, it’s super helpful for me to grasp this requirement.

I’ll toss in a Python code snippet for calling the API in the documentation as well.

― Reply to this email directly, view it on GitHubhttps://github.com/gcui-art/suno-api/issues/4#issuecomment-2027369229, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGXF3F7EH3SNIDTACUX3SR3Y2WAMDAVCNFSM6AAAAABFOLDIR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRXGM3DSMRSHE. You are receiving this because you were mentioned.Message ID: @.***>

GitPusher99 commented 3 months ago

@guoyuaarg 错误信息的图片看不到,方便直接将 错误信息 贴出来下吗?