Doitong 開發者中心

一站式 AI 內容生成 API 套件

透過單一整合 API 即可存取 30 多種頂尖 AI 模型。以業界領先的品質生成影片、圖片、虛擬人與語音。

30+
AI Models
8
Video APIs
9
Image Models
99.9%
Uptime SLA
<2s
Avg Response

文字轉影片 API

利用全球最先進的 AI 影片模型,將文字提示詞轉化為驚艷的影片

🎬
Kling
Kuaishou Technology

業界領先的影片生成模型,提供 6 個版本 (1.0-2.1)。支援標準與專業模式,5-10 秒影片,具備卓越的動態連貫性。

v1.0 - v2.1 5-10 秒長度 專業模式 1080p 解析度
🚀
Minimax / Hailuo-02
Minimax Technology

具備卓越場景理解力與自然動態的先進影片生成。可用模型包含 Hailuo-02 與 HailuoI2V。

1280x720 5 秒長度 自然動態 快速生成
Veo-3
Google DeepMind

Google 最新的影片模型,具備無與倫比的寫實感與物理準確性。頂級品質輸出。

超寫實風格 符合物理規律 Google 頂尖品質 支援 4K
🎨
Runway Gen4
Runway ML

使用 Gen-2、Gen-3 與 Gen4 模型的專業圖片動畫化工具。提供電影級成果。

Gen-2, Gen-3, Gen4 圖片動畫化 電影級品質 專業級功能
🌟
Luma Labs
Luma AI

透過 Dream Machine 進行藝術化影片生成。創作具備獨特美學的超現實與創意影片。

Dream Machine 藝術風格 創意無限 5 秒長度
💎
Seedance
ByteDance

先進的舞蹈合成技術,支援多人編舞。可根據參考素材建立同步舞蹈影片。

舞蹈合成 支援多人 編舞功能 參考素材驅動
🎯
Wan 2.2
Wan Technology

專精於穩定的 5 秒短片。提供 480p 與 1080p 解析度,輸出品質可靠。

v2.2 版本 5 秒長度 480p/1080p 穩定輸出
🛍️
Vidu
Vidu AI

專注於電子商務的影片生成。針對產品展示與行銷內容進行優化。

電子商務優化 產品展示影片 8 秒長度 行銷即戰力

文字轉圖片 API

使用最尖端的擴散模型,根據文字描述創作精美圖片

🎨
Google Imagen 3
Google AI

Google's most advanced image model with photorealistic quality and exceptional prompt adherence. Multiple sub-models available.

Photorealistic Large/Medium Fast turbo High resolution
Flux Dev
Black Forest Labs

適合快速迭代的開發模型。在原型開發的生成速度與品質之間取得完美平衡。

快速生成 開發專用 50 點額度 支援所有比例
💎
Flux Pro
Black Forest Labs

具備強化細節與藝術控制力的專業圖片生成。穩定性極佳。

專業等級 高品質輸出 100 點額度 強化控制
🚀
Flux Pro 1.1
Black Forest Labs

Enhanced version with improved prompt understanding and faster generation times. Better composition.

Version 1.1 250 credits Faster Improved
👑
Flux Pro 1.1 Ultra
Black Forest Labs

最高品質的圖片生成。為嚴苛專案提供極致細節與解析度。

極致品質 4K 輸出 200 點額度 最高細節
🎯
Flux Kontext
Kontext AI

Specialized for context-aware generation with Pro and Max modes. Excellent for specific style requirements.

Pro/Max modes Context-aware Style control Reference support
Flux Krea
Krea AI

優化的 Flux 實作,提供多種品質等級以實現快速生成。

多種等級 快速生成 效能優化 彈性計價
🖼️
Minimax Image
Minimax

先進的中文圖片模型,具備優異的藝術理解與風格控制。

藝術風格 中文優化 高品質 支援批次處理
🎨
Stable Diffusion
Stability AI

業界標準的開源模型,具備廣泛的客製化選項。

開源生態 高度可客製 ControlNet 支援 LoRA

圖片轉影片 API

透過智慧動態與動畫效果,賦予靜態圖片生動活力

🎬
Kling Animation
Kuaishou

Transform images into smooth videos with natural motion. Multiple versions and quality modes available.

Image-to-video 5-10 seconds Natural motion Pro mode
🎥
Runway Animation
Runway ML

Professional image animation with Gen-2, Gen-3, and Gen4 models. Cinema-quality results.

Gen2/3/4 Cinema quality 16:9/9:16 Pro tools

虛擬人、對嘴與 TTS API

