快速入门
简单三步即可开始使用 Descrideo API。在 5 分钟内生成您的第一个视频描述。
创建描述任务
提交视频 URL 并指定您的 webhook 端点以接收结果。
curl -X POST https://api.descrideo.com/v1/video-descriptions \
-H "X-API-Key: nxt_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "direct_url",
"url": "https://example.com/video.mp4"
},
"frames": 20,
"generation_mode": "vision",
"webhook": {
"url": "https://your-app.com/webhooks/video"
},
"client_context": {
"lang": "en",
"output_fields": ["title", "description", "tags"]
}
}'
通过 webhook 接收结果
一旦处理完成,我们将结果通过具有 HMAC 签名的 POST 请求发送到您的 webhook URL。
{
"job_id": "01HXYZ123ABC",
"status": "succeeded",
"result": {
"title": "Mountain Hiking Adventure in Swiss Alps",
"description": "A breathtaking journey through...",
"tags": ["hiking", "mountains", "switzerland", "nature"]
},
"billing": {
"token_cost": 1.23,
"base_cost": 1.0,
"transcription_cost": 0.23,
"franchise_cost": 0.0
},
"meta": {
"generation_mode": "vision_audio",
"transcription": {
"enabled": true,
"status": "completed",
"seconds": 45.5
}
},
"timing_ms": {
"probe": 500,
"audio": 3200,
"frames": 2100,
"ai": 8100,
"webhook": 120
}
}
身份验证
所有的 API 请求都需要通过 Authorization 头中的 Bearer 令牌进行身份验证。
Authorization: Bearer nxt_your_api_key_here
安全提示: 绝不要在客户端代码中暴露您的 API 密钥。始终从您的后端服务器进行 API 调用。
沙盒测试
使用我们的沙盒环境免费测试您的 webhook 集成。沙盒任务模拟完整的工作流而无需实际进行视频处理。
沙盒的优势
- 免费的每日配额 - 无需代币
- 具备 HMAC 签名的真实 Webhook 推送
- 不需要提供真实的视频 URL
- 支持重放 Webhook 以进行调试
POST /v1/sandbox/video-descriptions
{
"frames": 10,
"webhook": {
"url": "https://your-app.com/webhooks/video"
},
"client_context": {
"lang": "en",
"output_fields": ["title", "description", "tags"],
"custom_instructions": "Focus on technical details"
}
}
演示 API (网关)
上线前使用演示 API 结合真实的异步工作流和 webhook 交付进行集成。用来验证您的视频直连 URL 和 webhook 接收器。
限制: 每个演示 API 密钥每天 1 个任务,仅限 frames=10,仅限 lang=en(其他语言将返回 422 错误)。允许自定义指令。
端点
POST /api/demo/v1/video-descriptions— 创建演示任务(仅直连 URL)GET /api/demo/v1/video-descriptions/{job_id}— 获取状态/结果POST /api/demo/v1/video-descriptions/{job_id}/replay-webhook— 重新发送 webhook 到您的接收器GET /api/demo/v1/webhook-secret— 获取用于签名验证的 webhook 密钥
创建演示任务(示例)
curl -X POST https://your-portal.com/api/demo/v1/video-descriptions \
-H "X-API-Key: demo_your_demo_api_key" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "direct_url",
"url": "https://example.com/video.mp4"
},
"frames": 10,
"webhook": {
"url": "https://your-app.com/webhooks/demo"
},
"client_context": {
"lang": "en",
"output_fields": ["title", "description", "tags"],
"custom_instructions": "Make the description more detailed"
}
}'
Webhook 签名
演示 API 使用与主 API 相同的签名头向您的 URL 转发 webhooks:X-Nxt-Timestamp 和 X-Nxt-Signature。使用 GET /api/demo/v1/webhook-secret 来检索用于验证的密钥。
创建描述任务
/v1/video-descriptions
请求体
| Parameter | Type | Required | Description |
|---|---|---|---|
source |
object | Yes | 视频来源配置 |
type |
string | * | direct_url 或 source_provider |
url |
string | * | 视频文件的直接 URL(当 type=direct_url 时) |
provider |
object | * | 来源提供者端点配置(当 type=source_provider 时) |
webhook.url |
string | Yes | 用于接收结果的 URL |
client_context.output_fields |
array | No | 要生成的字段:标题,描述,标签 |
client_context.lang |
string | No | 输出语言 (ISO 639-1),默认:en |
frames |
integer | Yes | 要提取的帧数:10,20,或 30。在 vision 和 vision_audio 模式中必需。在 audio 模式中不使用。 |
generation_mode |
string | No | vision (默认), vision_audio, 或 audio。决定分析模式。 |
transcription |
object | No | 音频转录设置。具体必填字段取决于 generation_mode。 |
enabled |
boolean | * | 启用音频转录。对于 vision_audio/audio 模式会自动启用。 |
segments |
integer | * | 采样的音频片段数:10,20,或 30 |
segment_sec |
number | * | 每个片段的持续时长(秒)(5–60) |
client_context.custom_instructions |
string | No | 有关输出样式的自定义 AI 指令 |
响应
返回 202 Accepted 以及任务 ID。
{
"job_id": "01HXYZ123ABC",
"status": "queued"
}
获取任务状态
/v1/video-descriptions/{job_id}
轮询任务状态。当 webhooks 不方便时,可用于监控处理进度。
任务状态
queued
任务正在排队等待处理
resolving_source
解析视频访问
probing
正在分析视频元数据
extracting_audio
正在提取音频片段
transcribing_audio
正在把音频转录为文本
extracting_frames
正在提取视频帧
ai_request
AI正在生成描述
succeeded
处理完成
failed
处理失败
Webhook 安全
所有 webhook 都使用 HMAC-SHA256 进行签名。验证签名可以确保真实性。
签名标头
X-Nxt-Timestamp: 1707400000
X-Nxt-Signature: sha256=abc123def456...
验证示例(Python)
import hmac
import hashlib
def verify_webhook(raw_body: bytes, timestamp: str, signature_header: str, secret: str) -> bool:
# Signature header format: "sha256="
expected_sig = signature_header.removeprefix("sha256=")
message = raw_body + timestamp.encode()
computed = hmac.new(secret.encode(), message, hashlib.sha256).hexdigest()
return hmac.compare_digest(computed, expected_sig)
提示: 从 GET /v1/webhook-secret 获取您的 webhook 密钥
来源提供者模式
对于私人视频,请使用来源提供者 (Source Provider) 模式。当我们的 API 需要获取视频时,您的端点将作为访问代理,返回预签名 URL。
工作流
-
1
您在任务提交时附带
source.provider配置 - 2 我们的 API 使用带签名的请求调用您的端点
- 3 您验证签名并返回预签名的 URL
- 4 我们的 API 根据预签名 URL 提取视频
安全提示: 您的视频将保持私密。我们只通过您控制的临时预签名 URL 对其进行访问。
错误处理
API 返回标准 HTTP 状态码及详细错误信息。
| Status | Meaning |
|---|---|
400 |
请求错误 - 参数无效 |
401 |
未授权 - API 密钥无效 |
402 |
需要付款 - 余额不足 |
404 |
未找到 - 请求资源不存在 |
429 |
速率受限 - 请求过多 |
500 |
内部错误 - 服务器问题 |
计费与代币
每个成功任务的基础消耗是 1 代币。音频转录是一项附加服务,每采集10秒的音频片段计费一次。最后费用将在 webhook billing.token_cost 字段进行汇报。
预付模式
预先购买代币包。代币会在创建任务时被冻结,并在处理成功后扣除。
后付模式
在账单周期结束后付款。可设置可选月度上限以控制开销。