API publique

Générer des vidéos et des images à partir de vos propres outils

Créez une clé, appelez l'API avec l'authentification Bearer, et interrogez le statut de la tâche jusqu'à ce que votre résultat soit prêt. Fonctionne avec Claude Code, Codex, et tout client HTTP.

Démarrage rapide

  1. 1

    Créer une clé

    Générez une clé API dans votre tableau de bord. Elle n'est affichée qu'une seule fois, alors conservez-la dans un endroit sûr.

  2. 2

    Appeler l'API

    Envoyez une requête POST avec votre clé Bearer et un en-tête Idempotency-Key.

    curl -X POST https://www.magi2.si/api/v1/video/magi2 \
      -H "Authorization: Bearer $SEEDANCE_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: demo-magi2-001" \
      -d '{
        "type": "text-to-video",
        "prompt": "A cinematic shot of a glass train crossing a snowy mountain bridge",
        "duration": 5,
        "aspect_ratio": "16:9",
        "generate_audio": true
      }'
  3. 3

    Vérifier le résultat

    Interrogez l'endpoint de statut de la tâche jusqu'à ce que le statut soit « terminé » ou « échoué », puis lisez la sortie.

    while true; do
      TASK=$(curl -s https://www.magi2.si/api/v1/tasks/sd2_xxxxx \
        -H "Authorization: Bearer $SEEDANCE_API_KEY")
      STATUS=$(echo "$TASK" | jq -r '.status')
      if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
        echo "$TASK" | jq
        break
      fi
      sleep 10
    done

Authentification

Chaque requête est authentifiée à l'aide d'une clé API Bearer dans l'en-tête Authorization.

Base URL
https://www.magi2.si/api/v1
Idempotency-Key
Send a unique value with every POST. Retrying with the same key and body within 24 hours returns the original task instead of charging for a second one.
Credits
Calls spend credits from the key owner's personal balance. Team credits are not used.
Media URLs
Reference images, videos and audio must be public HTTPS URLs that can be fetched without cookies or a login.
http
Authorization: Bearer sk_live_your_api_key
Content-Type: application/json
Idempotency-Key: a-unique-id-per-request

MAGI 2.0 Video

Texte, image ou média en vidéo.

Types
Text, first and last frame, references
Duration
4 to 30 seconds
References
10 images, 5 videos, 5 audio clips
Task ID
sd2_…
1

Soumettre une tâche

POST
/api/v1/video/magi2

Paramètres

  • typestringRequis

    text-to-video takes the prompt alone; image-to-video starts from a first frame; reference-to-video follows reference media.

    text-to-videoimage-to-videoreference-to-video
  • promptstringRequis

    Text prompt. Refer to references as @Image1, @Video1 and @Audio1, numbered by kind in URL order.

    1–8000 chars
  • durationintegerOptionnelPar défaut 5

    Clip duration. 12 credits per second of output.

    4–30 (seconds)
  • resolutionstringOptionnelPar défaut 1080p

    Every MAGI 2.0 video is rendered at 1080p.

    1080p
  • aspect_ratiostringOptionnelPar défaut 16:9

    Aspect ratio.

    16:99:161:14:33:421:9
  • generate_audiobooleanOptionnelPar défaut true

    Generate sound with the picture. The price is the same either way.

    truefalse
  • first_frame_urlstring (URL)Optionnel

    image-to-video: opening frame, required for this type.

    public https URL, ≤ 20 MB
  • last_frame_urlstring (URL)Optionnel

    image-to-video: optional closing frame.

    public https URL, ≤ 20 MB
  • image_urlsstring[] (URL)Optionnel

    reference-to-video: reference images. At least one image, video or audio clip is required for this type.

    ≤ 10 images
  • video_urlsstring[] (URL)Optionnel

    reference-to-video: reference videos (MP4 or MOV, ≤ 100 MB each).

    ≤ 5 videos, 2–30 s each, 30 s in total
  • audio_urlsstring[] (URL)Optionnel

    reference-to-video: reference audio (MP3 or WAV, ≤ 15 MB each).

    ≤ 5 clips, 30 s in total