建立會說話的虛擬人,並生成自然且完美同步的語音

👄
Hedra Lip Sync
Hedra AI

具備完美音訊同步的角色動畫。賦予肖像生動的表情與動作。

角色動畫 音訊同步 肖像驅動 表情控制
🎙️
ElevenLabs TTS
ElevenLabs

最自然的 AI 語音,具備情感控制並支援多種語言。

自然語音 情感控制 29 種語言 語音複製
🔊
Google TTS
Google Cloud

Google's neural text-to-speech with WaveNet voices. Over 380 voices in 50+ languages with SSML support.

380+ voices 50+ languages WaveNet SSML

單一 API,無限可能

🎯 全能生成

所有內容類型(影片、圖片、音訊、虛擬人)皆使用單一 'generate' 方法。透過一致的 API 簡化您的整合流程。

🤖 智慧供應商選擇

讓我們的 AI 根據您的需求自動選擇最佳供應商,或指定您偏好的供應商以獲得完整控制權。

🔄 冪等請求

透過 Idempotency-Key 標頭進行安全重試。再也不必擔心因網路問題導致的重複扣費。

📊 智慧速率限制

清晰的速率限制標頭 (X-RateLimit-*) 協助您優化請求時機,避免 429 錯誤。

🔔 安全 Webhooks

支援 HMAC 簽名的 Webhooks,提供安全的非同步通知。在內容準備就緒時立即獲得通知。

⚡ 清晰的錯誤代碼

提供機器可讀的錯誤代碼(如 INSUFFICIENT_CREDITS 和 RATE_LIMIT),讓除錯變得簡單直覺。

常見錯誤代碼

代碼 描述 建議操作
INSUFFICIENT_CREDITS 額度不足,無法執行此操作 請為您的帳戶儲值額度
RATE_LIMIT 請求過於頻繁 請檢查 X-RateLimit-Reset 標頭
INVALID_INPUT 提供的參數無效 請根據 Schema 檢查輸入內容
PROVIDER_UNAVAILABLE 選定的供應商暫時無法使用 請重試或使用自動選擇模式
GENERATION_FAILED 內容生成失敗 請嘗試使用不同的參數重試

各方案速率限制

方案 請求數/分鐘 並行數 每日限制
Free 10 1 100
Starter 30 3 1,000
Pro 60 10 10,000
Enterprise Custom Custom Unlimited

快速入門程式碼範例

# Universal generation API - Video example
curl -X POST https://api.doitong.com/graphql \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: unique-request-id-123" \
  -d '{
    "query": "mutation Generate($input: GenerateInput!) { generate(input: $input) { id status type provider url metadata { duration resolution } creditCost estimatedTime } }",
    "variables": {
      "input": {
        "type": "VIDEO",
        "provider": "minimax",
        "input": {
          "text": "A serene mountain landscape at sunset"
        },
        "options": {
          "duration": 10,
          "resolution": "1080p",
          "style": "cinematic"
        }
      }
    }
  }'

# Auto-select best provider for quality
curl -X POST https://api.doitong.com/graphql \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation { generate(input: { type: VIDEO, input: { text: \"Epic dragon battle\" }, priority: QUALITY }) { id status provider creditCost } }"
  }'

# Check generation status
curl -X POST https://api.doitong.com/graphql \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { generation(id: \"gen_abc123\") { status progress url error { code message } } }"
  }'
