Create Video
Generate complete videos from a text prompt. Describe what you want and the AI handles script writing, avatar selection, visuals, voiceover, pacing, and captions automatically.
Authentication
All requests require the X-Api-Key header. Set the HEYGEN_API_KEY environment variable.
CODEBLOCK0
Tool Selection
If HeyGen MCP tools are available (mcp__heygen__*), prefer them over direct HTTP API calls — they handle authentication and request formatting automatically.
| Task | MCP Tool | Fallback (Direct API) |
|---|
| Generate video from prompt | INLINECODE3 | INLINECODE4 |
| Check video status / get URL |
mcp__heygen__get_video |
GET /v3/videos/{video_id} |
| List account videos |
mcp__heygen__list_videos |
GET /v3/videos |
| Delete a video |
mcp__heygen__delete_video |
DELETE /v3/videos/{video_id} |
If no HeyGen MCP tools are available, use direct HTTP API calls as documented in the reference files.
Default Workflow
Always use prompt-optimizer.md guidelines to structure prompts with scenes, timing, and visual styles.
With MCP tools:
- 1. Write an optimized prompt using prompt-optimizer.md → visual-styles.md
- Call
mcp__heygen__generate_video_agent with prompt and config (durationsec, orientation, avatarid) - Call
mcp__heygen__get_video with the returned video_id to poll status and get the download URL
Without MCP tools (direct API):
- 1. Write an optimized prompt using prompt-optimizer.md → visual-styles.md
- INLINECODE13 — see video-agent.md
- INLINECODE14 — see video-status.md
Reference Files
Read these as needed — they contain endpoint details, request/response schemas, and code examples (curl, TypeScript, Python).
Core workflow:
Foundation:
Best Practices
- 1. Optimize your prompt — quality depends entirely on prompt structure. Always use the prompt optimizer
- Lock avatar if needed — pass
avatar_id for consistency across videos - Specify voice — pass
voice_id for a specific narrator voice - Upload reference files — help the agent understand your brand/product
- Iterate on prompts — refine based on results; Video Agent is great for quick iterations
创建视频
根据文本提示生成完整视频。描述您的需求,AI将自动处理脚本编写、虚拟形象选择、视觉效果、配音、节奏和字幕。
身份验证
所有请求都需要X-Api-Key请求头。请设置HEYGENAPIKEY环境变量。
bash
curl -X POST https://api.heygen.com/v3/video-agents \
-H X-Api-Key: $HEYGENAPIKEY \
-H Content-Type: application/json \
-d {prompt: 创建一个60秒的产品演示视频。}
工具选择
如果HeyGen MCP工具可用(mcpheygen*),优先使用它们而非直接HTTP API调用——它们会自动处理身份验证和请求格式。
| 任务 | MCP工具 | 备用方案(直接API) |
|---|
| 根据提示生成视频 | mcpheygengeneratevideoagent | POST /v3/video-agents |
| 检查视频状态/获取URL |
mcp
heygenget
video | GET /v3/videos/{videoid} |
| 列出账户视频 | mcp
heygenlist_videos | GET /v3/videos |
| 删除视频 | mcp
heygendelete
video | DELETE /v3/videos/{videoid} |
如果没有可用的HeyGen MCP工具,请使用参考文件中记录的直连HTTP API调用。
默认工作流程
始终使用prompt-optimizer.md指南来构建包含场景、时间和视觉风格的提示。
使用MCP工具时:
- 1. 使用prompt-optimizer.md → visual-styles.md编写优化后的提示
- 调用mcpheygengeneratevideoagent,传入提示和配置(durationsec、orientation、avatarid)
- 调用mcpheygengetvideo,传入返回的videoid轮询状态并获取下载URL
不使用MCP工具时(直接API):
- 1. 使用prompt-optimizer.md → visual-styles.md编写优化后的提示
- POST /v3/video-agents — 参见video-agent.md
- GET /v3/videos/ — 参见video-status.md
参考文件
根据需要阅读这些文件——它们包含端点详情、请求/响应模式和代码示例(curl、TypeScript、Python)。
核心工作流程:
基础内容:
最佳实践
- 1. 优化您的提示 — 质量完全取决于提示结构。始终使用提示优化器
- 如需固定虚拟形象 — 传递avatarid以保持视频间的一致性
- 指定语音 — 传递voiceid以使用特定的旁白语音
- 上传参考文件 — 帮助智能体理解您的品牌/产品
- 迭代优化提示 — 根据结果进行调整;视频智能体非常适合快速迭代