Sreath Chruthachail Runway
Beothachadh dhealbhan proifeasanta le modalan Gen-2, Gen-3, agus Gen4. Toraidhean aig càileachd taigh-dhealbh.
✓ Modalan Gen-2, Gen-3, Gen4
✓ Beothachadh dhealbhan
✓ Smachd gluasaid
✓ Càileachd HD
Dearbh-aithneachadh
Gus cothrom fhaighinn air Runway tro API Doitong, cleachd an iuchair API Doitong agad. Cuir i an sàs ann am mùthadh GraphQL no ann am bannan-cinn an API REST.
// GraphQL Header
{
"Authorization": "Bearer YOUR_API_KEY"
}
// REST Header
"X-API-Key": "YOUR_API_KEY"
Toiseach Luath
Tòisich le Runway Gen4 API ann am beagan mhionaidean. Lean na ceumannan sìmplidh seo gus a' chiad text to video agad a chruthachadh.
Ceum 1: Faigh an Iuchair API agad
Clàraich airson cunntas Doitong agus rach chun deas-bhòrd agad gus iuchair API a chruthachadh.
Ceum 2: Dèan a' Chiad Iarrtas agad
Cleachd fear de na h-eisimpleirean còda gu h-ìosal gus a' chiad ghairm API agad a dhèanamh.
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"
}
}
}
Prìsean
Tha Runway Gen4 API a' cleachdadh modail prìse stèidhichte air creideasan. Thèid creideasan a chleachdadh a rèir cho iomadh-fhillte 's a tha an t-susbaint agus dè cho fada 's a mhaireas i.
| Feart | Creideasan | Tuairisgeul |
|---|---|---|
| Modh Àbhaisteach | 100-200 Creideasan | Bhidio 5-10 diog aig càileachd àbhaisteach |
| Modh Pro | 300-500 Creideasan | Bhidio 5-10 diog aig càileachd proifeasanta |
Puingean-crìche API
Tha Runway Gen4 API ri fhaighinn tron phuing-chrìche GraphQL aonaichte againn.
Puing-chrìche GraphQL
POST https://api.doitong.com/graphql
Puing-chrìche REST
POST https://api.doitong.com/v1/text_to_video
Paramaidirean
Paramaidirean a tha rim faighinn airson iarrtasan Runway Gen4 API:
| Paramaid | Seòrsa | Riatanach | Tuairisgeul |
|---|---|---|---|
service |
String | Yes | Aithneadair seirbheis: "runway" |
prompt |
String | Yes | Tuairisgeul teacsa air na tha ri chruthachadh |
duration |
Integer | No | Fad a' bhidio ann an diogan (bun-tomhas: 5) |
aspectRatio |
String | No | Co-mheas taobhan: "16:9", "9:16", "1:1" (bun-tomhas: "16:9") |
version |
String | No | Model version: "gen-2", "gen-3", "gen-4" |
webhookUrl |
String | No | URL airson fiosan crìochnachaidh fhaighinn |
Cruth na Freagairt
Tha a h-uile freagairt API a' leantainn cruth cunbhalach:
Freagairt Shoirbheachail
{
"data": {
"generatevideo": {
"id": "abc123xyz",
"status": "processing",
"url": null,
"webhookUrl": "https://your-webhook.com/callback",
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Freagairt Chrìochnaichte
{
"data": {
"generatevideo": {
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
"duration": 5,
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Làimhseachadh Mhearachdan
Tha an API a' cleachdadh còdan inbhe HTTP àbhaisteach agus a' tilleadh teachdaireachdan mearachd mionaideach.
Còdan Mearachd Cumanta
| Còd Inbhe | Seòrsa Mearachd | Tuairisgeul |
|---|---|---|
| 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 |
Cruth Freagairt Mearachd
{
"errors": [
{
"message": "Insufficient credits for this operation",
"extensions": {
"code": "INSUFFICIENT_CREDITS",
"creditsRequired": 100,
"creditsAvailable": 50
}
}
]
}
Webhooks
Faigh fiosan fìor-ùine nuair a bhios cruthachadh text to video deiseil.
A' rèiteachadh Webhooks
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",
"createdAt": "2024-01-01T00:00:00Z",
"completedAt": "2024-01-01T00:01:00Z",
"metadata": {
"duration": 5,
"width": 1920,
"height": 1080
}
}
Tèarainteachd Webhook
Tha bann-cinn ainm-sgrìobhte anns a h-uile iarrtas webhook airson dearbhadh:
X-Doitong-Signature: sha256=abc123...
Crìochan Luaths
Gus dèanamh cinnteach gu bheil an siostam cothromach agus seasmhach, tha na crìochan luaths seo an sàs:
| Plana | Iarrtasan/Mionaid | Obraichean aig an aon àm | Crìoch Làitheil |
|---|---|---|---|
| An-asgaidh | 10 | 1 | 100 |
| Starter | 30 | 3 | 1,000 |
| Pro | 60 | 10 | 10,000 |
| Enterprise | Gnàthaichte | Gnàthaichte | Gun chrìoch |
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Window reset timestamp
Na Cleachdaidhean as Fheàrr
1. Optimaisich na Brosnachaidhean agad
Sgrìobh brosnachaidhean soilleir, tuairisgeulach airson na toraidhean as fheàrr:
- Be specific about visual elements, style, and mood
- Include details about lighting, camera angles, and composition
- Avoid contradictory or impossible requests
2. Làimhsich Pròiseasadh Neo-shioncronach
Tha an cruthachadh neo-shioncronach. Cuir an sàs dòigh sgrùdaidh (polling) no 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. Ath-shlànachadh Mhearachdan
Cuir an sàs loidsig ath-fheuchainn le dàil eas-chruthach (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. Cum sùil air Cleachdadh Chreideasan
Cum sùil air na creideasan a chleachdas tu gus nach bi briseadh sam bith ann:
- Check credit balance before large batch operations
- Set up alerts for low credit thresholds
- Implement credit-aware request queuing
Deiseil airson Tòiseachadh?
Thig còmhla ri mìltean de luchd-leasachaidh a tha a' cleachdadh Runway Gen4 API gus susbaint iongantach a chruthachadh