开发者 API

强大易用的 AI API

全栈 AI 视频和图像生成解决方案

集成世界顶级的 Seedance 和 Seedream 模型,一键生成专业级视频和图像。支持多种 SDK,仅需几行代码。

1000+
开发者信任
99.9%
正常运行时间
<100ms
平均响应时间
24/7
技术支持

支持的 AI 模型

Seedance 1.0

基础版
  • 720P 视频生成
  • 最长 5 秒
  • 文本转视频
  • 快速处理

Seedance 1.5 Pro

推荐
  • 1080P 视频生成
  • 最长 30 秒
  • 图像和视频转视频
  • 高级控制选项
  • AI 抠图
  • 背景替换

Seedance 2.0

新版
  • 4K 视频生成
  • 最长 60 秒
  • 高级特效
  • 实时处理

Seedream 3.0

图像
  • 2K 图像生成
  • 多样化风格
  • 快速渲染
  • 创意控制

Seedream 4.0

高级
  • 4K 图像生成
  • 高保真输出
  • 细节增强
  • 变体生成

Seedream 4.5

最新
  • 8K 图像生成
  • 超高分辨率
  • AI 处理增强
  • 专业级质量

Seedream 5.0

前沿
  • 16K 图像支持
  • 极端细节处理
  • AI 智能优化
  • 实验功能支持

为什么选择我们的 API

极速处理

优化的处理管道,<100ms 响应时间,毫秒级延迟。

企业级安全

端到端加密、ISO 27001 认证、企业级隐私保护。

数据隐私

严格遵守 GDPR,用户数据 30 天自动删除。

高可靠性

99.9% 正常运行时间保证,全球多区域部署。

无限扩展

自动扩展架构,支持任意流量,无需担心容量。

完善文档

详细 API 文档、SDK 示例、最佳实践指南。

SDK 安装

快速开始指南

Python SDK

通过 pip 安装

pip install seedance-sdk

通过 poetry 安装

poetry add seedance-sdk

Node.js SDK

通过 npm 安装

npm install seedance-sdk

通过 yarn 安装

yarn add seedance-sdk

快速开始指南

Python 示例

初始化客户端

基础设置

import seedance

# Initialize client
client = seedance.Client(api_key="your-api-key-here")

# Or use environment variable
# export SEEDANCE_API_KEY="your-api-key"
# client = seedance.Client()

生成图像

Seedream 图像生成

# Generate high-quality images using Seedream 4.5
response = client.seedream.generate(
    prompt="A serene mountain landscape at sunset, oil painting style",
    model="seedream-4.5",
    resolution="4k",
    quality="high",
    num_images=1,
    seed=42  # Optional: for reproducible results
)

# Get results
image_url = response.images[0].url
print(f"Generated image: {image_url}")

生成视频

Seedance 视频生成

# Generate video using Seedance 1.5 Pro
response = client.seedance.generate(
    prompt="A majestic eagle soaring over snowy mountains",
    model="seedance-1.5-pro",
    duration=15,  # seconds
    resolution="1080p",
    fps=24
)

# Get async task ID
task_id = response.task_id
print(f"Task submitted: {task_id}")

检查任务状态

轮询结果

import time

# Poll task status
while True:
    status = client.task.get_status(task_id)

    if status.status == "completed":
        result = status.result
        print(f"Video URL: {result.video_url}")
        break
    elif status.status == "failed":
        print(f"Task failed: {status.error_message}")
        break
    else:
        print(f"Task status: {status.status}")
        time.sleep(2)  # Check every 2 seconds

Node.js / TypeScript 示例

初始化客户端

基础设置

import { SeedanceClient } from 'seedance-sdk';

// Initialize client
const client = new SeedanceClient({
  apiKey: 'your-api-key-here'
});

// Or use environment variable
// const client = new SeedanceClient();

生成图像

Seedream 图像生成

// Generate images using Seedream 4.5
const response = await client.seedream.generate({
  prompt: "A cyberpunk city street with neon signs",
  model: "seedream-4.5",
  resolution: "4k",
  quality: "high",
  numImages: 1
});

// Get results
const imageUrl = response.images[0].url;
console.log(`Generated image: ${imageUrl}`);

生成视频

Seedance 视频生成