// Doitong Universal API Client
class DoitongAPI {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.endpoint = 'https://api.doitong.com/graphql';
  }

  async generate(input) {
    const response = await fetch(this.endpoint, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.apiKey}`,
        'Content-Type': 'application/json',
        'Idempotency-Key': crypto.randomUUID()
      },
      body: JSON.stringify({
        query: `
          mutation Generate($input: GenerateInput!) {
            generate(input: $input) {
              id
              status
              type
              provider
              url
              metadata
              creditCost
              estimatedTime
              error {
                code
                message
              }
            }
          }
        `,
        variables: { input }
      })
    });

    const data = await response.json();
    
    // Check for rate limits
    const remaining = response.headers.get('X-RateLimit-Remaining');
    if (remaining && parseInt(remaining) < 10) {
      console.warn(`Low rate limit: ${remaining} requests remaining`);
    }
    
    if (data.errors) {
      throw new Error(data.errors[0].message);
    }
    
    return data.data.generate;
  }

  async checkStatus(id) {
    const response = await fetch(this.endpoint, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.apiKey}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        query: `
          query GetGeneration($id: ID!) {
            generation(id: $id) {
              id
              status
              progress
              url
              error {
                code
                message
              }
            }
          }
        `,
        variables: { id }
      })
    });
    
    const data = await response.json();
    return data.data.generation;
  }

  async waitForCompletion(id, pollInterval = 2000) {
    while (true) {
      const result = await this.checkStatus(id);
      
      if (result.status === 'COMPLETED') {
        return result;
      } else if (result.status === 'FAILED') {
        throw new Error(result.error?.message || 'Generation failed');
      }
      
      await new Promise(resolve => setTimeout(resolve, pollInterval));
    }
  }
}

// Usage examples
const api = new DoitongAPI('YOUR_API_KEY');

// Simple video generation - let AI choose provider
const video = await api.generate({
  type: 'VIDEO',
  input: { text: 'A serene mountain landscape' }
});

// Specific provider with options
const video = await api.generate({
  type: 'VIDEO',
  provider: 'minimax',
  input: { text: 'Epic battle scene' },
  options: {
    duration: 10,
    resolution: '1080p',
    style: 'cinematic'
  }
});

// Image generation with auto-provider selection for quality
const image = await api.generate({
  type: 'IMAGE',
  input: { text: 'Photorealistic portrait' },
  priority: 'QUALITY'
});

// Wait for completion
const result = await api.waitForCompletion(video.id);
console.log('Video ready:', result.url);

// Using Apollo Client for GraphQL
import { ApolloClient, gql } from '@apollo/client';

const CREATE_VIDEO = gql`
  mutation CreateVideo($input: VideoCreateInput!) {
    videoCreate(input: $input) {
      id
      status
      videoUrl
    }
  }
`;

const client = new ApolloClient({
  uri: 'https://api.doitong.com/graphql',
  headers: {
    authorization: 'Bearer YOUR_API_KEY'
  }
});

const result = await client.mutate({
  mutation: CREATE_VIDEO,
  variables: {
    input: {
      prompt: 'Beautiful sunset over ocean',
      model: 'luma',
      duration: 9
    }
  }
});
import requests
import time
import json
import uuid
from typing import Dict, Optional, Any

class DoitongAPI:
    def __init__(self, api_key: str):
        self.api_key = api_key
        self.base_url = "https://api.doitong.com/graphql"
        self.headers = {
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json"
        }
    
    def generate(self, 
                 content_type: str,
                 input_data: Dict[str, Any],
                 provider: Optional[str] = None,
                 options: Optional[Dict] = None,
                 idempotency_key: Optional[str] = None) -> Dict:
        """Universal generation method for all content types"""
        
        # Add idempotency key for safe retries
        headers = self.headers.copy()
        if idempotency_key:
            headers["Idempotency-Key"] = idempotency_key
        else:
            headers["Idempotency-Key"] = str(uuid.uuid4())
        
        query = """
        mutation Generate($input: GenerateInput!) {
          generate(input: $input) {
            id
            status
            type
            provider
            url
            metadata
            creditCost
            estimatedTime
            error
            errorCode
          }
        }
        """
        
        variables = {
            "input": {
                "type": content_type.upper(),
                "input": input_data
            }
        }
        
        if provider:
            variables["input"]["provider"] = provider
        if options:
            variables["input"]["options"] = options
        
        response = requests.post(
            self.base_url,
            headers=headers,
            json={"query": query, "variables": variables}
        )
        
        # Handle rate limiting
        if response.status_code == 429:
            retry_after = response.headers.get("X-RateLimit-Reset", 60)
            raise Exception(f"Rate limited. Retry after {retry_after} seconds")
        
        data = response.json()
        
        if "errors" in data:
            error = data["errors"][0]
            raise Exception(f"API Error: {error.get('message', 'Unknown error')}")
        
        return data["data"]["generate"]
    
    def check_status(self, generation_id: str) -> Dict:
        """Check the status of a generation"""
        query = """
        query GetGeneration($id: ID!) {
          generation(id: $id) {
            id
            status
            type
            url
            progress
            error
            errorCode
            metadata
          }
        }
        """
        
        response = requests.post(
            self.base_url,
            headers=self.headers,
            json={
                "query": query,
                "variables": {"id": generation_id}
            }
        )
        
        return response.json()["data"]["generation"]
    
    def wait_for_completion(self, generation_id: str, max_wait: int = 300) -> Dict:
        """Poll until generation is complete"""
        start_time = time.time()
        
        while time.time() - start_time < max_wait:
            result = self.check_status(generation_id)
            
            if result["status"] == "completed":
                return result
            elif result["status"] == "failed":
                error_code = result.get("errorCode", "UNKNOWN_ERROR")
                error_msg = result.get("error", "Generation failed")
                raise Exception(f"[{error_code}] {error_msg}")
            
            # Adaptive polling - start fast, slow down over time
            wait_time = 2 if time.time() - start_time < 30 else 5
            time.sleep(wait_time)
        
        raise TimeoutError("Generation timed out")

# Example usage
if __name__ == "__main__":
    api = DoitongAPI("YOUR_API_KEY")
    
    try:
        # Generate a video (auto-selects best provider)
        video = api.generate(
            content_type="video",
            input_data={"text": "A majestic eagle soaring through clouds"},
            options={"duration": 10, "resolution": "1080p"}
        )
        print(f"Video generation started: {video['id']}")
        
        # Wait for completion
        result = api.wait_for_completion(video['id'])
        print(f"Video ready: {result['url']}")
        print(f"Credits used: {result['creditCost']}")
        
        # Generate with specific provider
        image = api.generate(
            content_type="image",
            provider="flux-ultra",
            input_data={"text": "Professional product photography"},
            options={"aspectRatio": "16:9", "quality": "ultra"}
        )
        
        # Generate audio/TTS
        audio = api.generate(
            content_type="audio",
            provider="elevenlabs",
            input_data={"text": "Welcome to the future of AI"},
            options={"voice": "rachel", "emotion": "excited"}
        )
        
    except Exception as e:
        print(f"Error: {e}")
# Universal generation mutation - works for all content types
mutation Generate($input: GenerateInput!) {
  generate(input: $input) {
    id
    status
    type
    provider
    url
    metadata
    creditCost
    estimatedTime
    progress
    error
    errorCode
  }
}

# Example: Generate video (auto-select provider)
# Variables:
{
  "input": {
    "type": "VIDEO",
    "input": {
      "text": "A bustling Tokyo street at night with neon lights"
    },
    "options": {
      "duration": 10,
      "resolution": "1080p",
      "style": "cinematic"
    }
  }
}

# Example: Generate video with specific provider
# Variables:
{
  "input": {
    "type": "VIDEO",
    "provider": "kling",
    "input": {
      "text": "Epic space battle scene"
    },
    "options": {
      "mode": "pro",
      "duration": 10,
      "aspectRatio": "16:9"
    }
  }
}

# Example: Image-to-video generation
# Variables:
{
  "input": {
    "type": "VIDEO",
    "provider": "runway",
    "input": {
      "text": "Make the character dance",
      "image": "https://example.com/character.jpg"
    },
    "options": {
      "motionIntensity": "high",
      "model": "gen-3"
    }
  }
}

# Example: Generate image
# Variables:
{
  "input": {
    "type": "IMAGE",
    "provider": "flux-ultra",
    "input": {
      "text": "Photorealistic portrait in Rembrandt style"
    },
    "options": {
      "aspectRatio": "16:9",
      "quality": "ultra",
      "seed": 42
    }
  }
}

# Example: Generate audio/TTS
# Variables:
{
  "input": {
    "type": "AUDIO",
    "provider": "elevenlabs",
    "input": {
      "text": "Welcome to the future of artificial intelligence"
    },
    "options": {
      "voice": "rachel",
      "emotion": "excited",
      "speed": 1.0
    }
  }
}

# Example: Generate avatar video
# Variables:
{
  "input": {
    "type": "AVATAR",
    "provider": "heygen",
    "input": {
      "text": "Hello, I'm your AI assistant",
      "voice": "professional_female"
    },
    "options": {
      "avatarId": "kate",
      "background": "modern_office",
      "gesture": "friendly"
    },
    "webhookUrl": "https://your-app.com/webhook"
  }
}

# Query generation status
query GetGeneration($id: ID!) {
  generation(id: $id) {
    id
    status
    type
    provider
    url
    progress
    metadata {
      width
      height
      duration
      format
    }
    creditCost
    error
    errorCode
    createdAt
    completedAt
  }
}

# Cancel a generation
mutation CancelGeneration($id: ID!) {
  cancelGeneration(id: $id)
}

# Get available providers for a content type
query GetProviders($type: GenerationType!) {
  providers(type: $type) {
    id
    name
    description
    features
    limitations
    pricing {
      creditCost
      estimatedTime
    }
    options {
      name
      type
      required
      description
      allowedValues
    }
  }
}
}

準備好打造驚人的產品了嗎?

加入數千名開發者的行列,使用我們的 API 創作新一代 AI 內容