调用火山引擎方舟平台的AI能力。
首先设置环境变量:
bash
export VOLCENGINE_API_KEY="222b33d4-f22f-4f99-b68f-0eb9150ab507"
# 或在 ~/.bashrc 中持久化
echo 'export VOLCENGINE_API_KEY="222b33d4-f22f-4f99-b68f-0eb9150ab507"' >> ~/.bashrc
能力模型ID图片生成doubao-seedream-5-0-lite视频生成doubao-seedance-1-5-pro-251215图片理解doubao-seed-1-8-251228视频理解doubao-seed-1-8-251228
bash
# 调用火山引擎API生成图片
curl -X POST "https://ark.cn-beijing.volces.com/api/v3/visual generation/tasks" \
-H "Authorization: Bearer $VOLCENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-lite",
"prompt": "一只戴墨镜的橘猫",
"size": "1024x1024",
"num": 1
}'
bash
# 提交视频生成任务
curl -X POST "https://ark.cn-beijing.volces.com/api/v3/video generation/tasks" \
-H "Authorization: Bearer $VOLCENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-1-5-pro-251215",
"prompt": "镜头推进,一只橘猫从沙发上跳下来",
"duration": 5,
"ratio": "16:9"
}'
bash
# 图片理解(视觉理解)
curl -X POST "https://ark.cn-beijing.volces.com/api/v3/chat/completions" \
-H "Authorization: Bearer $VOLCENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-1-8-251228",
"messages": [
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}},
{"type": "text", "text": "描述这张图片"}
]
}
]
}'
bash
# 视频理解(使用视频URL)
curl -X POST "https://ark.cn-beijing.volces.com/api/v3/chat/completions" \
-H "Authorization: Bearer $VOLCENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-1-8-251228",
"messages": [
{
"role": "user",
"content": [
{"type": "video_url", "video_url": {"url": "https://example.com/video.mp4"}},
{"type": "text", "text": "描述这个视频"}
]
}
]
}'
对于异步任务(图片/视频生成),需要查询任务状态:
bash
curl -X GET "https://ark.cn-beijing.volces.com/api/v3/visual generation/tasks/{task_id}" \
-H "Authorization: Bearer $VOLCENGINE_API_KEY"
prompt: 描述词size: 尺寸,如 "1024x1024"、"16:9"num: 生成数量prompt: 描述词duration: 时长(秒)ratio: 比例,如 "16:9"、"9:16"