Requête

curl -X POST https://www.magi2.si/api/v1/video/magi2 \
  -H "Authorization: Bearer $SEEDANCE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: demo-magi2-001" \
  -d '{
    "type": "text-to-video",
    "prompt": "A cinematic shot of a glass train crossing a snowy mountain bridge",
    "duration": 5,
    "aspect_ratio": "16:9",
    "generate_audio": true
  }'

Réponse202

json
{
  "id": "sd2_xxxxx",
  "status": "processing",
  "model": "magi2",
  "type": "text-to-video",
  "duration": 5,
  "resolution": "1080p",
  "billable_seconds": 5,
  "credits_used": 60
}

Les valeurs credits_used affichées dans ces exemples sont fournies à titre indicatif. La consommation réelle est calculée lors de l’envoi et renvoyée par l’API.

2

Statut de la tâche

GET
/api/v1/tasks/{id}

status

processing
Accepted and running. Keep polling.
completed
Finished. Read output, or result_urls for a flat list of files.
failed
Ended without a result. error says why and credits_refunded shows what was returned.

Poll every 10 seconds or so and stop at completed or failed. Status reads have their own rate limit, so polling never uses up your submit budget.

Requête

curl https://www.magi2.si/api/v1/tasks/sd2_xxxxx \
  -H "Authorization: Bearer $SEEDANCE_API_KEY"

Réponse200

json
{
  "id": "sd2_xxxxx",
  "type": "video",
  "status": "completed",
  "model": "magi2",
  "quality_tier": null,
  "channel": null,
  "resolution": "1080p",
  "credits_used": 60,
  "credits_refunded": 0,
  "pricing": {
    "billable_seconds": 5,
    "unit_rate_credits": 12
  },
  "output": {
    "video_url": "https://...",
    "last_frame_url": null,
    "seed": null
  },
  "result_urls": ["https://..."],
  "error": null,
  "created_at": "2026-12-01T10:00:00.000Z",
  "updated_at": "2026-12-01T10:06:30.000Z"
}

Wait for the result

while true; do
  TASK=$(curl -s https://www.magi2.si/api/v1/tasks/sd2_xxxxx \
    -H "Authorization: Bearer $SEEDANCE_API_KEY")
  STATUS=$(echo "$TASK" | jq -r '.status')
  if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
    echo "$TASK" | jq
    break
  fi
  sleep 10
done

Tasks and balance

Read endpoints for building a task history, showing remaining credits, or discovering models at runtime. They share the read rate limit.

List tasks

GET
/api/v1/tasks

Returns the tasks this account created through the API in the last 30 days, newest first. Each item has the same shape as a single task. Use limit (1 to 50, default 20) and pass next_cursor as before to fetch the next page.

curl "https://www.magi2.si/api/v1/tasks?limit=20" \
  -H "Authorization: Bearer $SEEDANCE_API_KEY"
