Aller au contenu
Référence API
Référence API

Wan Texte en vidéo

Utilisez le point de terminaison texte vers vidéo pour créer une tâche asynchrone.

01

Vue d'ensemble

Utilisez le point de terminaison texte vers vidéo avec un modèle compatible. Utilisez l'ID de tâche retourné pour récupérer son état, ou fournissez callback_url pour les livraisons documentées ci-dessous.

Démarrage rapide

  1. Créez une clé API et définissez-la comme RUNAPI_API_KEY.
  2. Choisissez un modèle pris en charge et envoyez une requête POST dont le corps correspond au schéma de ce modèle.
  3. Enregistrez l'identifiant de tâche retourné, puis interrogez l'état jusqu'à atteindre un état terminal ou gérez les callbacks documentés ci-dessous.

Point de terminaison

POST /api/v1/wan/text_to_video
URL de base
https://runapi.ai
Version de l'API
v1
Authentification
Authorization: Bearer YOUR_API_TOKEN
02

Modèles pris en charge

Ouvrez une page de modèle pour consulter la tarification actuelle, les limites de débit et les conditions d'utilisation commerciale.

03

Schéma de requête

Corps JSON

Les champs et les valeurs autorisées dépendent du modèle sélectionné. Lorsqu'il est fourni, callback_url reçoit les livraisons de tâches documentées ci-dessous.

wan-2.2-a14b-text-to-video-turbo18 champs
accelerationstring
Optionnel
aspect_ratiostring
Optionnel
background_audio_urlstring
Optionnel
callback_urlstring
Optionnel
duration_secondsinteger
Optionnel
enable_prompt_expansionboolean
Optionnel
enable_safety_checkerboolean
Optionnel
first_frame_image_urlstring
Optionnel
modelstring
Optionnel
negative_promptstring
Optionnel
output_resolutionstring
Optionnel Valeurs autorisées: 480p, 580p, 720p
promptstring
Optionnel
ratiostring
Optionnel
reference_audio_urlstring
Optionnel
reference_image_urlsarray
Optionnel
reference_video_urlsarray
Optionnel
seedinteger
Optionnel
watermarkboolean
Optionnel
wan-2.5-text-to-video18 champs
accelerationstring
Optionnel
aspect_ratiostring
Optionnel
background_audio_urlstring
Optionnel
callback_urlstring
Optionnel
duration_secondsinteger
Optionnel
enable_prompt_expansionboolean
Optionnel
enable_safety_checkerboolean
Optionnel
first_frame_image_urlstring
Optionnel
modelstring
Optionnel
negative_promptstring
Optionnel
output_resolutionstring
Optionnel Valeurs autorisées: 720p, 1080p
promptstring
Optionnel
ratiostring
Optionnel
reference_audio_urlstring
Optionnel
reference_image_urlsarray
Optionnel
reference_video_urlsarray
Optionnel
seedinteger
Optionnel
watermarkboolean
Optionnel
wan-2.6-text-to-video18 champs
accelerationstring
Optionnel
aspect_ratiostring
Optionnel
background_audio_urlstring
Optionnel
callback_urlstring
Optionnel
duration_secondsinteger
Optionnel
enable_prompt_expansionboolean
Optionnel
enable_safety_checkerboolean
Optionnel
first_frame_image_urlstring
Optionnel
modelstring
Optionnel
multi_shotsboolean
Optionnel

Contrôle si la vidéo générée utilise plusieurs plans avec des transitions plutôt qu'un seul plan continu.

negative_promptstring
Optionnel
output_resolutionstring
Optionnel Valeurs autorisées: 720p, 1080p
promptstring
Optionnel
ratiostring
Optionnel
reference_audio_urlstring
Optionnel
reference_image_urlsarray
Optionnel
reference_video_urlsarray
Optionnel
watermarkboolean
Optionnel
wan-2.7-r2v18 champs
accelerationstring
Optionnel
aspect_ratiostring
Optionnel Valeurs autorisées: 16:9, 9:16, 1:1, 4:3, 3:4
background_audio_urlstring
Optionnel
callback_urlstring
Optionnel
duration_secondsinteger
Optionnel Par défaut: 5 Plage: 2 - 10
enable_prompt_expansionboolean
Optionnel
enable_safety_checkerboolean
Optionnel
first_frame_image_urlstring
Optionnel
modelstring
Optionnel
negative_promptstring
Optionnel
output_resolutionstring
Optionnel Valeurs autorisées: 720p, 1080p
promptstring
Optionnel
ratiostring
Optionnel
reference_audio_urlstring
Optionnel
reference_image_urlsarray
Optionnel
reference_video_urlsarray
Optionnel
seedinteger
Optionnel
watermarkboolean
Optionnel
wan-2.7-text-to-video18 champs
accelerationstring
Optionnel
aspect_ratiostring
Optionnel
background_audio_urlstring
Optionnel
callback_urlstring
Optionnel
duration_secondsinteger
Optionnel
enable_prompt_expansionboolean
Optionnel
enable_safety_checkerboolean
Optionnel
first_frame_image_urlstring
Optionnel
modelstring
Optionnel
negative_promptstring
Optionnel
output_resolutionstring
Optionnel Valeurs autorisées: 720p, 1080p
promptstring
Optionnel
ratiostring
Optionnel
reference_audio_urlstring
Optionnel
reference_image_urlsarray
Optionnel
reference_video_urlsarray
Optionnel
seedinteger
Optionnel
watermarkboolean
Optionnel

