Wan Generowanie Wideo

Specjalizacja w stabilnych 5-sekundowych klipach. Dostępne w rozdzielczościach 480p i 1080p z niezawodną jakością.

✓ v2.2

✓ 5 sekund

✓ 480p/1080p

✓ Stabilny rezultat

Authentication

To access Wan through Doitong API, use your Doitong API key. Include it in the GraphQL mutation or REST API headers.

Important: Keep your Doitong API key secure and never expose it in client-side code. Always make API calls from your backend server.
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

// REST Header
"X-API-Key": "YOUR_API_KEY"

Quick Start

Get started with Wan 2.2 API in just a few minutes. Follow these simple steps to generate your first text to video.

Step 1: Get Your API Key

Sign up for a Doitong account and navigate to your dashboard to generate an API key.

Step 2: Make Your First Request

Use one of the code examples below to make your first API call.

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": "wan",
        "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: 'wan',
        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": "wan",
        "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": "wan",
    "input": {
      "text": "A serene landscape with mountains and a lake at sunset"
    },
    "options": {
      "duration": 5,
      "aspectRatio": "16:9",
      "version": "2.2",
      "quality": "high"
    }
  }
}

Pricing

The Wan 2.2 API uses a credit-based pricing model. Credits are consumed based on the complexity and duration of the generated content.

Feature Credits Description
Tryb standardowy 100-200 Credits 5-10 sekundowe wideo w standardowej jakości
Tryb profesjonalny 300-500 Credits 5-10 sekundowe wideo w profesjonalnej jakości

API Endpoints

The Wan 2.2 API is available through our unified GraphQL endpoint.

GraphQL Endpoint

POST https://api.doitong.com/graphql

REST Endpoint

POST https://api.doitong.com/v1/text_to_video

Parameters

Available parameters for Wan 2.2 API requests:

Parameter Type Required Description
service Ciąg znaków Yes Service identifier: "wan"
prompt Ciąg znaków Yes Text description of what to generate
duration Liczba całkowita No Video duration in seconds (default: 5)
aspectRatio Ciąg znaków No Aspect ratio: "16:9", "9:16", "1:1" (default: "16:9")
version Ciąg znaków No Model version: "2.2"
webhookUrl Ciąg znaków No URL to receive completion notifications

Response Format

All API responses follow a consistent format:

Success Response

{
  "data": {
    "generatevideo": {
      "id": "abc123xyz",
      "status": "processing",
      "url": null,
      "webhookUrl": "https://your-webhook.com/callback",
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Completed Response

{
  "data": {
    "generatevideo": {
      "id": "abc123xyz",
      "status": "completed",
      "url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
      "duration": 5,
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Error Handling

The API uses standard HTTP status codes and returns detailed error messages.

Common Error Codes

Status Code Error Type Description
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

Error Response Format

{
  "errors": [
    {
      "message": "Insufficient credits for this operation",
      "extensions": {
        "code": "INSUFFICIENT_CREDITS",
        "creditsRequired": 100,
        "creditsAvailable": 50
      }
    }
  ]
}

Webhooks

Receive real-time notifications when your text to video generation is complete.

Setting Up 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": "wan",
  "createdAt": "2024-01-01T00:00:00Z",
  "completedAt": "2024-01-01T00:01:00Z",
  "metadata": {
    "duration": 5,
    "width": 1920,
    "height": 1080
  }
}

Webhook Security

All webhook requests include a signature header for verification:

X-Doitong-Signature: sha256=abc123...

Rate Limits

To ensure fair usage and system stability, the following rate limits apply:

Plan Requests/Minute Concurrent Jobs Daily Limit
Free 10 1 100
Starter 30 3 1,000
Pro 60 10 10,000
Enterprise Custom Custom Unlimited
Rate Limit Headers: Check response headers for current limit status:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

Best Practices

1. Optimize Your Prompts

Write clear, descriptive prompts for best results:

  • Be specific about visual elements, style, and mood
  • Include details about lighting, camera angles, and composition
  • Avoid contradictory or impossible requests

2. Handle Async Processing

Generation is asynchronous. Implement proper polling or 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. Error Recovery

Implement retry logic with 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. Monitor Credit Usage

Track your credit consumption to avoid interruptions:

  • Check credit balance before large batch operations
  • Set up alerts for low credit thresholds
  • Implement credit-aware request queuing

Ready to Get Started?

Join thousands of developers using Wan 2.2 API to create amazing content

Get API Key View Pricing