json
{
  "data": [
    {
      "id": "sd2_xxxxx",
      "type": "video",
      "status": "completed",
      "model": "seedance2",
      "credits_used": 30,
      "result_urls": ["https://..."]
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Check balance

GET
/api/v1/balance

Returns the credits the key owner can spend through the API. subscription_credits is the part that came from a plan and expires at subscription_credits_expire_at.

curl "https://www.magi2.si/api/v1/balance" \
  -H "Authorization: Bearer $SEEDANCE_API_KEY"
json
{
  "credits": 1200,
  "subscription_credits": 1000,
  "subscription_credits_expire_at": "2026-07-01T00:00:00.000Z"
}

List models

GET
/api/v1/models

Returns every model the API serves with its endpoint, accepted modes and task ID prefix. Useful for building a model picker without hard-coding this page.

curl "https://www.magi2.si/api/v1/models" \
  -H "Authorization: Bearer $SEEDANCE_API_KEY"
json
{
  "data": [
    {
      "id": "seedance2",
      "name": "Seedance 2",
      "type": "video",
      "method": "POST",
      "endpoint": "/api/v1/video/seedance2",
      "modes": ["text-to-video", "image-to-video", "media-to-video"],
      "task_id_prefix": "sd2_"
    }
  ]
}

Codes d'erreur

Every error has the same shape. Branch on code, and show message to a person. A task that was accepted can still fail later, so also check status when you poll.

json
{
  "error": {
    "code": "invalid_request",
    "message": "Invalid request body: prompt: String must contain at least 3 character(s)"
  }
}
CodeHTTPSignification
unauthorized401Missing, invalid, or revoked API key.
invalid_request400Bad input or unsupported field. The message names the first field that failed; details lists them all.
purchase_required403The requested paid tier requires a successful credits or plan purchase; free promotional credits alone do not unlock it.
insufficient_credits402Not enough credits. Seedance 2.5 always returns HTTP 402 with insufficient_credits; when an authoritative quote is available, it may also include required_credits, available_credits, pricing_version, and promotion_applied.
rate_limited429Too many requests for this account. See Rate limits below. Seedance requests that validate reference media are limited to 3 per 60 seconds per account and source IP, with a project-wide safety cap. Retry after the Retry-After response header (in seconds).
idempotency_conflict409Same Idempotency-Key reused with a different body, or still running.
service_busy503Temporary upstream or credit-concurrency issue. Retry.
not_found404Task does not exist or does not belong to this key owner.
internal_error500Unexpected server-side failure.

Rate limits

A request over the limit returns HTTP 429 with a Retry-After header in seconds, plus X-RateLimit-Limit and X-RateLimit-Reset. Wait that long, then retry with the same Idempotency-Key.

Submit a job
30 per 60 seconds
Every POST endpoint, counted per account across all of its keys.
Read
120 per 60 seconds
Task status, task list, balance and models. Counted separately, so polling never uses up the submit budget.
Reference media validation
3 per 60 seconds
Seedance requests that include reference media, per account and source IP.

Utiliser avec Claude Code

Utilisez Copy for AI pour exporter l'API complète en Markdown propre, collez-le dans Claude Code ou Codex, et laissez l'agent se charger de l'intégration. Ou pointez l'agent directement vers le endpoint de texte brut.

Skill

Installez la compétence Seedance dans Claude Code, Codex ou tout autre agent — elle rédige des prompts cinématographiques et les génère via l'API pour vous.

bash
# Download the one-file skill from MAGI 2.0 AI
mkdir -p ~/.claude/skills/seedance
curl --fail --location -H "Authorization: Bearer $SEEDANCE_API_KEY" https://www.magi2.si/downloads/seedance-skill.md -o ~/.claude/skills/seedance/SKILL.md.tmp &&
mv ~/.claude/skills/seedance/SKILL.md.tmp ~/.claude/skills/seedance/SKILL.md

FAQ

Qui peut utiliser l'API ?
Tout utilisateur disposant de crédits. Aucune restriction de forfait — n'importe quel compte avec des crédits peut créer une clé et appeler l'API.
Comment obtenir des crédits ?
Rechargez ou abonnez-vous sur la page des tarifs. Les crédits sont ajoutés à votre solde instantanément.
Les crédits sont-ils partagés entre le site web et l'API ?
Oui — votre solde de crédits personnel alimente à la fois vos générations web et vos appels API. Dans une équipe, les appels API utilisent le solde personnel de chaque membre, et non le pool partagé de l'équipe.
Par où commencer ?
Créez une clé API dans votre tableau de bord, puis appelez les endpoints avec un jeton Bearer (voir le Quickstart ci-dessus).
Que faire si un appel renvoie insufficient_credits ?
Votre solde est vide — rechargez sur la page des tarifs et réessayez.