API documentation
One request makes one video: call POST /api/v1/videos with your API key, get a video id back, then poll GET /api/v1/videos/{id} or pass a webhook_url and wait for our callback. Every endpoint speaks JSON, prices are in credits, and a failed video refunds its credits on its own.




1. Authentication
Create a key on Settings → API keys (it starts with sk_) and send it as a header:
Authorization: Bearer sk_…
A key is shown once; revoking it stops it at once. Keep keys out of front-end code and public repos.
2. Create a video
POST /api/v1/videos
| Field | Type | Notes |
|---|---|---|
model |
string | Required. See the model table, e.g. seedance-2-fast |
prompt |
string | Required, up to 2,000 characters |
image_url |
string | Optional https URL of a first frame. Makes it image-to-video; required for Hailuo 2.3 |
resolution |
string | Optional; defaults to the model’s default |
seconds |
number | Optional video length |
aspect_ratio |
string | Optional, text-to-video only, e.g. 16:9, 9:16 |
webhook_url |
string | Optional https URL we POST to when the video ends |
Send an Idempotency-Key header to make retries safe: the same key on the same account creates one video only.
curl https://magi2ai.dev/api/v1/videos \
-H "Authorization: Bearer $MAGI2_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f3c1a52-launch-teaser" \
-d '{
"model": "seedance-2-fast",
"prompt": "A lighthouse at dusk, waves rolling in, slow push-in",
"resolution": "480p",
"seconds": 5,
"aspect_ratio": "16:9",
"webhook_url": "https://example.com/hooks/magi2"
}'
Response 201:
{
"data": {
"id": "3f9c2b7e-5a1d-4c8e-9b0f-2d6e8a41c7d3",
"status": "pending",
"model": "seedance-2-fast",
"modelName": "Seedance 2.0 Fast",
"mode": "text",
"prompt": "A lighthouse at dusk, waves rolling in, slow push-in",
"resolution": "480p",
"seconds": 5,
"aspect": "16:9",
"credits": 95,
"outputs": [],
"license": "commercial",
"createdAt": "2026-11-25T09:12:44.000Z"
}
}
Image to video:
curl https://magi2ai.dev/api/v1/videos \
-H "Authorization: Bearer $MAGI2_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "hailuo-2-3",
"prompt": "The rider leans into the turn, camera tracks alongside",
"image_url": "https://example.com/first-frame.jpg",
"resolution": "768p",
"seconds": 6
}'
3. Get the result
GET /api/v1/videos/{id} returns the same object. status moves from pending to processing and ends as success, failed or canceled. On success outputs[0] is the MP4 URL. Poll about every 10 seconds, or use a webhook.
curl https://magi2ai.dev/api/v1/videos/3f9c2b7e-5a1d-4c8e-9b0f-2d6e8a41c7d3 \
-H "Authorization: Bearer $MAGI2_API_KEY"
GET /api/v1/videos?limit=20&page=1 lists your videos, newest first.
4. Models and prices
GET /api/v1/models needs no key and returns every model’s options and prices. Today’s models:
Model (model) |
Input | Resolution | Seconds | Sound | From |
|---|---|---|---|---|---|
Seedance 2.0 Fast (seedance-2-fast) |
text or image | 480p / 720p | 5 / 10 | yes | 15 credits |
Kling 4.0 Flash (kling-4-flash) |
text or image | 720p | 5 / 10 | no | 20 credits |
Wan 2.7 (wan-2-7) |
text or image | 720p / 1080p | 5 / 10 | no | 15 credits |
Hailuo 2.3 (hailuo-2-3) |
image only | 768p / 1080p | 6 / 10 | no | 11 credits |
MAGI-2 (magi-2) |
coming soon | not sold |
Credits for every combination:
| Model | Resolution | Length | Credits |
|---|---|---|---|
| Seedance 2.0 Fast | 480p | 5 s | 15 |
| Seedance 2.0 Fast | 480p | 10 s | 30 |
| Seedance 2.0 Fast | 720p | 5 s | 25 |
| Seedance 2.0 Fast | 720p | 10 s | 50 |
| Kling 4.0 Flash | 720p | 5 s | 20 |
| Kling 4.0 Flash | 720p | 10 s | 40 |
| Wan 2.7 | 720p | 5 s | 15 |
| Wan 2.7 | 720p | 10 s | 30 |
| Wan 2.7 | 1080p | 5 s | 25 |
| Wan 2.7 | 1080p | 10 s | 50 |
| Hailuo 2.3 | 768p | 6 s | 11 |
| Hailuo 2.3 | 768p | 10 s | 18 |
| Hailuo 2.3 | 1080p | 6 s | 16 |
Credits are taken when a video starts and returned automatically if it fails. A prompt stopped by content screening is never charged. Buy credits on Pricing.
5. Account balance
GET /api/v1/account returns { "data": { "credits": 1234 } }.
6. Errors
Errors come back as { "error": { "message": "…" } }:
| Status | Meaning |
|---|---|
400 |
Body isn’t JSON, or an invalid option combination (a resolution or length the model doesn’t offer, or magi-2, which isn’t live yet) |
401 |
Missing, invalid or revoked key |
402 |
Not enough credits |
422 |
The prompt or image failed content screening (not charged) |
429 |
Too fast; try again shortly |
5xx |
Our side failed; retry with the same Idempotency-Key |
7. Code samples
JavaScript (Node 18+):
const res = await fetch('https://magi2ai.dev/api/v1/videos', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MAGI2_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'wan-2-7',
prompt: 'Morning fog lifting off an alpine lake, drone glide',
resolution: '720p',
seconds: 5,
aspect_ratio: '16:9',
}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(error.message);
console.log(data.id, data.status);
Python:
import os, time, requests
API = "https://magi2ai.dev/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MAGI2_API_KEY']}"}
video = requests.post(f"{API}/videos", headers=HEADERS, json={
"model": "kling-4-flash",
"prompt": "A red fox trotting through a birch forest in snow",
"resolution": "720p",
"seconds": 5,
"aspect_ratio": "16:9",
}).json()["data"]
while video["status"] in ("pending", "processing"):
time.sleep(10)
video = requests.get(f"{API}/videos/{video['id']}", headers=HEADERS).json()["data"]
print(video["status"], video["outputs"])
8. From an AI assistant (MCP)
The same features are on the MCP server at https://magi2ai.dev/mcp, for Claude, ChatGPT, Cursor and other clients, with OAuth sign-in or the same API key. Setup steps: MCP server.
Questions
How long does a video take?
Usually from under a minute to a few minutes, depending on the model, resolution and length. A webhook saves you from polling.
Do failed videos cost credits?
Credits are taken at the start and returned automatically when a video fails. A request stopped by content screening is never charged.
Can I use an image hosted elsewhere as the first frame?
Yes. Pass a public https image URL; we copy it to our own storage before the video starts.
Are there rate limits?
Each account can create one video per second, and the number of videos running at once is capped (higher on paid accounts). Past that you get a 429.
Last updated: