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

# Veo 3 API quickstart: Generate videos with CometAPI

> Create a Veo video task with CometAPI, poll task status, and store completed video output with curl, Python, or Node.js.

## What you will build

You will create one Veo video task with multipart form data, store the returned task ID, poll the retrieve endpoint, and save the final asset URL or file in your own system.

## Prerequisites

* A CometAPI API key stored in `COMETAPI_KEY`
* Python 3.10+ with `requests`, or Node.js 18+
* A server-side job runner for polling

## API key, base URL, authentication

Create Veo tasks with:

```text theme={null}
POST https://api.cometapi.com/v1/videos
```

Poll Veo task status with:

```text theme={null}
GET https://api.cometapi.com/v1/videos/<task_id>
```

Authenticate with a Bearer token:

```text theme={null}
Authorization: Bearer $COMETAPI_KEY
```

## Code examples

Use the tabs below for copyable examples in cURL, Python, and Node.js.

<CodeGroup>
  ```bash cURL theme={null}
  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

  curl "https://api.cometapi.com/v1/videos/<task_id>" \
    -H "Authorization: Bearer $COMETAPI_KEY"
  ```

  ```python Python theme={null}
  import os
  import time

  import requests

  api_key = os.environ["COMETAPI_KEY"]
  headers = {"Authorization": f"Bearer {api_key}"}

  create_response = requests.post(
      "https://api.cometapi.com/v1/videos",
      headers=headers,
      files={
          "model": (None, "veo3.1-fast"),
          "prompt": (None, "A paper kite floats above a field."),
          "seconds": (None, "4"),
          "size": (None, "1280x720"),
      },
      timeout=60,
  )
  create_response.raise_for_status()
  task_id = create_response.json()["id"]

  for _ in range(60):
      retrieve_response = requests.get(
          f"https://api.cometapi.com/v1/videos/{task_id}",
          headers=headers,
          timeout=30,
      )
      retrieve_response.raise_for_status()
      task = retrieve_response.json()
      if task["status"] in {"completed", "failed", "error"}:
          print(task)
          break
      time.sleep(5)
  else:
      raise TimeoutError("Veo task did not finish in time")
  ```

  ```javascript Node.js theme={null}
  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 createResponse = await fetch("https://api.cometapi.com/v1/videos", {
    method: "POST",
    headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
    body: form,
  });

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

  const { id } = await createResponse.json();

  for (let attempt = 0; attempt < 60; attempt += 1) {
    const retrieveResponse = await fetch(`https://api.cometapi.com/v1/videos/${id}`, {
      headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
    });

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

    const task = await retrieveResponse.json();
    if (["completed", "failed", "error"].includes(task.status)) {
      console.log(task);
      break;
    }
    await new Promise((resolve) => setTimeout(resolve, 5000));
  }
  ```
</CodeGroup>

## Flow explanation

Veo video generation is asynchronous. The create endpoint accepts multipart form data and returns a task ID immediately. Poll the retrieve endpoint until the task reaches a terminal status, then persist the final video URL or file details from the completed response.

Use short durations and the smallest useful size for first tests. Move completed assets into your own storage when your application needs retention.

## Common parameters

| Parameter         | Use                                                             |
| ----------------- | --------------------------------------------------------------- |
| `model`           | Veo model ID. The API reference example uses `veo3.1-fast`.     |
| `prompt`          | Text prompt for the video job.                                  |
| `seconds`         | Duration form field. The reference documents `4`, `6`, and `8`. |
| `size`            | Exact `WxH` size, such as `1280x720`.                           |
| `input_reference` | Optional first-frame image file for image-to-video.             |

## Troubleshooting / FAQ

<AccordionGroup>
  <Accordion title="The request fails with a content type problem">
    Send multipart form data. Do not send Veo create requests as JSON.
  </Accordion>

  <Accordion title="Polling takes longer than expected">
    Use a bounded polling loop, store the task ID, and surface a pending state in your application instead of blocking a web request.
  </Accordion>

  <Accordion title="How should I control cost">
    Start with a short duration, one task, and the smallest acceptable size. Use account quotas and cost estimation before scaling task count.
  </Accordion>
</AccordionGroup>

## Next steps

* Read the [Create a Veo 3 video API reference](/api/video/veo3/create).
* Poll with [Retrieve a Veo 3 video](/api/video/veo3/retrieve).
* Find Veo video models in [Models](/overview/models).
* Review [Use polling and webhooks for video generation](/guides/webhook-and-polling-for-video-generation).
* Estimate task cost with [Estimate request cost before calling a model](/guides/how-to-estimate-cost-before-calling-a-model).
