API · MCP · Agent skill
H3Gen developer docs
Generate MiniMax H3 videos and H3-Image 4K images from your own code, from Claude, Cursor and other MCP clients, or from an agent skill. Every call spends the same credits as the studio.
Overview
Base URL https://h3gen.io. Requests and responses are JSON. Generation is asynchronous: you start a task, then read it until it has succeeded or failed.
/api/v1/mcph3gen-video agent skillQuickstart
1. Create a key in Settings → API keys. It is shown once; store it as H3GEN_API_KEY.
2. Start a video:
export H3GEN_API_KEY="sk_..."
curl https://h3gen.io/api/v1/videos \
-H "Authorization: Bearer $H3GEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A street violinist at dusk, slow push-in, crowd murmur and a warm melody",
"resolution": "768p",
"duration": 6,
"max_credits": 40,
"client_request_id": "violinist-001"
}'{
"tasks": [{ "id": "8f3c…", "type": "video", "status": "processing" }],
"credits_charged": 36
}3. Read the task. wait=25 holds the request until the video is ready or 25 seconds pass; repeat until the status changes.
curl "https://h3gen.io/api/v1/tasks/8f3c…?wait=25" \
-H "Authorization: Bearer $H3GEN_API_KEY"{
"id": "8f3c…",
"type": "video",
"status": "succeeded",
"prompt": "A street violinist at dusk, …",
"credits": 36,
"created_at": "2026-11-21T12:00:00.000Z",
"output": {
"url": "https://h3gen.io/api/v1/files/8f3c…?expires=…&signature=…",
"download_url": "https://h3gen.io/api/v1/files/8f3c…?expires=…&signature=…&download=1",
"expires_at": "2026-11-22T12:03:10.000Z"
}
}Authentication
Send the key as Authorization: Bearer sk_… (or X-API-Key: sk_…). Keys act as your account: keep them on the server, never in a browser or a public repo. Delete a key in settings to revoke it at once.
Create a video
POST /api/v1/videos returns 202 with one task per output. The mode follows the fields you send: prompt only is text to video; image (plus optional image_end) is image to video; ref_images, ref_videos and ref_audios are omni reference.
promptresolutiondurationratioimageimage_endimage_task_idref_imagesref_videosref_audioscountprompt_optimizermax_creditsclient_request_idA first frame works with ref_images but not with ref_videos or ref_audios.
Image to video
# 1. upload the first frame
curl https://h3gen.io/api/v1/uploads \
-H "Authorization: Bearer $H3GEN_API_KEY" \
-F "file=@product.jpg"
# → { "url": "https://…/3b1d….jpg", "type": "image", "bytes": 482113 }
# 2. animate it
curl https://h3gen.io/api/v1/videos \
-H "Authorization: Bearer $H3GEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"The bottle rotates on wet stone, rain, macro lens","image":"https://…/3b1d….jpg","resolution":"1080p","duration":5}'Song and cover art to a music video
{
"prompt": "The singer from image 1 performs the chorus on a neon rooftop, lip-synced, handheld orbit",
"ref_images": ["https://…/cover.png"],
"ref_audios": ["https://…/chorus.mp3"],
"ratio": "9:16",
"resolution": "1080p",
"duration": 10,
"max_credits": 90
}Create an image
POST /api/v1/images starts one H3-Image task. Add up to 3 ref_images to edit or combine photos.
promptresolutionratioref_imagesmax_creditsclient_request_idcurl https://h3gen.io/api/v1/images \
-H "Authorization: Bearer $H3GEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"Studio packshot of a ceramic mug, soft daylight, 45° angle","resolution":"4k","ratio":"1:1"}'
# then animate the finished image
curl https://h3gen.io/api/v1/videos \
-H "Authorization: Bearer $H3GEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"Steam rises from the mug, slow dolly in","image_task_id":"<image task id>","resolution":"1080p","duration":5}'Upload media
Frames and references must be hosted by H3Gen. POST /api/v1/uploads takes multipart form data with one file field, or JSON with a public https url to import. It returns the url to use in a request.
curl https://h3gen.io/api/v1/uploads \
-H "Authorization: Bearer $H3GEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/reference.mp4"}'Tasks and results
GET /api/v1/tasks/{id} returns processing, succeeded or failed. Videos usually take 1–5 minutes. Add ?wait=25 to hold the request; otherwise poll every 15–30 seconds. GET /api/v1/tasks lists recent tasks.
When a task succeeds, output.url streams the file and output.download_url downloads it. Both links work without the key for 24 hours; read the task again for fresh ones. A failed task carries error.code (FAILED or TIMEOUT) and its credits are already refunded.
Credits
API calls use your H3Gen credit balance (GET /api/v1/account). Price a request first with POST /api/v1/estimate (add "type": "image" for images).
Clips longer than 15 seconds cost 2× per second. Reference-video seconds are added to the billed seconds. Reference images beyond 5 cost 1 credit each; the prompt optimizer adds 1.
Image references beyond 2 cost 2 credits each. Buy credits on the pricing page.
curl https://h3gen.io/api/v1/estimate \
-H "Authorization: Bearer $H3GEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"…","resolution":"2k","duration":10,"count":2}'
# → { "credits": 200, "outputs": 2, "credits_per_output": 100 }Retries and limits
Send a unique client_request_id (or an Idempotency-Key header) with each generation. If the same id arrives again within 24 hours, you get the original tasks back with "replayed": true and nothing new is charged. Use max_credits as a ceiling for automated callers.
Requests are rate limited per account (about one generation or upload per second). A 429 means wait a moment and retry.
Errors
Errors use HTTP status codes and a JSON body:
{
"error": {
"code": "insufficient_credits",
"message": "This request needs 100 credits; the balance is 40.",
"needed": 100,
"balance": 40,
"top_up_url": "https://h3gen.io/pricing"
}
}invalid_requestunauthorizedpayment_requiredinsufficient_creditsnot_foundinvalid_requestrate_limitedunavailableMCP server
https://h3gen.io/mcp is a remote MCP server (Streamable HTTP). It authenticates with the same API key in the Authorization header and spends the same credits.
Claude Code
claude mcp add --transport http h3gen https://h3gen.io/mcp \
--header "Authorization: Bearer $H3GEN_API_KEY"Cursor, Windsurf and other clients with header support
{
"mcpServers": {
"h3gen": {
"url": "https://h3gen.io/mcp",
"headers": { "Authorization": "Bearer sk_..." }
}
}
}get_accountlist_capabilitiesestimate_video_costestimate_image_costimport_mediagenerate_videogenerate_imageget_tasklist_tasksAgents are told to estimate and confirm the cost before generating, pass max_credits and a client_request_id, and poll get_task instead of resubmitting. Connectors that only support OAuth (claude.ai, ChatGPT) are not supported yet.
Agent skill
The h3gen-video skill teaches Claude Code and other skill-aware agents the full workflow: upload, estimate, generate, wait and download. It ships with a dependency-free Node 18+ script.
mkdir -p ~/.claude/skills/h3gen-video/scripts
curl -fsSL https://h3gen.io/skills/h3gen-video/SKILL.md -o ~/.claude/skills/h3gen-video/SKILL.md
curl -fsSL https://h3gen.io/skills/h3gen-video/scripts/h3gen.mjs -o ~/.claude/skills/h3gen-video/scripts/h3gen.mjs
export H3GEN_API_KEY="sk_..."
# the script also works on its own
node ~/.claude/skills/h3gen-video/scripts/h3gen.mjs accountReference files
- openapi.json — OpenAPI 3.1 spec for code generators and GPT actions.
- SKILL.md — the agent skill.
- /api/v1/models — live limits and prices as JSON.
- Questions: support@h3gen.io