新增媒体生成市场技能

This commit is contained in:
2026-04-27 12:15:54 +08:00
parent 2662fd55fc
commit 2923f87fa1
9 changed files with 1042 additions and 2 deletions

View File

@@ -0,0 +1,208 @@
---
name: 可灵文生视频
description: >-
Use this skill when the user wants to generate videos from text descriptions
or images. Calls the Kling AI video generation API through the media proxy.
Supports text-to-video and image-to-video modes. The API is asynchronous —
submit a task, then poll for completion.
Use when 用户提到 生成视频、文生视频、AI 视频、创建视频、视频生成、
动画生成、可灵、Kling、把图片变成视频、图生视频。
license: Complete terms in LICENSE.txt
version: 1.1.0
type: procedural
risk_level: low
status: enabled
disable-model-invocation: false
provider: kling
tags:
- media
- video
- generation
- kling
requires:
tools:
- Bash
metadata:
author: desirecore
updated_at: '2026-04-25'
market:
icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3"
stroke="#AF52DE" stroke-width="1.5" fill="#AF52DE"
fill-opacity="0.1"/><polygon points="10,7 18,12 10,17" fill="#AF52DE"
fill-opacity="0.6" stroke="#AF52DE" stroke-width="1.2"
stroke-linejoin="round"/></svg>
short_desc: 基于快手可灵 AI 的文本/图片生成视频技能
category: media
maintainer:
name: DesireCore Official
verified: true
channel: latest
---
# kling-video-gen 技能
## 强制规则(违反将导致功能失败)
1. **必须用 HTTPS 访问 agent-service**`https://127.0.0.1:${PORT}``-k` 跳过证书验证
2. **全程使用 Bash curl** — 不要使用 HttpRequest 工具或 Python
3. **轮询间隔 10-15 秒** — 使用 `sleep 10` 等待
## 完整执行流程
### 前置条件
- 用户已在资源管理器-算力中配置可灵 Provider 并填写 API Key
- agent-service 正在运行
### 核心概念:异步任务模式
可灵 API 采用异步任务模式,分两步完成:
1. **提交任务**POST 请求创建视频生成任务,返回 `task_id`
2. **轮询结果**:用 `task_id` 查询任务状态,直到 `task_status``succeed``failed`
### 模型选择
| 模型 | 适用场景 | 特点 |
|------|---------|------|
| kling-v2-5-turbo | 快速生成(推荐默认) | 高性价比720p/1080p |
| kling-v2-5-turbo-pro | 高品质生成 | 1080p/4K |
| kling-v2 | 旗舰文生视频 | 高质量 |
| kling-v2-master | 最高品质 | 1080p/4K耗时较长 |
### 第一步:提交视频生成任务(文生视频)
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"provider": "kling",
"serviceType": "video_gen",
"endpoint": "/videos/text2video",
"body": {
"model_name": "kling-v2-5-turbo",
"prompt": "用户描述的视频内容",
"negative_prompt": "",
"cfg_scale": 0.5,
"mode": "std",
"duration": "5",
"aspect_ratio": "16:9"
},
"responseType": "json"
}'
```
从 JSON 响应中提取 `data.data.task_id`
### 第一步(备选):图生视频
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"provider": "kling",
"serviceType": "video_gen",
"endpoint": "/videos/image2video",
"body": {
"model_name": "kling-v2-5-turbo",
"image": "图片URL或base64",
"prompt": "可选的运动描述",
"cfg_scale": 0.5,
"mode": "std",
"duration": "5"
},
"responseType": "json"
}'
```
### 第二步:轮询任务状态
每隔 10-15 秒调用一次,直到 `task_status``succeed``failed`。将 `TASK_ID` 替换为第一步返回的 `task_id`。图生视频查询路径改为 `/videos/image2video/TASK_ID`
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
TASK_ID="第一步返回的task_id"
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d "{
\"provider\": \"kling\",
\"serviceType\": \"video_gen\",
\"endpoint\": \"/videos/text2video/${TASK_ID}\",
\"method\": \"GET\",
\"responseType\": \"json\"
}"
```
轮询响应示例(进行中):
```json
{
"success": true,
"data": {
"code": 0,
"data": {
"task_id": "task_xxx",
"task_status": "processing",
"task_status_msg": "Generating video..."
}
}
}
```
完成响应示例:
```json
{
"success": true,
"data": {
"code": 0,
"data": {
"task_id": "task_xxx",
"task_status": "succeed",
"task_result": {
"videos": [
{
"id": "video_xxx",
"url": "https://...",
"duration": "5.0"
}
]
}
}
}
}
```
### 第三步:展示结果
任务完成后从 `data.data.task_result.videos[0].url` 获取视频 URL直接展示给用户。
### 参数说明
| 参数 | 说明 | 可选值 |
|------|------|--------|
| model_name | 模型名称 | kling-v2-5-turbo默认, kling-v2-5-turbo-pro, kling-v2, kling-v2-master |
| prompt | 视频描述 | 文本字符串 |
| negative_prompt | 不希望出现的内容 | 文本字符串(可选) |
| cfg_scale | 创意自由度 | 0-1默认 0.5 |
| mode | 生成模式 | "std"(标准), "pro"(高品质) |
| duration | 视频时长(秒) | "5" 或 "10" |
| aspect_ratio | 画面比例 | "16:9", "9:16", "1:1" |
### 错误处理
- `task_status: "failed"`:生成失败,向用户说明(可能是内容政策或参数错误)
- `success: false` + `error: "未找到匹配的供应商"`:用户未配置可灵 Provider
- `success: false` + `error: "未配置 API Key"`:用户未填写可灵 API Key
- 连续轮询超过 5 分钟未完成:告知用户任务可能超时,建议重试
### 注意事项
- 可灵视频生成是异步的,通常需要 1-5 分钟
- 轮询间隔建议 10-15 秒,不要太频繁
- 生成的视频 URL 有时效限制,建议及时保存
- 如果用户未明确要求,默认使用 `kling-v2-5-turbo` + `std` + `5秒` + `16:9`

View File

@@ -0,0 +1,126 @@
---
name: MiniMax 文生图
description: >-
Use this skill when the user wants to generate images using MiniMax's
image-01 model. Supports text-to-image and subject reference for character
consistency. Use when 用户提到 生成图片、画图、文生图、创建图片、
AI 绘画、生成插图、画一张、帮我画、设计图片、MiniMax 画图。
license: Complete terms in LICENSE.txt
version: 1.3.0
type: procedural
risk_level: low
status: enabled
disable-model-invocation: false
provider: minimax
tags:
- media
- image
- generation
- minimax
requires:
tools:
- Bash
metadata:
author: desirecore
updated_at: '2026-04-25'
market:
icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3"
stroke="#34C759" stroke-width="1.5" fill="#34C759"
fill-opacity="0.1"/><circle cx="8.5" cy="8.5" r="2" stroke="#34C759"
stroke-width="1.2"/><path d="M3 16l5-5 4 4 3-3 6 6" stroke="#34C759"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/></svg>
short_desc: 基于 MiniMax image-01 的文本生成图片技能
category: media
maintainer:
name: DesireCore Official
verified: true
channel: latest
listed: false
---
# minimax-image-gen 技能
## 强制规则(违反将导致功能失败)
1. **必须使用 `"response_format": "url"`** — 禁止 `"base64"`base64 会导致输出截断
2. **必须用 HTTPS 访问 agent-service**`https://127.0.0.1:${PORT}``-k` 跳过证书验证
3. **必须通过 `/api/media/upload` 上传到 media-store** — 禁止保存到本地路径
4. **必须使用 `dc-media://` 协议展示图片** — 唯一能让前端正确渲染的方式
5. **全程使用 Bash curl** — 不要使用 HttpRequest 工具或 Python
## 完整执行流程(严格按此三步执行)
### 第一步:调用 API 生成图片
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"providerId": "provider-minimax-media-001",
"endpoint": "/image_generation",
"body": {
"model": "image-01",
"prompt": "这里替换为英文图片描述",
"aspect_ratio": "1:1",
"response_format": "url",
"n": 1
},
"responseType": "json"
}'
```
从 JSON 响应中提取 `data.data.image_urls[0]` 得到图片 URL。
### 第二步:下载并上传到 media-store
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
IMAGE_URL="第一步拿到的图片URL"
curl -sL "$IMAGE_URL" -o /tmp/minimax-gen.png && \
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \
-F "file=@/tmp/minimax-gen.png;type=image/png"
```
从 JSON 响应中提取 `mediaId` 字段(格式如 `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png`)。
### 第三步:用 dc-media 协议展示图片
在你的回复文本中直接写 Markdown 图片语法:
```
![图片描述](dc-media://这里替换为mediaId)
```
例如:`![白色的猫坐在书桌上](dc-media://a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6.png)`
前端会自动将 `dc-media://` 转为可访问的图片 URL 并渲染出来。
## 参数映射
| 用户意图 | aspect_ratio |
|---------|-------------|
| 正方形/头像 | "1:1" |
| 横版/风景/壁纸 | "16:9" |
| 竖版/手机/海报 | "9:16" |
| 标准照片 | "4:3" |
| 竖版照片 | "3:4" |
## 主体参考(角色一致性)
在 body 中添加 `subject_reference`
```json
"subject_reference": [
{ "type": "character", "image_file": { "url": "参考图片URL" } }
]
```
## 错误处理
- `"error": "未找到匹配的供应商"`:未配置 MiniMax Media Provider
- `statusCode: 401`API Key 无效
- `statusCode: 429`:频率限制,稍后重试

