ओपन API
इमेज / वीडियो जनरेशन टास्क बनाने के लिए REST API। अपने अकाउंट पेज से sk- कुंजी के साथ प्रमाणित करें।
API कुंजी प्रबंधित करेंप्रमाणीकरण
सभी अनुरोधों के लिए एक बियरर टोकन आवश्यक है। अपने अकाउंट पेज से एक जनरेट करें।
Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxउपलब्ध मॉडल
नीचे दिए गए model_id मान ही ओपन API द्वारा स्वीकार किए जाते हैं।
| model_id | क्षमता | आउटपुट |
|---|---|---|
seedance-2 | Seedance 2.0 (text / image to video) | video_url |
gpt-image-2 | ChatGPT Image 2 (text / image to image) | image_url |
nano-banana-2 | Nano Banana 2 (text / image to image) | image_url |
टास्क बनाएँ
जनरेशन अनुरोध सबमिट करें। प्रतिक्रिया में एक task_id मिलेगा जिसे आप पोल कर सकते हैं।
POST
/api/v1/tasks/createअनुरोध बॉडी
{
"model_id": "gpt-image-2",
"prompt": "a serene zen garden at sunrise, ultra detailed",
"image_urls": [],
"aspect_ratio": "16:9"
}cURL उदाहरण
curl -X POST https://your-site.com/api/v1/tasks/create \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model_id": "gpt-image-2",
"prompt": "a serene zen garden at sunrise",
"aspect_ratio": "16:9"
}'प्रतिक्रिया
{
"code": 200,
"msg": "提交成功,等待生成",
"data": {
"task_id": "abcdef123456",
"request_id": "kie_xxxxxxxxxxxx",
"credits": 15
}
}सबमिट करने पर क्रेडिट काट लिए जाते हैं। असफल टास्क अपने आप रिफंड हो जाते हैं।
टास्क क्वेरी करें
टास्क को आईडी द्वारा तब तक जांचें जब तक task_status 3 (सफल) या 4 (असफल) न हो जाए।
GET
/api/v1/tasks/{task_id}cURL उदाहरण
curl https://your-site.com/api/v1/tasks/abcdef123456 \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"प्रतिक्रिया
{
"code": 200,
"msg": "ok",
"data": {
"task_id": "abcdef123456",
"task_status": 3,
"task_type": "image",
"model_id": "gpt-image-2",
"image_url": "https://your-cdn.com/...",
"video_url": null,
"audio_url": null,
"credits": 15,
"created_at": 1730000000
}
}task_status: 1 कतार में, 2 चल रहा है, 3 सफल, 4 असफल।
त्रुटियाँ
code: 200— सफलताcode: 0— व्यावसायिक विफलता (विवरण के लिए msg फ़ील्ड देखें)HTTP 401— अमान्य या अनुपलब्ध API कुंजी