Règles conditionnelles

Ces exigences s'appliquent lorsque toutes les conditions listées sont réunies.

  1. Lorsque model = wan-2.2-a14b-text-to-video-turbo
    Requis
    Non accepté
    multi_shots
  2. Lorsque model = wan-2.5-text-to-video
    Requis
    Non accepté
    multi_shots
  3. Lorsque model = wan-2.6-text-to-video
    Requis
    Non accepté
    seed
  4. Lorsque model = wan-2.7-r2v
    Requis
    Non accepté
    multi_shots
  5. Lorsque model = wan-2.7-text-to-video
    Requis
    Non accepté
    multi_shots
04

Créer une acceptation

HTTP 202

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    },
    "task_replayed": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "status",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "processing"
}
05

Interrogation en cours

HTTP 200

GET /api/v1/wan/text_to_video/:id

Schéma de réponse
JSON
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "processing"
}
06

Interrogation terminée

HTTP 200

GET /api/v1/wan/text_to_video/:id

Schéma de réponse
JSON
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "videos": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "status",
    "videos",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "completed",
  "videos": [
    {
      "url": "https://file.runapi.ai/reference-video.mp4"
    }
  ]
}
07

Échec de l'interrogation

HTTP 200

GET /api/v1/wan/text_to_video/:id

Schéma de réponse
JSON
{
  "properties": {
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "error": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "error": "Task processing failed.",
  "id": "tsk_reference_demo",
  "status": "failed"
}
08

Rappel client : terminé

HTTP 200

POST callback_url

Schéma de réponse
JSON
{
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "videos": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    }
  },
  "required": [
    "id",
    "status",
    "videos"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "id": "tsk_reference_demo",
  "status": "completed",
  "videos": [
    {
      "url": "https://file.runapi.ai/reference-video.mp4"
    }
  ]
}
09

Rappel client : échoué

HTTP 200

POST callback_url

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "properties": {
            "code": {
              "type": "string"
            },
            "limit_cents": {
              "type": "integer"
            },
            "message": {
              "type": "string"
            },
            "reset_at": {
              "format": "date-time",
              "type": [
                "string",
                "null"
              ]
            },
            "used_cents": {
              "type": "integer"
            },
            "window": {
              "enum": [
                "1h",
                "1d",
                "7d",
                "daily",
                "weekly",
                "monthly",
                "lifetime"
              ],
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object",
          "unevaluatedProperties": false
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": {
    "code": "generation_failed",
    "message": "Task processing failed."
  },
  "id": "tsk_reference_demo",
  "status": "failed"
}
10

Erreurs

HTTP 401

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "Authentication required"
}
11

Erreurs

HTTP 401

GET /api/v1/wan/text_to_video/:id

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "Authentication required"
}
12

Erreurs

HTTP 400

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Message d'erreur lisible par l'humain.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Résumé de validation lisible par l'humain.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Messages de validation indexés par champ de requête public, avec un tableau de chaînes lisibles par l'humain pour chaque champ.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}

Exemple de réponse

JSON
{
  "error": "model must be one of: wan-2.2-a14b-text-to-video-turbo, wan-2.5-text-to-video, wan-2.6-text-to-video, wan-2.7-r2v, wan-2.7-text-to-video"
}
13

Erreurs

HTTP 402

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "Insufficient balance"
}
14

Erreurs

HTTP 429

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "API key credit limit exceeded"
}
15

Erreurs

HTTP 409

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "The request uses features that are not supported for the selected model"
}
16

Erreurs

HTTP 429

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "Rate limit reached. Please retry later."
}
17

Erreurs

HTTP 503

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "Service under maintenance, please try again later"
}
18

Erreurs

HTTP 504

POST /api/v1/wan/text_to_video

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "The request timed out"
}
19

Erreurs

HTTP 404

GET /api/v1/wan/text_to_video/:id

Schéma de réponse
JSON
{
  "properties": {
    "error": {
      "description": "Message d'erreur lisible par l'humain.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Exemple de réponse

JSON
{
  "error": "Task with id 'tsk_reference_demo' not found"
}
20

Exemples de code générés

Utilisez directement cURL, ou installez un SDK pour votre langage. Chaque exemple soumet la requête validée indiquée dans cette référence.

Installer

Shell
pip install runapi-wan
PYTHON
import os
from runapi.wan import WanClient

client = WanClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_video.create(
  model="wan-2.2-a14b-text-to-video-turbo",
  prompt="A paper kite flying above a quiet coastal town at sunrise."
)