206
skills/minimax-tts/SKILL.md Normal file
View File

@@ -0,0 +1,206 @@
---
name: MiniMax 语音合成
description: >-
Use this skill when the user wants to convert text to speech using MiniMax's
T2A (Text-to-Audio) API. Supports multiple voice styles, emotional control,
and voice cloning. Use when 用户提到 语音合成、文字转语音、TTS、朗读、
读出来、生成语音、生成音频、文本转音频、配音、念出来、MiniMax 语音。
license: Complete terms in LICENSE.txt
version: 1.2.0
type: procedural
risk_level: low
status: enabled
disable-model-invocation: false
provider: minimax
tags:
- media
- audio
- tts
- speech
- minimax
requires:
tools:
- Bash
metadata:
author: desirecore
updated_at: '2026-04-25'
market:
icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3"
stroke="#007AFF" stroke-width="1.5" fill="#007AFF"
fill-opacity="0.1"/><path d="M8 9v6M11 7v10M14 10v4M17 8v8"
stroke="#007AFF" stroke-width="2"
stroke-linecap="round"/></svg>
short_desc: 基于 MiniMax Speech-02 的文本转语音技能
category: media
maintainer:
name: DesireCore Official
verified: true
channel: latest
listed: false
---
# minimax-tts 技能
## 强制规则(违反将导致功能失败)
1. **必须用 HTTPS 访问 agent-service**`https://127.0.0.1:${PORT}``-k` 跳过证书验证
2. **全程使用 Bash curl** — 不要使用 HttpRequest 工具或 Python
## 完整执行流程
### 前置条件
- 用户已在资源管理器-算力中配置 MiniMax Media Provider 并填写 API Key
- agent-service 正在运行
### 语音选择指南
| voice_id | 特点 | 适用场景 |
|----------|------|---------|
| male-qn-qingse | 青涩男声 | 旁白、播客 |
| female-shaonv | 少女女声 | 有声书、对话 |
| female-yujie | 御姐女声 | 专业播报 |
| presenter_male | 主持人男声 | 新闻、正式场合 |
| presenter_female | 主持人女声 | 新闻、正式场合 |
### 生成语音
MiniMax TTS 返回 JSON包含音频 URL 或 hex 数据),`responseType` 使用 `"json"`
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"providerId": "provider-minimax-media-001",
"endpoint": "/t2a_v2",
"body": {
"model": "speech-02-hd",
"text": "要转换为语音的文本内容",
"voice_setting": {
"voice_id": "male-qn-qingse",
"speed": 1.0,
"vol": 1.0,
"pitch": 0
},
"audio_setting": {
"format": "mp3",
"sample_rate": 32000
}
},
"responseType": "json"
}'
```
### 响应处理
MiniMax TTS 返回 JSON根据请求参数可能返回 URL 或 hex 格式:
**URL 格式响应**(推荐,需在 audio_setting 中设置 `"format": "url"`
```json
{
"success": true,
"data": {
"data": {
"audio": {
"audio_url": "https://...",
"status": 1
}
},
"base_resp": { "status_code": 0, "status_msg": "success" }
},
"statusCode": 200
}
```
**Hex 格式响应**(默认):
```json
{
"success": true,
"data": {
"data": {
"audio": {
"data": "hex编码的音频数据...",
"status": 1
}
},
"extra_info": {
"audio_length": 12345,
"audio_sample_rate": 32000,
"audio_size": 67890
}
},
"statusCode": 200
}
```
### 下载并上传到 media-store
音频 URL 有时效限制,必须立即下载并保存到本地 media-store。
**URL 格式**
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
AUDIO_URL="响应中的audio_url"
curl -sL "$AUDIO_URL" -o /tmp/minimax-tts.mp3 && \
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \
-F "file=@/tmp/minimax-tts.mp3;type=audio/mpeg"
```
**Hex 格式**
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
HEX_DATA="响应中的hex数据"
echo -n "$HEX_DATA" | xxd -r -p > /tmp/minimax-tts.mp3 && \
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \
-F "file=@/tmp/minimax-tts.mp3;type=audio/mpeg"
```
从 JSON 响应中提取 `mediaId` 字段。
### 展示结果
在回复中使用 dc-media 协议引用(前端会自动识别音频扩展名并渲染播放器):
```
![语音合成结果](dc-media://这里替换为mediaId)
```
```
### 参数说明
| 参数 | 说明 | 默认值 |
|------|------|--------|
| model | 模型 | "speech-02-hd"(高清)或 "speech-02-turbo"(快速) |
| text | 要转换的文本 | 最大 10000 字符 |
| voice_setting.voice_id | 语音角色 | "male-qn-qingse" |
| voice_setting.speed | 语速 | 1.0 |
| voice_setting.vol | 音量 | 1.0 |
| voice_setting.pitch | 音调 | 0 |
| audio_setting.format | 音频格式 | "mp3" |
| audio_setting.sample_rate | 采样率 | 32000 |
### 特殊语法
MiniMax TTS 支持在文本中插入停顿标记:
- `<#0.5#>` — 停顿 0.5 秒
- `<#2#>` — 停顿 2 秒
- 有效范围0.01 ~ 99.99 秒
示例:`"你好<#1#>欢迎来到 DesireCore"`
### 错误处理
- `success: false` + `statusCode: 400`:文本为空或参数格式错误
- `success: false` + `statusCode: 401`API Key 无效
- `success: false` + `statusCode: 429`:频率限制
- `success: false` + `error: "未找到匹配的供应商"`:未配置 MiniMax Media Provider
### 注意事项
- 文本超过 3000 字符时建议使用流式输出(但代理模式暂不支持流式)
- 返回的 audio_url 有 24 小时时效
- 如果用户未明确要求,默认使用 `speech-02-hd` + `male-qn-qingse` + 1.0 倍速
- 长文本建议分段调用,每段不超过 3000 字符

View File

@@ -0,0 +1,217 @@
---
name: MiniMax 文生视频
description: >-
Use this skill when the user wants to generate videos using MiniMax's
Hailuo model. Supports text-to-video, image-to-video, and subject reference.
The API is asynchronous — submit a task, poll for status, then download.
Use when 用户提到 生成视频、文生视频、AI 视频、创建视频、视频生成、
动画生成、MiniMax 视频、海螺、Hailuo、图片变视频、图生视频。
license: Complete terms in LICENSE.txt
version: 1.2.0
type: procedural
risk_level: low
status: enabled
disable-model-invocation: false
provider: minimax
tags:
- media
- video
- generation
- minimax
- hailuo
requires:
tools:
- Bash
metadata:
author: desirecore
updated_at: '2026-04-25'
market:
icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3"
stroke="#AF52DE" stroke-width="1.5" fill="#AF52DE"
fill-opacity="0.1"/><polygon points="10,7 18,12 10,17" fill="#AF52DE"
fill-opacity="0.6" stroke="#AF52DE" stroke-width="1.2"
stroke-linejoin="round"/></svg>
short_desc: 基于 MiniMax Hailuo 的文本/图片生成视频技能
category: media
maintainer:
name: DesireCore Official
verified: true
channel: latest
listed: false
---
# minimax-video-gen 技能
## 强制规则(违反将导致功能失败)
1. **必须用 HTTPS 访问 agent-service**`https://127.0.0.1:${PORT}``-k` 跳过证书验证
2. **全程使用 Bash curl** — 不要使用 HttpRequest 工具或 Python
3. **轮询间隔 10 秒** — 使用 `sleep 10` 等待
## 完整执行流程
### 前置条件
- 用户已在资源管理器-算力中配置 MiniMax Media Provider 并填写 API Key
- agent-service 正在运行
### 核心概念:三步异步流程
MiniMax 视频生成采用异步任务模式:
1. **提交任务**POST 创建视频生成任务,返回 `task_id`
2. **轮询状态**:用 `task_id` 查询任务状态,直到 `status``"Success"``"Fail"`
3. **下载视频**:用 `file_id` 获取下载 URL
### 模型选择与降级策略
| 模型 | 支持模式 | 特点 | 适用场景 |
|------|---------|------|---------|
| MiniMax-Hailuo-2.3 | 文生视频 + 图生视频 | 最高画质,默认首选 | 用户未指定时的默认选择 |
| MiniMax-Hailuo-2.3-fast | **仅图生视频** | 速度快,成本低 50% | 图生视频场景下额度不足时降级 |
**降级规则(强制)**
1. 默认使用 `MiniMax-Hailuo-2.3`
2. **文生视频T2V额度不足时**`MiniMax-Hailuo-2.3-fast` 不支持文生视频,无法降级。应直接告知用户额度不足,建议等待额度重置或切换到其他视频生成服务(如可灵)
3. **图生视频I2V额度不足时**:可降级到 `MiniMax-Hailuo-2.3-fast`,告知用户"已切换到快速模型生成"
4. 如果用户做图生视频且明确要求快速生成,直接使用 `MiniMax-Hailuo-2.3-fast`
### 第一步:提交文生视频任务
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"providerId": "provider-minimax-media-001",
"endpoint": "/video_generation",
"body": {
"model": "MiniMax-Hailuo-2.3",
"prompt": "用户描述的视频内容"
},
"responseType": "json"
}'
```
可选参数(加入 body 中):
- `"duration"`: 视频时长秒数6 或 10
- `"resolution"`: `"768P"``"1080P"`
从 JSON 响应中提取 `data.task_id`
### 第一步(备选):图生视频
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"providerId": "provider-minimax-media-001",
"endpoint": "/video_generation",
"body": {
"model": "MiniMax-Hailuo-2.3",
"prompt": "描述图片中场景的动态变化",
"first_frame_image": "https://图片URL"
},
"responseType": "json"
}'
```
### 第二步:轮询任务状态
每隔 10 秒调用一次,直到 `status``"Success"``"Fail"`。将 `TASK_ID` 替换为第一步返回的 `task_id`
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
TASK_ID="第一步返回的task_id"
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d "{
\"providerId\": \"provider-minimax-media-001\",
\"endpoint\": \"/query/video_generation?task_id=${TASK_ID}\",
\"method\": \"GET\",
\"responseType\": \"json\"
}"
```
轮询响应(进行中):
```json
{
"success": true,
"data": {
"task_id": "task_xxx",
"status": "Processing",
"file_id": ""
}
}
```
轮询响应(完成):
```json
{
"success": true,
"data": {
"task_id": "task_xxx",
"status": "Success",
"file_id": "file_xxx"
}
}
```
### 第三步:获取视频下载链接
`FILE_ID` 替换为第二步完成响应中的 `file_id`
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
FILE_ID="第二步返回的file_id"
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d "{
\"providerId\": \"provider-minimax-media-001\",
\"endpoint\": \"/files/retrieve?file_id=${FILE_ID}\",
\"method\": \"GET\",
\"responseType\": \"json\"
}"
```
从响应中提取 `data.file.download_url`
### 第四步:下载并上传到 media-store
下载 URL 有 24 小时时效,必须立即下载并保存到本地 media-store。
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
VIDEO_URL="第三步获取的download_url"
curl -sL "$VIDEO_URL" -o /tmp/minimax-video.mp4 && \
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \
-F "file=@/tmp/minimax-video.mp4;type=video/mp4"
```
从 JSON 响应中提取 `mediaId` 字段。
### 第五步:用 dc-media 协议展示视频
在你的回复文本中直接写 Markdown 图片语法(前端会自动识别视频扩展名并渲染播放器):
```
![视频描述](dc-media://这里替换为mediaId)
```
### 错误处理
- `status: "Fail"`:视频生成失败,向用户说明
- `success: false` + `error: "未找到匹配的供应商"`:未配置 MiniMax Media Provider
- `success: false` + `error: "未配置 API Key"`:未填写 API Key
- **额度不足**`statusCode: 429``insufficient_quota``balance` 相关错误文生视频无法降级Fast 模型不支持 T2V告知用户额度不足图生视频可换用 `MiniMax-Hailuo-2.3-fast` 从第一步重试
- 轮询超过 10 分钟未完成:告知用户任务可能超时
### 注意事项
- MiniMax 视频生成是异步的,通常需要 2-10 分钟
- 轮询间隔建议 10 秒
- 下载 URL 有 24 小时时效
- 如果用户未明确要求,默认不传 duration 和 resolution使用 API 默认值)

View File

@@ -0,0 +1,120 @@
---
name: OpenAI 文生图
description: >-
Use this skill when the user wants to generate images from text descriptions.
Calls the OpenAI DALL-E 3 API through the media proxy to create images.
Supports different sizes (1024x1024, 1792x1024, 1024x1792) and styles
(natural, vivid). Use when 用户提到 生成图片、画图、文生图、创建图片、
AI 绘画、生成插图、画一张、帮我画、设计图片、DALL-E。
license: Complete terms in LICENSE.txt
version: 1.3.0
type: procedural
risk_level: low
status: enabled
disable-model-invocation: false
provider: openai
tags:
- media
- image
- generation
- dall-e
- openai
requires:
tools:
- Bash
metadata:
author: desirecore
updated_at: '2026-04-25'
market:
icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3"
stroke="#34C759" stroke-width="1.5" fill="#34C759"
fill-opacity="0.1"/><circle cx="8.5" cy="8.5" r="2" stroke="#34C759"
stroke-width="1.2"/><path d="M3 16l5-5 4 4 3-3 6 6" stroke="#34C759"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/></svg>
short_desc: 基于 OpenAI DALL-E 3 的文本生成图片技能
category: media
maintainer:
name: DesireCore Official
verified: true
channel: latest
---
# openai-image-gen 技能
## 强制规则(违反将导致功能失败)
1. **必须使用 `"response_format": "url"`** — 禁止 `"b64_json"`base64 会导致输出截断
2. **必须用 HTTPS 访问 agent-service**`https://127.0.0.1:${PORT}``-k` 跳过证书验证
3. **必须通过 `/api/media/upload` 上传到 media-store** — 禁止保存到本地路径
4. **必须使用 `dc-media://` 协议展示图片** — 唯一能让前端正确渲染的方式
5. **全程使用 Bash curl** — 不要使用 HttpRequest 工具或 Python
## 完整执行流程(严格按此三步执行)
### 第一步:调用 API 生成图片
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"serviceType": "image_gen",
"endpoint": "/images/generations",
"body": {
"model": "dall-e-3",
"prompt": "这里替换为图片描述",
"n": 1,
"size": "1024x1024",
"style": "vivid",
"quality": "standard",
"response_format": "url"
},
"responseType": "json"
}'
```
从 JSON 响应中提取 `data.data[0].url` 得到图片 URL。`data.data[0].revised_prompt` 是 DALL-E 优化后的提示词,可展示给用户。
### 第二步:下载并上传到 media-store
OpenAI URL 仅 1 小时有效,必须立即下载。
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
IMAGE_URL="第一步拿到的图片URL"
curl -sL "$IMAGE_URL" -o /tmp/dalle-gen.png && \
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \
-F "file=@/tmp/dalle-gen.png;type=image/png"
```
从 JSON 响应中提取 `mediaId` 字段。
### 第三步:用 dc-media 协议展示图片
在你的回复文本中直接写 Markdown 图片语法:
```
![图片描述](dc-media://这里替换为mediaId)
```
前端会自动将 `dc-media://` 转为可访问的图片 URL 并渲染。
## 参数映射
| 用户意图 | size | style | quality |
|---------|------|-------|---------|
| 正方形(默认) | "1024x1024" | "vivid" | "standard" |
| 横版/风景 | "1792x1024" | "vivid" | "standard" |
| 竖版/手机 | "1024x1792" | "vivid" | "standard" |
| 写实/自然 | — | "natural" | — |
| 高清 | — | — | "hd" |
## 错误处理
- `"error": "未找到匹配的供应商"`:未配置 OpenAI Provider
- `statusCode: 401`API Key 无效或过期
- `statusCode: 429`:速率限制,稍后重试

