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

先进的视频生成模型,具有卓越的场景理解和自然动态。包含海螺-02 和海螺 I2V 模型。

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

数字人、对口型与语音合成 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 错误。

🔔 安全 Webhook

支持 HMAC 签名的 Webhook,用于接收安全的异步通知。在内容准备就绪时第一时间获得通知。

⚡ 清晰的错误代码

提供机器可读的错误代码(如 INSUFFICIENT_CREDITS 和 RATE_LIMIT),让调试变得简单高效。

常见错误代码

错误码 描述 建议操作
INSUFFICIENT_CREDITS 额度不足,无法执行此操作 请为您的账户充值
RATE_LIMIT 请求过于频繁 请检查 X-RateLimit-Reset 响应头
INVALID_INPUT 提供的参数无效 请根据 Schema 检查输入参数
PROVIDER_UNAVAILABLE 所选供应商暂时不可用 请重试或选择自动匹配供应商
GENERATION_FAILED 内容生成失败 请尝试更换参数后重试

各套餐速率限制

套餐方案 每分钟请求数 (RPM) 并发数 每日上限
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 内容