// Generate video using Seedance 1.5 Pro
const response = await client.seedance.generate({
  prompt: "A spacecraft entering Earth&apos;s atmosphere",
  model: "seedance-1.5-pro",
  duration: 20,  // seconds
  resolution: "1080p",
  fps: 24
});

// Get task ID
const taskId = response.taskId;
console.log(`Task submitted: ${taskId}`);

异步等待

等待完成

// Use waitForCompletion helper function
const result = await client.task.waitForCompletion(taskId, {
  maxWaitTime: 300000,  // 5 minutes
  pollInterval: 2000    // Check every 2 seconds
});

if (result.status === 'completed') {
  console.log(`Video URL: ${result.videoUrl}`);
} else {
  console.error(`Task failed: ${result.errorMessage}`);
}

REST API 使用

cURL 请求示例

生成图像

POST /v1/seedream/generate

curl -X POST https://api.seedance2api.com/v1/seedream/generate \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A beautiful sunset over the ocean",
    "model": "seedream-4.5",
    "resolution": "4k",
    "quality": "high",
    "num_images": 1
  }' | jq '.images[0].url'

生成视频

POST /v1/seedance/generate

curl -X POST https://api.seedance2api.com/v1/seedance/generate \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A runner jogging through a forest",
    "model": "seedance-1.5-pro",
    "duration": 15,
    "resolution": "1080p",
    "fps": 24
  }' | jq '.task_id'

检查任务状态

GET /v1/tasks/:task_id

curl -X GET https://api.seedance2api.com/v1/tasks/task-123-abc \
  -H "Authorization: Bearer your-api-key" | jq '.'

# Response example:
# {
#   "task_id": "task-123-abc",
#   "status": "processing",
#   "progress": 45,
#   "created_at": "2024-01-15T10:30:00Z",
#   "updated_at": "2024-01-15T10:32:15Z"
# }

获取最终结果

GET /v1/results/:task_id

curl -X GET https://api.seedance2api.com/v1/results/task-123-abc \
  -H "Authorization: Bearer your-api-key" | jq '.'

# Response example:
# {
#   "task_id": "task-123-abc",
#   "status": "completed",
#   "result": {
#     "video_url": "https://cdn.seedance2api.com/videos/...",
#     "duration": 15,
#     "resolution": "1080p"
#   },
#   "completed_at": "2024-01-15T10:35:00Z"
# }

API 参数详解

完整的参数说明和示例

Seedream 图像生成参数

参数名类型必填说明示例
promptstring图像描述文本,最多300字符A sunset over mountains
modelstring模型名称:seedream-3.0, seedream-4.0, seedream-4.5, seedream-5.0seedream-4.5
resolutionstring输出分辨率:1024x1024, 2048x2048, 4k (4096×4096)4k
qualitystring生成质量:standard, highhigh
num_imagesinteger生成图像数量,1-4张1
seedinteger随机种子,用于重现结果42
stylestring艺术风格:oil_painting, watercolor, cyberpunk等oil_painting

Seedance 视频生成参数

参数名类型必填说明示例
promptstring视频描述文本,最多300字符Running through forest
modelstring模型名称:seedance-1.0, seedance-1.5-pro, seedance-2.0seedance-1.5-pro
durationinteger视频时长(秒),5-30秒15
resolutionstring输出分辨率:720p, 1080p, 4k1080p
fpsinteger帧率:24, 30, 6024
image_inputstring参考图片URL(可选),用于图生视频https://...

响应格式示例

标准化的 JSON 响应结构

成功响应

图像生成成功

{
  "status": "success",
  "data": {
    "task_id": "task-uuid-12345",
    "images": [
      {
        "id": "img-uuid-001",
        "url": "https://cdn.seedance2api.com/images/...",
        "width": 2048,
        "height": 2048,
        "format": "png",
        "size_bytes": 4526048
      }
    ],
    "model": "seedream-4.5",
    "resolution": "4k",
    "processing_time_ms": 2500
  }
}

视频生成已接受

{
  "status": "accepted",
  "data": {
    "task_id": "task-uuid-67890",
    "status": "queued",
    "estimated_wait_time_seconds": 45,
    "check_status_url": "/v1/tasks/task-uuid-67890"
  }
}

错误响应

错误请求 (400)

{
  "status": "error",
  "error": {
    "code": "INVALID_PROMPT",
    "message": "Prompt is too long (max 300 characters)",
    "details": {
      "field": "prompt",
      "value": "...",
      "constraint": "max_length",
      "limit": 300
    }
  }
}

