cang-ying/bingshuo-heartbeat/skills/SKILL-002-API调用手册.hdlp

123 lines
3.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# SKILL-002 · API调用手册火山/可灵/万相)
> trigger: 需要调用图片/视频生成API时自动加载
> emergence: 2026-07-15 · D186
> lock: 三个API全部核对通过 · 可直接调用
---
## §0 密钥存储位置
```
API密钥不进仓库存在本地电脑
密钥文件: ~/Documents/guanghulab-local-secrets/shortdrama-api.env
核对报告: ~/Documents/guanghulab-local-secrets/shortdrama-api-report.md
读取方式: source ~/Documents/guanghulab-local-secrets/shortdrama-api.env
然后使用: $VOLCENGINE_API_KEY, $KLING_API_KEY, $WANXIANG_API_KEY
```
## §1 火山方舟(字节跳动)
### 1.1 图片生成
```bash
# 即梦3.01000张额度
curl -s "https://ark.cn-beijing.volces.com/api/v3/images/generations" \
-H "Authorization: Bearer ${VOLCENGINE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"model":"doubao-seedream-4-0-250828","prompt":"描述","size":"1024x1024"}'
# 即梦5.0 Pro高质量
curl -s "https://ark.cn-beijing.volces.com/api/v3/images/generations" \
-H "Authorization: Bearer ${VOLCENGINE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"model":"doubao-seedream-5-0-pro-260628","prompt":"描述","size":"1024x1024"}'
```
### 1.2 视频生成
```bash
# Seedance Mini便宜·主用
curl -s "https://ark.cn-beijing.volces.com/api/v3/contents/generations/tasks" \
-H "Authorization: Bearer ${VOLCENGINE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"model":"doubao-seedance-2-0-mini-260615","content":[{"type":"text","text":"描述"}],"duration":5,"resolution":"720p","aspect_ratio":"16:9"}'
# Seedance Pro大场景/运镜)
curl -s "https://ark.cn-beijing.volces.com/api/v3/contents/generations/tasks" \
-H "Authorization: Bearer ${VOLCENGINE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"model":"doubao-seedance-2-0-260128","content":[{"type":"text","text":"描述"}],"duration":5,"resolution":"720p","aspect_ratio":"16:9"}'
```
### 1.3 查询视频任务状态
```bash
curl -s "https://ark.cn-beijing.volces.com/api/v3/contents/generations/tasks/{TASK_ID}" \
-H "Authorization: Bearer ${VOLCENGINE_API_KEY}"
```
### 1.4 剧本解析/对话
```bash
curl -s "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-2-1-pro-260628","messages":[{"role":"user","content":"问题"}]}'
```
## §2 可灵AI快手
### 2.1 视频生成
```bash
curl -s "https://openapi.klingai.com/v1/videos/text2video" \
-H "Authorization: Bearer ${KLING_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"prompt":"描述","model_name":"kling-v1"}'
```
### 2.2 查询任务状态
```bash
curl -s "https://openapi.klingai.com/v1/videos/text2video/{TASK_ID}" \
-H "Authorization: Bearer ${KLING_API_KEY}"
```
⚠️ 注意可灵API快过期了优先用掉
## §3 万相(阿里百炼)
### 3.1 图片生成
```bash
curl -s "https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis" \
-H "Authorization: Bearer ${WANXIANG_API_KEY}" \
-H "Content-Type: application/json" \
-H "X-DashScope-Async: enable" \
-d '{"model":"wanx2.1-t2i-turbo","input":{"prompt":"描述"},"parameters":{"size":"1024*1024","n":1}}'
```
### 3.2 查询任务状态
```bash
curl -s "https://dashscope.aliyuncs.com/api/v1/tasks/{TASK_ID}" \
-H "Authorization: Bearer ${WANXIANG_API_KEY}"
```
## §4 使用策略
### 4.1 图片生成优先级
```
1. 可灵 kling-v1快过期·先用掉
2. 即梦3.0 seedream-4-01000张额度·主力
3. 万相 wanx2.1-turbo备选
4. 即梦5.0 Pro seedream-5-0-pro高质量备选
```
### 4.2 视频生成优先级
```
1. Seedance Mini 2.0(便宜·主用)
2. Seedance Pro 2.0(大场景/运镜)
3. 可灵 kling-v1备选
```
---
> 本技能包由蛋蛋整理 · 闭着眼睛都能调用
> 下次做短剧直接加载 · 不需要再查API文档