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

# Opprett en Veo 3-video

> Generer Veo 3.1-videoer asynkront via CometAPI med POST /v1/videos, poll deretter oppgaven og last ned den fullførte MP4-filen.

Opprett en Veo 3.1-video fra tekst eller et bilde. API-et returnerer umiddelbart en oppgave-ID. Lagre den returnerte `id` for å polle oppgaven og laste ned den fullførte videoen.

`POST /v1/videos` bruker `multipart/form-data`. Send kontroller som skjemafelt og et bilde som et `input_reference`-filfelt.

## Velg en modell

| Modell-ID     | Når du bør bruke den                                  | Merknader              |
| ------------- | ----------------------------------------------------- | ---------------------- |
| `veo3.1-fast` | Standardvalg for de fleste korte klipp                | Raskere Veo 3.1-rute.  |
| `veo3.1`      | Bruk når du spesifikt ønsker standardmodellen Veo 3.1 | Standard Veo 3.1-rute. |

## Velg en inndatamodus

| Mål             | Obligatoriske felt                               | Valgfrie felt     |
| --------------- | ------------------------------------------------ | ----------------- |
| Tekst-til-video | `model`, `prompt`                                | `seconds`, `size` |
| Bilde-til-video | `model`, `prompt`, én `input_reference`-bildefil | `seconds`, `size` |

For å animere et bilde laster du opp én fil via `input_reference` og bruker feltet én gang. Bildet angir åpningsbildet; `prompt` beskriver bevegelsen og kamerafunksjonen som følger.

## Angi varighet og størrelse

For denne OpenAI-kompatible ruten angir du varigheten med en eksplisitt heltallsverdi for `seconds` og utdataformatet med `size`. Send begge verdiene som skjemafelt.

| Modell-ID     | `seconds`     | Standard                 |
| ------------- | ------------- | ------------------------ |
| `veo3.1-fast` | `4`, `6`, `8` | `4` sekunder, `1280x720` |
| `veo3.1`      | `4`, `6`, `8` | `4` sekunder, `1280x720` |

Angi `size` til én av WxH-verdiene nedenfor.

| Oppløsningsnivå | Bildeformat | `size` (`WxH`) |
| --------------- | ----------- | -------------- |
| `720p`          | `16:9`      | `1280x720`     |
|                 | `9:16`      | `720x1280`     |
| `1080p`         | `16:9`      | `1920x1080`    |
| `4K`            | `16:9`      | `3840x2160`    |

## Oppgaveflyt

<Steps>
  <Step title="Opprett oppgaven">
    Send forespørselen med multipart-skjemaet og lagre den returnerte `id`.
  </Step>

  <Step title="Poll oppgaven">
    Bruk [Veo3 Retrieve](./retrieve) til `status` er `completed`, `failed` eller `error`.
  </Step>

  <Step title="Last ned resultatet">
    Når oppgaven er `completed`, laster du ned MP4-filen fra svaret for den fullførte oppgaven.
  </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
              uploaded_image_to_video:
                summary: Image-to-video from an uploaded image
                value:
                  model: veo3.1-fast
                  prompt: Start from this image and slowly pan right.
                  seconds: 4
                  size: 1280x720
                  input_reference: '@/path/to/reference.png'
      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.
        '401':
          description: The API key is missing or invalid.
      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);
        - lang: Shell
          label: Image-to-video from an uploaded image
          source: |-
            curl https://api.cometapi.com/v1/videos \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              --form-string model=veo3.1-fast \
              --form-string 'prompt=Start from this image and slowly pan right.' \
              --form-string seconds=4 \
              --form-string size=1280x720 \
              --form 'input_reference=@/path/to/reference.png;type=image/png'
        - lang: Python
          label: Image-to-video from an uploaded image
          source: |
            import os

            import requests

            prompt = (
                "Start from this image and slowly pan right."
            )

            with open("/path/to/reference.png", "rb") as image_1:
                fields = [
                    ("model", (None, "veo3.1-fast")),
                    ("prompt", (None, prompt)),
                    ("seconds", (None, "4")),
                    ("size", (None, "1280x720")),
                    ("input_reference", ("reference.png", image_1, "image/png")),
                ]

                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: Image-to-video from an uploaded image
          source: >
            import { readFile } from "node:fs/promises";


            const image_1 = await readFile("/path/to/reference.png");


            const form = new FormData();

            form.append("model", "veo3.1-fast");

            form.append("prompt", "Start from this image and slowly pan
            right.");

            form.append("seconds", "4");

            form.append("size", "1280x720");

            form.append(
              "input_reference",
              new Blob([image_1], { type: "image/png" }),
              "reference.png",
            );


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


            if (!response.ok) {
              throw new Error(await response.text());
            }


            console.log(await response.json());
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: integer
          description: >-
            Requested clip duration in whole seconds. Send 4, 6, or 8 as a form
            field.
          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: >-
            One image file that sets the opening frame for image-to-video. Send
            input_reference once with one file. Use prompt to describe the
            motion and camera behavior that follow.
      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
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer authentication. Use your CometAPI API key.

````