未授权 (401)

{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "message": "API key is invalid or expired"
  }
}

错误处理指南

HTTP状态码错误代码说明建议操作
400INVALID_REQUEST请求参数无效或缺失检查请求参数格式和必填项
401UNAUTHORIZEDAPI密钥无效或过期验证API密钥是否正确
403FORBIDDEN无权限访问该资源升级账户或联系支持
429RATE_LIMITED超出速率限制等待后重试,查看速率限制头
500INTERNAL_ERROR服务器内部错误稍后重试或联系技术支持
503SERVICE_UNAVAILABLE服务暂时不可用使用指数退避重试机制

最佳实践

  • 实现指数退避重试策略
  • 设置合理的超时时间(建议5分钟)
  • 视频生成使用轮询或Webhook获取结果
  • 记录所有API错误以便调试
  • 使用Webhook避免频繁轮询

速率限制

不同套餐的请求配额说明

请求限制

免费版10次/小时

适合个人测试和小规模使用

专业版1000次/小时

适合中小型应用和开发团队

企业版无限制

适合大规模生产环境,自定义配额

响应头信息

速率限制响应头

HTTP/1.1 200 OK
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1705315200
X-RateLimit-RetryAfter: 3600

# Explanation:
# X-RateLimit-Limit: Total quota for current period
# X-RateLimit-Remaining: Remaining requests
# X-RateLimit-Reset: Quota reset timestamp
# X-RateLimit-RetryAfter: Recommended retry wait time in seconds

认证方式 - API Key

如何获取API密钥

  1. 1

    注册账户

    访问 seedance2api.com 注册新账户

  2. 2

    验证邮箱

    完成邮箱验证激活账户

  3. 3

    进入控制台

    登录后进入开发者控制台

  4. 4

    生成密钥

    在API密钥页面生成新的密钥

如何使用API密钥

HTTP请求中使用

# Method 1: Using Authorization header
curl -X POST https://api.seedance2api.com/v1/seedream/generate \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "..."}'

# Method 2: Using X-API-Key header
curl -X POST https://api.seedance2api.com/v1/seedream/generate \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "..."}'

安全提示

  • 不要在客户端代码中暴露API密钥
  • 使用环境变量存储密钥
  • 定期轮换密钥
  • 如果密钥泄露,立即删除并重新生成

Webhook 支持

实时通知

配置Webhook接收任务完成通知,无需频繁轮询API。支持自动重试和签名验证。

  • 任务完成自动通知
  • 失败通知
  • 进度更新(可选)
  • 自动重试机制

Webhook事件示例

{
  "event": "task.completed",
  "timestamp": "2024-01-15T10:35:00Z",
  "data": {
    "task_id": "task-uuid-12345",
    "status": "completed",
    "model": "seedance-1.5-pro",
    "result": {
      "video_url": "https://cdn.seedance2api.com/...",
      "duration": 15,
      "resolution": "1080p"
    }
  }
}

如何设置Webhook

  1. 1. 在控制台配置Webhook URL
  2. 2. 选择要接收的事件类型
  3. 3. 验证Webhook签名确保安全
  4. 4. 在请求中添加webhook_url参数

免费额度说明

绑卡即送

首次绑定信用卡即送$1额度

完成账户验证自动获得

首充返赠

首次充值返赠25%额度

首次充值任意金额返赠 25%

30

天试用期

新用户享受30天免费试用

如何开始使用

  1. 1注册账户
  2. 2完成邮箱验证
  3. 3进入 Playground 体验
  4. 4开始创作精彩视频

定价预览

灵活的定价方案,满足从个人开发者到企业的各种需求

按使用量计费

  • Seedream: $0.04/张
  • Seedance: 按需定价
  • 无最低消费
  • 用多少付多少

月度订阅

最受欢迎

  • 专业版: $99/月
  • 企业版: $499/月
  • 包含月度配额
  • 优先技术支持

企业方案

  • 自定义配额
  • 专属技术支持
  • SLA保证
  • 专业集成服务

常见问题

快速找到您需要的答案

准备好开始了吗?

立即注册,获取免费API密钥,开始构建您的AI应用

无需信用卡 · 立即开始 · 30天免费试用