H3Gen

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.

Call it from a backend or script
REST API under /api/v1
Let Claude Code, Cursor or another MCP client make videos
Remote MCP server at /mcp
Give a coding agent a ready-made workflow
The h3gen-video agent skill
API and MCP generation is available to accounts with a credit pack or subscription. Failed tasks are refunded automatically. H3Gen is an independent service and is not affiliated with MiniMax.

Quickstart

1. Create a key in Settings → API keys. It is shown once; store it as H3GEN_API_KEY.

2. Start a video:

bash
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"
  }'
202 Accepted
{
  "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.

bash
curl "https://h3gen.io/api/v1/tasks/8f3c…?wait=25" \
  -H "Authorization: Bearer $H3GEN_API_KEY"
200 OK
{
  "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.

prompt
Type:string, required
Notes:Subject, action, camera move, lighting and sound. Up to 5,000 characters.
resolution
Type:480p · 768p · 1080p · 2k
Notes:Default 2k.
duration
Type:integer 4–30
Notes:Seconds. 2k allows up to 15. Default 5.
ratio
Type:16:9 · 9:16 · 1:1 · 4:3 · 3:4 · 21:9
Notes:Text and reference mode. Ignored with a first frame.
image
Type:URL
Notes:First frame, from /api/v1/uploads.
image_end
Type:URL
Notes:Last frame. Needs image.
image_task_id
Type:string
Notes:Use a finished image task of your account as the first frame.
ref_images
Type:URL[] ≤ 9
Notes:Images beyond 5 cost 1 credit each.
ref_videos
Type:URL[] ≤ 3
Notes:2–15 s each, 15 s total. Their seconds are billed.
ref_audios
Type:URL[] ≤ 3
Notes:Dialogue, a song or ambience to follow.
count
Type:integer 1–4
Notes:Videos to make. Each is its own task and charge.
prompt_optimizer
Type:boolean
Notes:Let the model expand the prompt (+1 credit).
max_credits
Type:number
Notes:Refuse instead of charging if the request costs more.
client_request_id
Type:string
Notes:Makes retries safe. See Retries and limits.

A first frame works with ref_images but not with ref_videos or ref_audios.

Image to video

bash
# 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

request body
{
  "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.

prompt
string, required, up to 2,000 characters
resolution
1k · 2k · 4k (default 2k)
ratio
1:1 · 16:9 · 9:16 · 4:3 · 3:4 · 3:2 · 2:3 · 21:9 (default 16:9)
ref_images
URL[] ≤ 3
max_credits
number
client_request_id
string
bash
curl 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.

Image
Formats:PNG, JPEG, WebP
Limit:20 MB
Video
Formats:MP4, MOV
Limit:30 MB, 2–15 s
Audio
Formats:MP3, WAV
Limit:15 MB
bash
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).

480p
4
768p
6
1080p
8
2K
10

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.

1k
8
2k
12
4k
24

Image references beyond 2 cost 2 credits each. Buy credits on the pricing page.

bash
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:

402 Payment Required
{
  "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"
  }
}
400
code:invalid_request
Meaning:A field is missing or out of range; the message names it.
401
code:unauthorized
Meaning:Missing, invalid or revoked key.
402
code:payment_required
Meaning:The account has no credit pack or subscription yet.
402
code:insufficient_credits
Meaning:Not enough credits for this request.
404
code:not_found
Meaning:No such task on this account.
411 / 413 / 415
code:invalid_request
Meaning:Upload without Content-Length, too large, or wrong type.
429
code:rate_limited
Meaning:Too many requests.
502 / 503
code:unavailable
Meaning:Generation could not start; any charge was refunded.

MCP 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

bash
claude mcp add --transport http h3gen https://h3gen.io/mcp \
  --header "Authorization: Bearer $H3GEN_API_KEY"

Cursor, Windsurf and other clients with header support

mcp.json
{
  "mcpServers": {
    "h3gen": {
      "url": "https://h3gen.io/mcp",
      "headers": { "Authorization": "Bearer sk_..." }
    }
  }
}
get_account
Credit balance and whether API generation is enabled.
list_capabilities
Models, limits, upload types and credit prices.
estimate_video_cost
Credits a generate_video call would cost.
estimate_image_cost
Credits a generate_image call would cost.
import_media
Copy a public https image, video or audio file into H3Gen.
generate_video
Start MiniMax H3 video generation (spends credits).
generate_image
Start H3-Image generation or editing (spends credits).
get_task
Status and 24-hour result link; wait_seconds holds the call up to 25 s.
list_tasks
Recent video and image tasks.

Agents 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.

bash
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 account

Reference files