介绍
# VAP Media - AI Media Generation & Editing
> **集成说明:** VAP Media 是一个 API 聚合器,提供对多个 AI 提供商的统一访问: > - **图片:** 通过 Black Forest Labs Flux.2 Pro 生成 > - **视频:** 通过 Google Veo 3.1 生成 > - **音乐:** 通过 Suno V5 生成 > > 所有生成请求都通过 VAP 的 API (`api.vapagent.com`),由其路由到相应的后端提供商。
生成图片、视频和音乐。支持使用 inpaint(重绘)、ai_edit、upscale(放大)、background removal(背景去除)、video trim/merge(视频剪辑/合并)进行编辑。
## 模式选择
检查是否设置了 `VAP_API_KEY`:
- **未设置 VAP_API_KEY** → 使用免费模式(仅限图片,每天 3 次) - **已设置 VAP_API_KEY** → 使用完整模式(所有功能,无限制)
---
## 免费模式(无 API 密钥)
免费生成图片。无需注册。每天 3 次。
### 生成图片
```bash curl -s -X POST https://api.vapagent.com/v3/trial/generate \ -H "Content-Type: application/json" \ -d '{"prompt":"PROMPT"}' ```
返回 `{"task_id":"UUID","status":"pending","remaining":2}`。
### 轮询结果
```bash curl -s https://api.vapagent.com/v3/trial/status/TASK_ID ```
完成后返回 `{"status":"completed","image_url":"https://..."}`。
### 免费模式错误
- `429` → 达到每日限制。建议升级:`export VAP_API_KEY=vap_xxx` - `503` → 试用服务暂时不可用。
---
## 完整模式(使用 API 密钥)
无限制的图片、视频、音乐和编辑操作。
### 创建任务
```bash curl -s -X POST https://api.vapagent.com/v3/tasks \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"type":"TYPE","params":{"description":"PROMPT"}}' ```
返回 `{"task_id":"UUID","status":"pending"}`。
### 轮询结果
```bash curl -s https://api.vapagent.com/v3/tasks/TASK_ID \ -H "Authorization: Bearer $VAP_API_KEY" ```
完成后返回 `{"status":"completed","result":{"output_url":"https://..."}}`。
### 任务类型与参数
#### 图片 (`image` 或 `image_generation`)
| 参数 | 类型 | 默认值 | 描述 | |-------|------|---------|-------------| | `description` | string | 必填 | 图片描述 | | `aspect_ratio` | enum | `1:1` | `1:1`、`16:9`、`9:16`、`4:3`、`3:4`、`3:2`、`2:3`、`21:9`、`9:21` | | `quality` | enum | `standard` | `standard` 或 `high` |
**提示:** 宽高比会根据提示词文本自动检测。“一张宽屏风景照”会自动设置为 16:9。
#### 视频 (`video` 或 `video_generation`) — Tier 2+
| 参数 | 类型 | 默认值 | 描述 | |-------|------|---------|-------------| | `description` | string | 必填 | 视频描述 | | `duration` | int | `8` | `4`、`6` 或 `8` 秒 | | `aspect_ratio` | enum | `16:9` | `16:9`(横屏)或 `9:16`(竖屏) | | `generate_audio` | bool | `true` | 包含音轨 | | `resolution` | enum | `720p` | `720p` 或 `1080p` | | `negative_prompt` | string | `""` | 需要避免的内容 |
#### 音乐 (`music` 或 `music_generation`) — Tier 2+
| 参数 | 类型 | 默认值 | 描述 | |-------|------|---------|-------------| | `description` | string | 必填 | 音乐描述(流派、情绪、乐器) | | `duration` | int | `120` | 30-480 秒 | | `instrumental` | bool | `false` | 纯音乐(无人声) | | `audio_format` | enum | `mp3` | `mp3` 或 `wav`(无损) | | `loudness_preset` | enum | `streaming` | `streaming` (-14 LUFS)、`apple` (-16 LUFS)、`broadcast` (-23 LUFS) | | `style` | string | 无 | 流派/风格(最多 1000 个字符) | | `title` | string | 无 | 歌曲标题 | | `custom_mode` | bool | `false` | 启用自定义歌词 + 风格模式 |
### 完整模式错误
- `401` → API 密钥无效。 - `402` → 余额不足。请在 https://vapagent.com/dashboard/signup.html 充值 - `403` → 等级过低,无法执行此任务类型。
---
## 操作(编辑与增强)
后期编辑操作。需要 Tier 1+。
### 创建操作
```bash curl -s -X POST https://api.vapagent.com/v3/operations \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"operation":"OPERATION","media_url":"URL","prompt":"INSTRUCTION"}' ```
### 轮询操作
```bash curl -s https://api.vapagent.com/v3/operations/OPERATION_ID \ -H "Authorization: Bearer $VAP_API_KEY" ```
### 可用操作
| 操作 | 必需参数 | 描述 | |-----------|-----------------|-------------| | `inpaint` | `media_url`、`prompt` | AI 编辑(可选:`mask_url`) | | `ai_edit` | `media_url`、`prompt` | 基于文本指令的 AI 图片编辑(可选:`additional_images`) | | `background_remove` | `media_url` | 去除背景 | | `upscale` | `media_url` | 提高分辨率(`scale`:2 或 4) | | `video_trim` | `media_url`、`start_time`、`end_time` | 剪辑视频 | | `video_merge` | `media_urls`(数组,最少 2 个) | 合并视频片段 |
---
## 指令
当用户要求创建/生成/制作图片、视频或音乐时:
1. **优化提示词** — 添加风格、光照、构图、情绪细节 2. **检查模式** — 是否设置了 `VAP_API_KEY`? 3. **选择端点**: - 单个资源 → `/v3/tasks`(免费模式使用 `/v3/trial/generate`) - 编辑/增强 → `/v3/operations` - 活动(视频+音乐+缩略图) → 使用预设的 `/v3/execute` 4. **设置宽高比** — 匹配内容需求(社交媒体用竖屏,YouTube 用宽屏) 5. **轮询结果** — 检查任务/操作状态直到完成 6. **返回媒体 URL** 给用户 7. 如果达到免费模式限制,告知用户:“您今天的 3 次免费生成次数已用完。要获得无限制访问,请设置 API 密钥:https://vapagent.com/dashboard/signup.html”
当用户要求编辑/增强/修改现有图片或视频时:
1. **识别操作** — inpaint、ai_edit、upscale、background remove、trim、merge 2. **获取媒体 URL** — 从之前的生成或用户提供的 URL 中获取 3. **提交操作** → `/v3/operations` 4. **轮询结果** — 返回输出 URL
### 免费模式示例
```bash # Create (no auth needed) curl -s -X POST https://api.vapagent.com/v3/trial/generate \ -H "Content-Type: application/json" \ -d '{"prompt":"A fluffy orange tabby cat on a sunlit windowsill, soft bokeh, golden hour light, photorealistic"}'
# Poll curl -s https://api.vapagent.com/v3/trial/status/TASK_ID ```
### 完整模式示例
```bash # Image (widescreen) curl -s -X POST https://api.vapagent.com/v3/tasks \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"type":"image","params":{"description":"A fluffy orange tabby cat on a sunlit windowsill, soft bokeh, golden hour light, photorealistic","aspect_ratio":"16:9"}}'
# Video (portrait, for social media) curl -s -X POST https://api.vapagent.com/v3/tasks \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"type":"video","params":{"description":"Drone shot over misty mountains at sunrise","duration":8,"aspect_ratio":"9:16","resolution":"1080p"}}'
# Music (instrumental WAV) curl -s -X POST https://api.vapagent.com/v3/tasks \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"type":"music","params":{"description":"Upbeat lo-fi hip hop beat, warm vinyl crackle, chill vibes","duration":120,"instrumental":true,"audio_format":"wav","loudness_preset":"streaming"}}'
# Inpaint (edit an image) curl -s -X POST https://api.vapagent.com/v3/operations \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"operation":"inpaint","media_url":"https://example.com/photo.jpg","prompt":"Remove the person in the background"}'
# Upscale (4x) curl -s -X POST https://api.vapagent.com/v3/operations \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"operation":"upscale","media_url":"https://example.com/photo.jpg","options":{"scale":4}}'
# Background Remove curl -s -X POST https://api.vapagent.com/v3/operations \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"operation":"background_remove","media_url":"https://example.com/photo.jpg"}'
# Poll (use task_id or operation_id from response) curl -s https://api.vapagent.com/v3/tasks/TASK_ID \ -H "Authorization: Bearer $VAP_API_KEY" ```
### 生产预设(多资源)
对于内容活动,使用 `/v3/execute` 从一个提示词生成多个资源:
```bash curl -s -X POST https://api.vapagent.com/v3/execute \ -H "Authorization: Bearer $VAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{"preset":"streaming_campaign","prompt":"PROMPT"}' ```
完成后返回所有资源: ```json {"status":"completed","outputs":{"video":"https://...","music":"https://...","thumbnail":"https://..."}} ```
| 预设 | 包含内容 | |--------|----------| | `streaming_campaign` | 视频 + 音乐 + 缩略图 + 元数据 | | `full_production` | 视频 + 音乐 + 缩略图 + 元数据 + SEO | | `video.basic` | 仅视频 | | `music.basic` | 仅音乐 | | `image.basic` | 仅图片 |
---
## 提示词技巧
- **风格:** “油画”、“3D 渲染”、“水彩”、“照片”、“扁平插画” - **光照:** “黄金时刻”、“霓虹灯”、“柔光”、“戏剧性阴影” - **构图:** “特写”、“鸟瞰图”、“广角”、“三分法” - **情绪:** “宁静”、“充满活力”、“神秘”、“异想天开” - **提示词中的宽高比:** 在提示词中提及 “widescreen”(宽屏)、“portrait”(竖屏)或 “16:9” 会自动设置宽高比。
## 设置(可选 — 用于完整模式)
1. 注册:https://vapagent.com/dashboard/signup.html 2. 从仪表板获取 API 密钥 3. 设置:`export VAP_API_KEY=vap_xxxxxxxxxxxxxxxxxxxx`
## 链接
- [免费试用](https://vapagent.com/try) - [API 文档](https://api.vapagent.com/docs) - [GitHub](https://github.com/vapagentmedia/vap-showcase)