تكامل Suno Tasks API واستخدامها
يمكن استخدام Suno Tasks API للاستعلام عن حالة تنفيذ طلبات Suno، مثل إنشاء الأغاني وتصدير الصوت، عبر معرّف المهمة.
¶ إجراءات التقديم
انتقل إلى لوحة تحكم orchats للحصول على مفتاح API يتمتع بصلاحية الاستعلام عن المهام. يستخدم المثال متغير البيئة API_KEY.
يرجى الاستعلام باستخدام هوية التطبيق التي استُخدمت عند إرسال المهمة. لا يستهلك الاستعلام أرصدة Credits.
إذا لم تكن قد سجلت الدخول أو أنشأت حسابًا بعد، فستُحوَّل تلقائيًا إلى صفحة تسجيل الدخول لدعوتك إلى إنشاء حساب وتسجيل الدخول، وبعد الانتهاء ستعود تلقائيًا إلى الصفحة الحالية.
يمكن استخدام مفتاح API الخاص بالتطبيق العام للخدمات المفعّلة للحساب؛ أما مفتاح التطبيق المخصص فيُستخدم وفق نطاق خدمات ذلك التطبيق. يرجى التحقق من صلاحيات المفتاح وفترة صلاحيته وحدوده، والتأكد من أن رصيد التطبيق يكفي لدفع تكلفة هذا الطلب. يعتمد رصيد التجربة المتاح على ما يظهر في الحساب، وعندما لا يكون الرصيد كافيًا، انقر على زر «إعادة الشحن».
📘 الوثائق الكاملة: Suno Audios Generation API →
¶ مثال على الطلب
لنأخذ مهمة أغنية غير متزامنة في Suno Audios Generation API مثالًا. بعد الإرسال، احفظ task_id المُعاد.
فيما يلي مهمة أغنية اختُبرت فعليًا، ومعرّف المهمة هو c409f30d-4b2f-4ad9-8ae7-f394e367713d. يرجى استبداله في الكود بمعرّف مهمتك.
¶ مثال على المهمة
استخدم معرّف المهمة أعلاه لإرسال استعلام retrieve. يظهر وقت الاكتمال في finished_at. قيمة response.success لهذه المهمة هي true، ويحتوي response.data على الأغنيتين المرشحتين مكان لكرسي آخر وهناك دائمًا مكان للمزيد.
¶ إعداد ترويسات الطلب ومتن الطلب
تتضمن ترويسات الطلب ما يلي:
accept: يحدد استقبال نتيجة الاستجابة بتنسيق JSON، وتُكتب هنا القيمةapplication/json.authorization: مفتاح استدعاء API، ويمكن اختياره مباشرة من القائمة المنسدلة بعد الحصول عليه.
يتضمن متن الطلب ما يلي:
id: معرّف المهمة المُرسلة.action: طريقة التعامل مع المهمة.
متن الطلب كما يلي.
{
"action": "retrieve",
"id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d"
}
¶ أمثلة على الكود
يمكن إنشاء كود الاستدعاء المقابل في الجانب الأيمن من صفحة تصحيح الأخطاء، وفيما يلي مثالان لكل من cURL وPython.
¶ CURL
curl -sS -X POST 'https://api.orchats.repoingest.com/suno/tasks' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"action": "retrieve",
"id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d"
}'
¶ Python
import os
import requests
url = "https://api.orchats.repoingest.com/suno/tasks"
headers = {
"accept": "application/json",
"authorization": f"Bearer {os.environ['API_KEY']}",
"content-type": "application/json",
}
payload = {
"action": "retrieve",
"id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
}
response = requests.post(url, json=payload, headers=headers, timeout=180)
print(response.text)
¶ مثال على الاستجابة
بعد نجاح الطلب، ستُرجع API تفاصيل مهمة الأغنية هنا. على سبيل المثال:
{
"id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
"type": "audios",
"created_at": 1796115741.863,
"started_at": 1796115741.863,
"finished_at": 1796115800.404,
"elapsed": 58.541,
"request": {
"action": "generate",
"model": "chirp-v6",
"prompt": "A song for Christmas"
},
"trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
"response": {
"success": true,
"task_id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
"trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
"data": [
{
"id": "15b56d7a-1ad1-4dc6-bc74-79b102caceeb",
"title": "Room for One More Chair",
"lyric": "[Verse 1]\nThe kettle sings, the window steams\nA paper chain hangs slightly crooked\nYou set the old tin on the shelf\nAnd laugh at how the years have kept it",
"audio_url": "https://cdn.acedata2.cloud/suno/15b56d7a-1ad1-4dc6-bc74-79b102caceeb.mp3",
"created_at": "2026-12-01T09:02:22.466Z",
"model": "chirp-v6",
"state": "succeeded",
"prompt": "A song for Christmas",
"style": "Cinematic Christmas pop with film-score scale, a steady four-on-the-floor pulse, driving syncopated percussion, and a repeating cello ostinato. Begin with intimate piano and close, warm lead vocals; build through layered strings, brass swells, and wordless choir accents into a wide, uplifting final chorus. Polished, spacious mix with clear vocal focus and dynamic section lifts.",
"duration": 231.96
},
{
"id": "555bf85a-907c-4573-b6f3-e816c04aabb9",
"title": "Always Room for More",
"lyric": "[Intro]\n[Wordless vocals]\nOh—ah, oh—ah\n[Verse 1]\nSnow gathers softly on the windowpane",
"audio_url": "https://cdn.acedata2.cloud/suno/555bf85a-907c-4573-b6f3-e816c04aabb9.mp3",
"created_at": "2026-12-01T09:02:22.466Z",
"model": "chirp-v6",
"state": "succeeded",
"prompt": "A song for Christmas",
"style": "Cinematic Christmas pop with marathon-film scale, syncopated rhythmic drive, cello ostinato, four-on-the-floor pulse, and wordless vocal drops. Begin with a restrained cello figure and distant wordless voices; build into a broad, uplifting chorus with layered strings, punchy percussion, and a clear lead vocal. Use a brief countdown-style dropout before the final chorus, then finish with a full, resolved orchestral-pop ending. Polished, spacious mix with strong low-end and crisp rhythmic detail.",
"duration": 231.2
}
],
"cost": {
"amount": 0.504,
"currency": "credit",
"list_amount": 0.56
}
}
}
تحتوي النتيجة المُعادة على عدة حقول؛ حقل request هو متن الطلب عند بدء المهمة، بينما حقل response هو متن الاستجابة المُعاد بعد اكتمال المهمة. وفيما يلي شرح الحقول.
id، معرّف مهمة إنشاء الأغنية، ويُستخدم لتحديد مهمة إنشاء الأغنية هذه بشكل فريد.request، معلومات الطلب في مهمة الأغنية المستعلم عنها.response، النتيجة المُعادة عند اكتمال المهمة. بالنسبة إلى الأغاني المنشأة حديثًا، فإنresponse.data[].image_urlهو رابط الغلاف الأصلي، ويمكن قراءة الغلاف عالي الدقة منimage_large_urlعند توفره. أما المهام السابقة فتُرجع الروابط المحفوظة في حينها.created_at، وقت إنشاء المهمة، وهو طابع زمني بنظام Unix (بالثواني، عدد عشري).started_at، وقت بدء تنفيذ المهمة، وهو طابع زمني بنظام Unix (بالثواني، عدد عشري).finished_at، وقت اكتمال المهمة، وهو طابع زمني بنظام Unix (بالثواني). يكون مفقودًا أو فارغًا عندما لا تكون المهمة مكتملة.elapsed، مدة تنفيذ المهمة، بوحدة الثواني. تُقدَّم بعد اكتمال المهمة. يشير HTTP 200 إلى نجاح الاستعلام. انتظر أولًا حتى تصبح لـfinished_atقيمة، ثم اقرأresponse.success. بعد نجاح المهمة، استخرجresponse.data، وعند فشلها تحقق منresponse.error.
¶ عملية الاستعلام عن مجموعة
عند الاستعلام عن مهام متعددة دفعة واحدة، اضبط action على retrieve_batch.
يتضمن نص الطلب ما يلي:
ids:مصفوفة معرّفات المهام المرفوعة.action:طريقة تنفيذ العملية على المهام.
نص الطلب كما يلي.
{
"action": "retrieve_batch",
"ids": [
"c409f30d-4b2f-4ad9-8ae7-f394e367713d",
"1a01d321-6780-4d8e-8612-02a0fad33102"
]
}
¶ مثال على الكود
يمكن استخدام cURL أو Python لإرسال نص الطلب نفسه.
¶ مثال على الاستجابة
بعد نجاح الطلب، ستُرجع واجهة API التفاصيل المحددة لجميع مهام الأغاني في هذه الدفعة. على سبيل المثال:
{
"items": [
{
"id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
"type": "audios",
"created_at": 1796115741.863,
"started_at": 1796115741.863,
"finished_at": 1796115800.404,
"elapsed": 58.541,
"request": {
"action": "generate",
"model": "chirp-v6",
"prompt": "A song for Christmas"
},
"trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
"response": {
"success": true,
"task_id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
"trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
"data": [
{
"id": "15b56d7a-1ad1-4dc6-bc74-79b102caceeb",
"title": "Room for One More Chair",
"lyric": "[Verse 1]\nThe kettle sings, the window steams\nA paper chain hangs slightly crooked\nYou set the old tin on the shelf\nAnd laugh at how the years have kept it",
"audio_url": "https://cdn.acedata2.cloud/suno/15b56d7a-1ad1-4dc6-bc74-79b102caceeb.mp3",
"created_at": "2026-12-01T09:02:22.466Z",
"model": "chirp-v6",
"state": "succeeded",
"prompt": "A song for Christmas",
"style": "Cinematic Christmas pop with film-score scale, a steady four-on-the-floor pulse, driving syncopated percussion, and a repeating cello ostinato. Begin with intimate piano and close, warm lead vocals; build through layered strings, brass swells, and wordless choir accents into a wide, uplifting final chorus. Polished, spacious mix with clear vocal focus and dynamic section lifts.",
"duration": 231.96
},
{
"id": "555bf85a-907c-4573-b6f3-e816c04aabb9",
"title": "Always Room for More",
"lyric": "[Intro]\n[Wordless vocals]\nOh—ah, oh—ah\n[Verse 1]\nSnow gathers softly on the windowpane",
"audio_url": "https://cdn.acedata2.cloud/suno/555bf85a-907c-4573-b6f3-e816c04aabb9.mp3",
"created_at": "2026-12-01T09:02:22.466Z",
"model": "chirp-v6",
"state": "succeeded",
"prompt": "A song for Christmas",
"style": "Cinematic Christmas pop with marathon-film scale, syncopated rhythmic drive, cello ostinato, four-on-the-floor pulse, and wordless vocal drops. Begin with a restrained cello figure and distant wordless voices; build into a broad, uplifting chorus with layered strings, punchy percussion, and a clear lead vocal. Use a brief countdown-style dropout before the final chorus, then finish with a full, resolved orchestral-pop ending. Polished, spacious mix with strong low-end and crisp rhythmic detail.",
"duration": 231.2
}
],
"cost": {
"amount": 0.504,
"currency": "credit",
"list_amount": 0.56
}
}
},
{
"id": "1a01d321-6780-4d8e-8612-02a0fad33102",
"type": "audios",
"created_at": 1796115741.902,
"started_at": 1796115741.902,
"finished_at": 1796115778.27,
"elapsed": 36.368,
"request": {
"action": "generate",
"model": "chirp-v6",
"title": "Window Lights",
"style": "Soft acoustic folk, fingerpicked guitar and brushed drums",
"lyric": "[Verse]\nWindow lights across the bay\nGuide the boats that drift away\n[Chorus]\nBring the morning home to me\nFold the stars into the sea",
"custom": true,
"duration": 90,
"async": true
},
"trace_id": "ffddaa23-a3dd-44de-aa4e-58a6e3f1ca2c",
"response": {
"success": true,
"task_id": "1a01d321-6780-4d8e-8612-02a0fad33102",
"trace_id": "ffddaa23-a3dd-44de-aa4e-58a6e3f1ca2c",
"data": [
{
"id": "8603c0f3-a396-455c-b945-fb48e65bf014",
"title": "Window Lights",
"lyric": "[Verse]\nWindow lights across the bay\nGuide the boats that drift away\n[Chorus]\nBring the morning home to me\nFold the stars into the sea",
"audio_url": "https://cdn.acedata2.cloud/suno/8603c0f3-a396-455c-b945-fb48e65bf014.mp3",
"created_at": "2026-12-01T09:02:22.389Z",
"model": "chirp-v6",
"state": "succeeded",
"style": "Soft acoustic folk, fingerpicked guitar and brushed drums",
"duration": 89.48
},
{
"id": "50487a72-bc9c-4511-93d7-e2949dfb00c0",
"title": "Window Lights",
"lyric": "[Verse]\nWindow lights across the bay\nGuide the boats that drift away\n[Chorus]\nBring the morning home to me\nFold the stars into the sea",
"audio_url": "https://cdn.acedata2.cloud/suno/50487a72-bc9c-4511-93d7-e2949dfb00c0.mp3",
"created_at": "2026-12-01T09:02:22.389Z",
"model": "chirp-v6",
"state": "succeeded",
"style": "Soft acoustic folk, fingerpicked guitar and brushed drums",
"duration": 89.56
}
],
"cost": {
"amount": 0.504,
"currency": "credit",
"list_amount": 0.56
}
}
}
],
"count": 2
}
تحتوي النتيجة المُرجعة على عدة حقول، من بينها items الذي يتضمن التفاصيل المحددة لمهام الأغاني في الدفعة، وتتطابق المعلومات المحددة لكل مهمة أغنية مع الحقول المذكورة أعلاه، وتفاصيل الحقول كما يلي.
items، جميع التفاصيل المحددة لمهام الأغاني في الدفعة. وهو مصفوفة، وتنسيق كل عنصر فيها مطابق لتنسيق النتيجة المُرجعة عند الاستعلام عن مهمة واحدة أعلاه.count، عدد مهام الأغاني التي يجري الاستعلام عنها في هذه الدفعة.
¶ CURL
curl -sS -X POST 'https://api.orchats.repoingest.com/suno/tasks' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"action": "retrieve_batch",
"ids": [
"c409f30d-4b2f-4ad9-8ae7-f394e367713d",
"1a01d321-6780-4d8e-8612-02a0fad33102"
]
}'
¶ Python
import os
import requests
url = "https://api.orchats.repoingest.com/suno/tasks"
headers = {
"accept": "application/json",
"authorization": f"Bearer {os.environ['API_KEY']}",
"content-type": "application/json",
}
payload = {
"action": "retrieve_batch",
"ids": ["c409f30d-4b2f-4ad9-8ae7-f394e367713d", "1a01d321-6780-4d8e-8612-02a0fad33102"],
}
response = requests.post(url, json=payload, headers=headers, timeout=180)
print(response.text)
¶ معالجة الأخطاء
عند استدعاء واجهة API، إذا حدث خطأ، فستُرجع واجهة API رمز الخطأ والمعلومات المقابلة. على سبيل المثال:
400 token_mismatched: تحقّق من معرّف المهمة والتطبيق الذي تنتمي إليه.400 api_not_implemented: تحقّق من عملية الاستعلام والمعلمات.401 invalid_token: تحقّق من صلاحية مفتاح API.429 too_many_requests: أبطئ الاستقصاء وفقًا لـRetry-After(إن وُجد) أو لاستراتيجية التراجع.500 api_error: احتفظ بـtrace_id، واستعلم عن المهمة نفسها بعد استعادة الاتصال بالشبكة.
¶ مثال على استجابة خطأ
{
"success": false,
"error": {
"code": "api_error",
"message": "fetch failed"
},
"trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}
¶ فشل المهمة نفسها
قد يُرجع الاستعلام HTTP 200 رغم ذلك. فيما يلي نتيجة استعلام بعد فشل مهمة إعادة إنتاج.
{
"id": "add2ba31-609e-48ca-9933-5711a88067fe",
"finished_at": 1796063763.654,
"response": {
"success": false,
"task_id": "add2ba31-609e-48ca-9933-5711a88067fe",
"trace_id": "47579d6e-185f-462e-83d2-6c827675e58d",
"error": {
"code": "timeout",
"message": "timeout while waiting for audio generation"
}
}
}
توجد تفاصيل فشل المهمة في response.error. تحقّق من الحقل الاختياري retryable قبل إعادة المحاولة. قواعد إعادة المحاولة لتوليد الأغاني
من خلال هذا المستند، تعرّفت على جميع التفاصيل المحددة لكيفية استخدام Suno Tasks API للاستعلام عن مهمة أغنية واحدة أو عن مهام الأغاني دفعة واحدة. نأمل أن يساعدك هذا المستند على دمج واجهة API هذه واستخدامها بصورة أفضل. إذا كانت لديك أي أسئلة، فلا تتردد في الاتصال بفريق الدعم الفني لدينا.