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

给AI agent 能够调用suno api #4

Closed
guoyuaarg opened this issue Mar 29, 2024 · 15 comments
Closed

给AI agent 能够调用suno api #4

guoyuaarg opened this issue Mar 29, 2024 · 15 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed

Comments

@guoyuaarg
Copy link

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

@blueeon
Copy link
Contributor

blueeon commented Mar 29, 2024

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

@blueeon blueeon added the help wanted Extra attention is needed label Mar 29, 2024
@guoyuaarg
Copy link
Author

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

@blueeon
Copy link
Contributor

blueeon commented Mar 29, 2024

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

@blueeon blueeon added the enhancement New feature or request label Mar 29, 2024
@guoyuaarg
Copy link
Author

guoyuaarg commented Mar 29, 2024 via email

@blueeon
Copy link
Contributor

blueeon commented Mar 29, 2024

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
Copy link
Contributor

blueeon commented Mar 29, 2024

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
Copy link
Contributor

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
Copy link
Author

guoyuaarg commented Mar 29, 2024 via email

@GitPusher99
Copy link
Contributor

对的,这个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
Copy link
Author

guoyuaarg commented Mar 29, 2024 via email

@GitPusher99
Copy link
Contributor

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

@buyeach
Copy link

buyeach commented Mar 30, 2024

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

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

@GitPusher99
Copy link
Contributor

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

@guoyuaarg
Copy link
Author

guoyuaarg commented Mar 31, 2024 via email

@blueeon blueeon added the documentation Improvements or additions to documentation label Mar 31, 2024
@GitPusher99
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants