使用 Flux API 生成内容的三个步骤
创建密钥,提交生成任务并获取结果。
Create an API key
Create an API key在 Flux 账户中创建密钥,并将其保存为服务端环境变量 FLUX_API_KEY。
提交生成请求
curl -X POST "https://api.flux-context.org/api/v1/generations" \
-H "Authorization: Bearer $FLUX_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: YOUR_UNIQUE_REQUEST_ID" \
-d '{
"model": "wan3",
"input": {
"mode": "text-to-video",
"prompt": "A calm seaside sunrise with gentle camera movement",
"resolution": "480p",
"duration": 4,
"sound": false,
"aspect_ratio": "16:9"
}
}'{
"id": "REQUEST_ID",
"status": "processing"
}获取结果
使用返回的请求 ID 查询任务。成功后打开结果列表中的链接。
curl "https://api.flux-context.org/api/v1/generations/REQUEST_ID" -H "Authorization: Bearer $FLUX_API_KEY"