154
skills/openai-tts/SKILL.md Normal file
View File

@@ -0,0 +1,154 @@
---
name: OpenAI 语音合成
description: >-
Use this skill when the user wants to convert text to speech audio.
Calls the OpenAI TTS API through the media proxy to generate audio files.
Supports multiple voices (alloy, echo, fable, onyx, nova, shimmer) and
audio formats (mp3, opus, aac, flac).
Use when 用户提到 语音合成、文字转语音、TTS、朗读、读出来、
生成语音、生成音频、文本转音频、配音、念出来。
license: Complete terms in LICENSE.txt
version: 1.1.0
type: procedural
risk_level: low
status: enabled
disable-model-invocation: false
provider: openai
tags:
- media
- audio
- tts
- speech
- openai
requires:
tools:
- Bash
metadata:
author: desirecore
updated_at: '2026-04-25'
market:
icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3"
stroke="#007AFF" stroke-width="1.5" fill="#007AFF"
fill-opacity="0.1"/><path d="M8 9v6M11 7v10M14 10v4M17 8v8"
stroke="#007AFF" stroke-width="2"
stroke-linecap="round"/></svg>
short_desc: 基于 OpenAI TTS 的文本转语音技能
category: media
maintainer:
name: DesireCore Official
verified: true
channel: latest
---
# openai-tts 技能
## 强制规则(违反将导致功能失败)
1. **必须用 HTTPS 访问 agent-service**`https://127.0.0.1:${PORT}``-k` 跳过证书验证
2. **全程使用 Bash curl** — 不要使用 HttpRequest 工具或 Python
3. **`responseType` 必须为 `"binary"`** — OpenAI TTS 返回二进制音频流,不是 JSON
## 完整执行流程
### 前置条件
- 用户已在资源管理器-算力中配置 OpenAI Provider 并填写 API Key
- agent-service 正在运行
### 语音选择指南
| 语音 | 特点 | 适用场景 |
|------|------|---------|
| alloy | 中性平衡 | 通用(推荐默认) |
| echo | 低沉稳重 | 旁白、播客 |
| fable | 温暖叙事 | 故事、有声书 |
| onyx | 深沉有力 | 新闻播报 |
| nova | 活泼明亮 | 对话、教学 |
| shimmer | 柔和温柔 | 冥想、助眠 |
### 生成语音
```bash
PORT=$(cat ~/.desirecore/agent-service.port)
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"serviceType": "tts",
"endpoint": "/audio/speech",
"body": {
"model": "tts-1",
"input": "要转换的文本内容",
"voice": "alloy",
"response_format": "mp3",
"speed": 1.0
},
"responseType": "binary",
"binaryMimeType": "audio/mpeg"
}'
```
成功响应(代理层自动保存音频文件到 media-store
```json
{
"success": true,
"media": {
"type": "audio",
"mediaId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mp3",
"name": "media-proxy-generated",
"mimeType": "audio/mpeg",
"size": 123456
},
"statusCode": 200
}
```
### 展示结果
从响应中提取 `media.mediaId`,音频文件可通过以下 URL 访问:
```
https://127.0.0.1:${PORT}/api/media/${mediaId}
```
向用户提供播放链接即可。
### 参数说明
| 参数 | 说明 | 可选值 | 默认值 |
|------|------|--------|--------|
| model | 模型 | "tts-1"(标准), "tts-1-hd"(高清) | tts-1 |
| input | 要转换的文本 | 最大 4096 字符 | — |
| voice | 语音角色 | alloy, echo, fable, onyx, nova, shimmer | alloy |
| response_format | 音频格式 | mp3, opus, aac, flac | mp3 |
| speed | 语速倍率 | 0.25 - 4.0 | 1.0 |
### binaryMimeType 映射
根据 `response_format` 设置对应的 `binaryMimeType`
| response_format | binaryMimeType |
|----------------|----------------|
| mp3 | audio/mpeg |
| opus | audio/opus |
| aac | audio/aac |
| flac | audio/flac |
### 错误处理
- `success: false` + `statusCode: 400`:通常是 input 为空或超长
- `success: false` + `statusCode: 401`API Key 无效或过期
- `success: false` + `statusCode: 429`:速率限制,建议稍后重试
- `success: false` + `error: "未找到匹配的供应商"`:用户未配置 OpenAI Provider
- `success: false` + `error: "未配置 API Key"`:用户未填写 OpenAI API Key
### 注意事项
- OpenAI TTS API 返回的是二进制音频流,不是 JSON所以 `responseType` 必须设为 `"binary"`
- `binaryMimeType` 必须与 `response_format` 对应,否则文件扩展名可能不正确
- `tts-1-hd` 音质更好但生成速度较慢,适合离线场景
- input 最大 4096 字符,超长文本需要分段处理
- 如果用户未明确要求,默认使用 `tts-1` + `alloy` + `mp3` + `1.0` 倍速