> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Créer une vidéo Veo 3

> Générez des vidéos Veo 3.1 de manière asynchrone via CometAPI avec POST /v1/videos, puis interrogez la tâche et téléchargez le fichier MP4 terminé.

Utilisez ce point de terminaison pour démarrer une tâche vidéo Veo 3.1. L'API renvoie immédiatement un ID de tâche ; stockez donc l'`id` retourné et interrogez la tâche jusqu'à ce qu'elle atteigne un statut terminal.

`POST /v1/videos` utilise `multipart/form-data` ; transmettez les contrôles scalaires comme champs de formulaire et les entrées multimédias comme champs de fichier `input_reference`.

## Choisir un modèle

| Model ID      | Quand l'utiliser                                                            | Remarques                  |
| ------------- | --------------------------------------------------------------------------- | -------------------------- |
| `veo3.1-fast` | Choix par défaut pour la plupart des clips courts                           | Route Veo 3.1 plus rapide. |
| `veo3.1`      | À utiliser lorsque vous souhaitez spécifiquement le modèle Veo 3.1 standard | Route Veo 3.1 standard.    |

## Choisir un mode d'entrée

| Objectif       | Champs requis                        | Champs facultatifs |
| -------------- | ------------------------------------ | ------------------ |
| Text-to-video  | `model`, `prompt`                    | `seconds`, `size`  |
| Image-to-video | `model`, `prompt`, `input_reference` | `seconds`, `size`  |

## Définir la durée et la taille

Pour la route compatible OpenAI, utilisez `seconds` pour la durée et `size` pour la taille de sortie. Envoyez les valeurs comme champs de formulaire.

| Model ID      | `seconds`     | Par défaut               |
| ------------- | ------------- | ------------------------ |
| `veo3.1-fast` | `4`, `6`, `8` | `4` secondes, `1280x720` |
| `veo3.1`      | `4`, `6`, `8` | `4` secondes, `1280x720` |

Définissez `size` sur l'une des valeurs WxH ci-dessous.

| Palier de résolution | Format d'image | `size` (`WxH`) |
| -------------------- | -------------- | -------------- |
| `720p`               | `16:9`         | `1280x720`     |
|                      | `9:16`         | `720x1280`     |
| `1080p`              | `16:9`         | `1920x1080`    |
| `4K`                 | `16:9`         | `3840x2160`    |

## Flux de tâche

<Steps>
  <Step title="Créer la tâche">
    Envoyez la requête de formulaire multipart et stockez l'`id` retourné.
  </Step>

  <Step title="Interroger la tâche">
    Utilisez [Veo3 Retrieve](./retrieve) jusqu'à ce que `status` soit `completed`, `failed` ou `error`.
  </Step>

  <Step title="Télécharger le résultat">
    Lorsque la tâche est `completed`, téléchargez le fichier MP4 depuis la réponse de tâche terminée.
  </Step>
</Steps>


## OpenAPI

````yaml api/openapi/video/veo3/post-create.openapi.json POST /v1/videos
openapi: 3.1.0
info:
  title: Veo 3.1 Async Generation API
  version: 1.0.0
  description: >-
    Create an asynchronous Veo 3.1 video task through CometAPI. Save the
    returned id, poll GET /v1/videos/{task_id}, and download the completed MP4
    file.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/videos:
    post:
      summary: Create a Veo 3.1 video task
      description: >-
        Create a Veo 3.1 task through the OpenAI-compatible /v1/videos endpoint.
        Send fields as multipart/form-data.
      operationId: veo3_async_generation
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/VeoCreateRequest'
            examples:
              text_to_video:
                summary: Text-to-video
                value:
                  model: veo3.1-fast
                  prompt: A paper kite floats above a field.
                  seconds: '4'
                  size: 1280x720
      responses:
        '200':
          description: >-
            Task created. Store the returned id and poll GET
            /v1/videos/{task_id}.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VeoVideoTask'
              example:
                id: task_example
                task_id: task_example
                object: video
                model: veo3.1-fast
                status: queued
                progress: 0
                created_at: 1779938152
        '400':
          description: >-
            The request is missing a required field or contains a value that the
            selected model cannot use.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          label: Text-to-video
          source: |-
            curl https://api.cometapi.com/v1/videos \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -F model=veo3.1-fast \
              -F 'prompt=A paper kite floats above a field.' \
              -F seconds=4 \
              -F size=1280x720
        - lang: Python
          label: Text-to-video
          source: |
            import os
            import requests

            fields = [
                ("model", (None, "veo3.1-fast")),
                ("prompt", (None, "A paper kite floats above a field.")),
                ("seconds", (None, "4")),
                ("size", (None, "1280x720")),
            ]

            response = requests.post(
                "https://api.cometapi.com/v1/videos",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                files=fields,
                timeout=120,
            )

            response.raise_for_status()
            print(response.json())
        - lang: JavaScript
          label: Text-to-video
          source: |
            const form = new FormData();
            form.append("model", "veo3.1-fast");
            form.append("prompt", "A paper kite floats above a field.");
            form.append("seconds", "4");
            form.append("size", "1280x720");

            const response = await fetch("https://api.cometapi.com/v1/videos", {
              method: "POST",
              headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
              body: form,
            });

            const result = await response.json();
            console.log(result);
components:
  schemas:
    VeoCreateRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: >-
            Veo 3.1 model ID. Use veo3.1-fast for the default route or veo3.1
            when you specifically need the standard model.
          enum:
            - veo3.1-fast
            - veo3.1
          example: veo3.1-fast
        prompt:
          type: string
          description: Text prompt for the video job.
          example: A paper kite floats above a field.
        seconds:
          type: string
          description: >-
            Requested clip duration. Use 4, 6, or 8. Send the value as a form
            field string.
          enum:
            - '4'
            - '6'
            - '8'
          default: '4'
          example: '4'
        size:
          type: string
          description: >-
            Supported WxH size values: 1280x720, 720x1280, 1920x1080, 3840x2160.
            Default is 1280x720.
          example: 1280x720
        input_reference:
          type: string
          format: binary
          description: Optional first-frame image file for image-to-video.
      additionalProperties: true
    VeoVideoTask:
      type: object
      required:
        - id
        - object
        - model
        - status
        - progress
        - created_at
      properties:
        id:
          type: string
          description: Task ID. Use this value with retrieve and content endpoints.
          example: task_example
        task_id:
          type: string
          description: Compatibility alias for id when present.
          example: task_example
        object:
          type: string
          description: Object type. Video tasks return video.
          example: video
        model:
          type: string
          description: Model ID used for the task.
          example: veo3.1-fast
        status:
          type: string
          description: >-
            Task lifecycle status. Poll until the value is completed, failed, or
            error.
          enum:
            - queued
            - in_progress
            - completed
            - failed
            - error
          example: queued
        progress:
          type: integer
          minimum: 0
          maximum: 100
          description: Task progress as a coarse percentage.
          example: 0
        created_at:
          type: integer
          description: Task creation time as a Unix timestamp in seconds.
          example: 1779938152
        completed_at:
          type: integer
          description: >-
            Task completion time as a Unix timestamp in seconds. This field
            appears on completed tasks.
          example: 1779938219
        video_url:
          type: string
          description: Temporary video delivery URL. This field appears on completed tasks.
          example: <temporary-video-url>
        error:
          type: object
          description: Failure details. This field appears when the task fails.
          additionalProperties: true
      additionalProperties: true
    ErrorResponse:
      description: >-
        Error body returned when a request cannot be processed or the task
        fails.
      type: object
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer authentication. Use your CometAPI API key.

````