Runway Creative Suite
การสร้างแอนิเมชันจากรูปภาพระดับมืออาชีพด้วยโมเดล Gen-2, Gen-3 และ Gen4 ให้ผลลัพธ์คุณภาพระดับภาพยนตร์
✓ โมเดล Gen-2, Gen-3, Gen4
✓ แอนิเมชันจากรูปภาพ
✓ การควบคุมการเคลื่อนไหว
✓ คุณภาพระดับ HD
การยืนยันตัวตน
หากต้องการเข้าใช้งาน Runway ผ่าน Doitong API โปรดใช้ API key ของคุณ โดยระบุไว้ใน GraphQL mutation หรือส่วนหัว (headers) ของ REST API
// GraphQL Header
{
"Authorization": "Bearer YOUR_API_KEY"
}
// REST Header
"X-API-Key": "YOUR_API_KEY"
เริ่มต้นใช้งานอย่างรวดเร็ว
เริ่มต้นใช้งาน Runway Gen4 API ได้ภายในไม่กี่นาที เพียงทำตามขั้นตอนง่ายๆ เหล่านี้เพื่อสร้าง text to video แรกของคุณ
ขั้นตอนที่ 1: รับ API Key
สมัครบัญชี Doitong และไปที่หน้าแดชบอร์ดเพื่อสร้าง API key ของคุณ
ขั้นตอนที่ 2: เริ่มส่งคำขอแรก
ใช้ตัวอย่างโค้ดด้านล่างเพื่อเริ่มเรียกใช้งาน API ครั้งแรก
curl -X POST https://api.doitong.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: unique-request-id-123" \
-d '{
"query": "mutation Generate($input: GenerateInput!) { generate(input: $input) { id status type provider url metadata creditCost } }",
"variables": {
"input": {
"type": "VIDEO",
"provider": "runway",
"input": {
"text": "A serene landscape with mountains and a lake at sunset"
},
"options": {
"duration": 5,
"aspectRatio": "16:9"
}
}
}
}'
const response = await fetch('https://api.doitong.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
'Idempotency-Key': 'unique-request-id-123'
},
body: JSON.stringify({
query: `
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
}
}
`,
variables: {
input: {
type: 'VIDEO',
provider: 'runway',
input: {
text: 'A serene landscape with mountains and a lake at sunset'
},
options: {
duration: 5,
aspectRatio: '16:9'
}
}
}
})
});
const data = await response.json();
console.log('Result:', data.data.generate);
import requests
import json
url = "https://api.doitong.com/graphql"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
query = """
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
}
}
"""
variables = {
"input": {
"type": "VIDEO",
"provider": "runway",
"input": {
"text": "A serene landscape with mountains and a lake at sunset"
},
"options": {
"duration": 5,
"aspectRatio": "16:9"
}
}
}
response = requests.post(url, json={
"query": query,
"variables": variables
}, headers=headers)
data = response.json()
print("Result:", data["data"]["generate"])
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
createdAt
}
}
# Variables
{
"input": {
"type": "VIDEO",
"provider": "runway",
"input": {
"text": "A serene landscape with mountains and a lake at sunset"
},
"options": {
"duration": 5,
"aspectRatio": "16:9",
"version": "gen-4",
"quality": "high"
}
}
}
ราคา
Runway Gen4 API ใช้รูปแบบราคาตามการใช้งานเครดิต โดยเครดิตจะถูกหักตามความซับซ้อนและความยาวของเนื้อหาที่สร้างขึ้น
| ฟีเจอร์ | เครดิต | คำอธิบาย |
|---|---|---|
| โหมดมาตรฐาน | 100-200 เครดิต | วิดีโอความยาว 5-10 วินาที คุณภาพมาตรฐาน |
| โหมดโปร | 300-500 เครดิต | วิดีโอความยาว 5-10 วินาที คุณภาพระดับมืออาชีพ |
API Endpoints
สามารถใช้งาน Runway Gen4 API ได้ผ่าน GraphQL endpoint ส่วนกลางของเรา
GraphQL Endpoint
POST https://api.doitong.com/graphql
REST Endpoint
POST https://api.doitong.com/v1/text_to_video
พารามิเตอร์
พารามิเตอร์ที่ใช้งานได้สำหรับคำขอ Runway Gen4 API:
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
service |
String | Yes | ตัวระบุบริการ: "runway" |
prompt |
String | Yes | คำอธิบายข้อความสำหรับสิ่งที่ต้องการสร้าง |
duration |
Integer | No | ความยาววิดีโอเป็นวินาที (ค่าเริ่มต้น: 5) |
aspectRatio |
String | No | อัตราส่วนภาพ: "16:9", "9:16", "1:1" (ค่าเริ่มต้น: "16:9") |
version |
String | No | Model version: "gen-2", "gen-3", "gen-4" |
webhookUrl |
String | No | URL สำหรับรับการแจ้งเตือนเมื่อดำเนินการเสร็จสิ้น |
รูปแบบการตอบกลับ
การตอบกลับของ API ทั้งหมดจะเป็นรูปแบบเดียวกัน ดังนี้:
การตอบกลับเมื่อสำเร็จ
{
"data": {
"generatevideo": {
"id": "abc123xyz",
"status": "processing",
"url": null,
"webhookUrl": "https://your-webhook.com/callback",
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
การตอบกลับเมื่อเสร็จสิ้น
{
"data": {
"generatevideo": {
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
"duration": 5,
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
การจัดการข้อผิดพลาด
API นี้ใช้รหัสสถานะ HTTP มาตรฐานและจะส่งข้อความแสดงข้อผิดพลาดโดยละเอียดกลับมา
รหัสข้อผิดพลาดที่พบบ่อย
| รหัสสถานะ | ประเภทข้อผิดพลาด | คำอธิบาย |
|---|---|---|
| 400 | Bad Request | Invalid parameters or malformed request |
| 401 | Unauthorized | Missing or invalid API key |
| 402 | Payment Required | Insufficient credits |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error, please retry |
รูปแบบการตอบกลับเมื่อเกิดข้อผิดพลาด
{
"errors": [
{
"message": "Insufficient credits for this operation",
"extensions": {
"code": "INSUFFICIENT_CREDITS",
"creditsRequired": 100,
"creditsAvailable": 50
}
}
]
}
Webhooks
รับการแจ้งเตือนแบบเรียลไทม์เมื่อการสร้าง text to video ของคุณเสร็จสมบูรณ์
การตั้งค่า Webhooks
Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.
Webhook Payload
{
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
"service": "runway",
"createdAt": "2024-01-01T00:00:00Z",
"completedAt": "2024-01-01T00:01:00Z",
"metadata": {
"duration": 5,
"width": 1920,
"height": 1080
}
}
ความปลอดภัยของ Webhook
คำขอ Webhook ทั้งหมดจะมีส่วนหัวลายเซ็น (signature header) เพื่อใช้ในการตรวจสอบ:
X-Doitong-Signature: sha256=abc123...
การจำกัดอัตราการใช้งาน
เพื่อให้มั่นใจในเสถียรภาพของระบบและการใช้งานที่เหมาะสม จึงมีการจำกัดอัตราการใช้งานดังนี้:
| แพ็กเกจ | คำขอต่อนาที | งานที่ประมวลผลพร้อมกัน | ขีดจำกัดต่อวัน |
|---|---|---|---|
| ฟรี | 10 | 1 | 100 |
| Starter | 30 | 3 | 1,000 |
| Pro | 60 | 10 | 10,000 |
| Enterprise | กำหนดเอง | กำหนดเอง | ไม่จำกัด |
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Window reset timestamp
แนวทางปฏิบัติที่แนะนำ
1. ปรับแต่ง Prompt ให้เหมาะสม
เขียน Prompt ที่ชัดเจนและมีรายละเอียดครบถ้วนเพื่อให้ได้ผลลัพธ์ที่ดีที่สุด:
- Be specific about visual elements, style, and mood
- Include details about lighting, camera angles, and composition
- Avoid contradictory or impossible requests
2. การจัดการประมวลผลแบบ Async
การสร้างเนื้อหาเป็นแบบอะซิงโครนัส โปรดใช้ระบบ Polling หรือ Webhooks ที่เหมาะสม:
// Polling example
async function pollStatus(jobId) {
let status = 'processing';
while (status === 'processing') {
await sleep(2000); // Wait 2 seconds
const result = await checkJobStatus(jobId);
status = result.status;
}
return result;
}
3. การกู้คืนจากข้อผิดพลาด
ควรใช้ตรรกะการลองใหม่ (Retry logic) พร้อมการหน่วงเวลาแบบ Exponential Backoff:
async function retryWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await sleep(Math.pow(2, i) * 1000);
}
}
}
4. ตรวจสอบการใช้เครดิต
ติดตามการใช้เครดิตของคุณเพื่อป้องกันการหยุดชะงักของการใช้งาน:
- Check credit balance before large batch operations
- Set up alerts for low credit thresholds
- Implement credit-aware request queuing
พร้อมเริ่มต้นใช้งานหรือยัง?
เข้าร่วมกับนักพัฒนาหลายพันคนที่ใช้ Runway Gen4 API เพื่อสร้างสรรค์เนื้อหาที่น่าทึ่ง