Runway Image Animation API
Professional image animation with cinema-quality results
✓ Cinema quality
✓ 16:9/9:16
✓ Pro tools
✓ Motion control
Pengesahan
Untuk mengakses Runway Image-to-Video API melalui API Doitong, gunakan kunci API Doitong anda. Sertakannya dalam mutasi GraphQL atau pengepala API REST.
// GraphQL Header
{
"Authorization": "Bearer YOUR_API_KEY"
}
// REST Header
"X-API-Key": "YOUR_API_KEY"
Mula Pantas
Mulakan dengan Runway Image-to-Video API dalam masa beberapa minit sahaja. Ikuti langkah mudah ini untuk menjana image to video pertama anda.
Langkah 1: Dapatkan Kunci API Anda
Daftar akaun Doitong dan pergi ke papan pemuka anda untuk menjana kunci API.
Langkah 2: Buat Permintaan Pertama Anda
Gunakan salah satu contoh kod di bawah untuk membuat panggilan API pertama anda.
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-i2v",
"input": {
"image": "https://example.com/your-image.jpg"
},
"options": {
"duration": 5,
"motionIntensity": "medium"
}
}
}
}'
const response = await fetch('https://api.doitong.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
query: `
mutation AnimateImage($input: ImageAnimationInput!) {
animateImage(input: $input) {
id
status
url
}
}
`,
variables: {
input: {
service: 'runway-i2v',
imageUrl: 'https://example.com/your-image.jpg',
duration: 5,
motionIntensity: 'medium'
}
}
})
});
const data = await response.json();
console.log('Animated Video:', data.data.animateImage);
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-i2v",
"input": {
"imageUrl": "https://example.com/your-image.jpg"
},
"options": {
"duration": 5,
"motionIntensity": "medium"
}
}
}
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-i2v",
"input": {
"imageUrl": "https://example.com/your-image.jpg"
},
"options": {
"duration": 5,
"motionIntensity": "medium",
"version": "gen-4"
}
}
}
Harga
Runway Image-to-Video API menggunakan model harga berasaskan kredit. Kredit ditolak berdasarkan kerumitan dan tempoh kandungan yang dijana.
| Ciri | Kredit | Penerangan |
|---|---|---|
| Penggunaan Asas | 10-50 Kredit | Kualiti dan tempoh standard |
| Penggunaan Premium | 100-500 Kredit | Kualiti tinggi dan ciri lanjutan |
Titik Akhir API
Runway Image-to-Video API tersedia melalui titik akhir GraphQL kami yang bersatu.
Titik Akhir GraphQL
POST https://api.doitong.com/graphql
Titik Akhir REST
POST https://api.doitong.com/v1/image_to_video
Parameter
Parameter yang tersedia untuk permintaan Runway Image-to-Video API:
| Parameter | Jenis | Wajib | Penerangan |
|---|---|---|---|
service |
Rentetan | Yes | Pengecam perkhidmatan: "runway-i2v" |
prompt |
Rentetan | Yes | Penerangan teks tentang perkara yang ingin dijana |
duration |
Integer | No | Tempoh video dalam saat (lalai: 5) |
aspectRatio |
Rentetan | No | Nisbah aspek: "16:9", "9:16", "1:1" (lalai: "16:9") |
version |
Rentetan | No | Model version: "gen-2", "gen-3", "gen-4" |
webhookUrl |
Rentetan | No | URL untuk menerima pemberitahuan selesai |
Format Respons
Semua respons API mengikut format yang konsisten:
Respons Berjaya
{
"data": {
"imagevideo": {
"id": "abc123xyz",
"status": "processing",
"url": null,
"webhookUrl": "https://your-webhook.com/callback",
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Respons Selesai
{
"data": {
"imagevideo": {
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
"duration": 5,
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Pengendalian Ralat
API ini menggunakan kod status HTTP standard dan mengembalikan mesej ralat yang terperinci.
Kod Ralat Biasa
| Kod Status | Jenis Ralat | Penerangan |
|---|---|---|
| 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 |
Format Respons Ralat
{
"errors": [
{
"message": "Insufficient credits for this operation",
"extensions": {
"code": "INSUFFICIENT_CREDITS",
"creditsRequired": 100,
"creditsAvailable": 50
}
}
]
}
Webhook
Terima pemberitahuan masa nyata apabila penjanaan image to video anda selesai.
Menetapkan Webhook
Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.
Payload Webhook
{
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
"service": "runway-i2v",
"createdAt": "2024-01-01T00:00:00Z",
"completedAt": "2024-01-01T00:01:00Z",
"metadata": {
"duration": 5,
"width": 1920,
"height": 1080
}
}
Keselamatan Webhook
Semua permintaan webhook menyertakan pengepala tandatangan untuk pengesahan:
X-Doitong-Signature: sha256=abc123...
Had Kadar
Untuk memastikan penggunaan yang adil dan kestabilan sistem, had kadar berikut dikenakan:
| Pelan | Permintaan/Minit | Tugasan Serentak | Had Harian |
|---|---|---|---|
| Percuma | 10 | 1 | 100 |
| Permulaan | 30 | 3 | 1,000 |
| Pro | 60 | 10 | 10,000 |
| Perusahaan | Tersuai | Tersuai | Tanpa Had |
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Window reset timestamp
Amalan Terbaik
1. Optimumkan Gesaan Anda
Tulis gesaan yang jelas dan deskriptif untuk hasil terbaik:
- Be specific about visual elements, style, and mood
- Include details about lighting, camera angles, and composition
- Avoid contradictory or impossible requests
2. Kendalikan Pemprosesan Asinkron
Penjanaan adalah asinkron. Laksanakan 'polling' atau webhook yang betul:
// 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. Pemulihan Ralat
Laksanakan logik cuba semula dengan 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. Pantau Penggunaan Kredit
Jejaki penggunaan kredit anda untuk mengelakkan gangguan perkhidmatan:
- Check credit balance before large batch operations
- Set up alerts for low credit thresholds
- Implement credit-aware request queuing
Bersedia untuk Bermula?
Sertai beribu-ribu pembangun yang menggunakan Runway Image-to-Video API untuk mencipta kandungan yang menakjubkan