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

# Create video

> Start a video generation job from a text prompt, optionally with frame images or reference images, videos and audio

Start generating a video from a text prompt, optionally with a first and last frame or with reference images, videos or audio. The endpoint returns the job straight away with `status: "queued"`. Generation takes minutes, so this response never contains the video. Poll [Retrieve video](https://docs.inworld.ai/api-reference/videoAPI/retrieve-video.md) until the job finishes, then download the MP4 from `output.videos[0].url`.

Send an `Idempotency-Key` header so a retry after a network error returns the original job while it is retained and has not been deleted. Generate the key once per video and store it before the first attempt. Use the same value for retries and after your program restarts. Deletion or automatic job removal releases the key, so a later create with it starts a new paid job. See [retries and idempotency](https://docs.inworld.ai/router/video-generation.md#retries-and-idempotency). Your account needs a payment method on file. See the [Video generation guide](https://docs.inworld.ai/router/video-generation.md) for models, parameters, limits and billing.

## API reference

**Endpoint:** `POST https://api.inworld.ai/v1/videos`

### Authorization

- `Authorization` (string; required) — Your [authentication](https://docs.inworld.ai/api-reference/introduction.md) credentials. For Basic authentication, populate `Basic $INWORLD_API_KEY`.

### Request body

Content type: `application/json`

- `model` (string; required) — The video model. Browse [inworld.ai/models](https://inworld.ai/models) for model IDs, or list them with the [List models API](https://docs.inworld.ai/api-reference/modelsAPI/modelservice/list-models.md) and `output_modalities=video`. See [Model compatibility](https://docs.inworld.ai/router/video-generation.md#model-compatibility) for each model's supported parameters.
- `prompt` (string; required) — What the video should show. It must contain more than whitespace; an empty or whitespace-only prompt returns `400`. Length limits depend on the model; see [Model compatibility](https://docs.inworld.ai/router/video-generation.md#model-compatibility).
- `seconds` (integer) — Clip length in whole seconds. The allowed values and the default depend on the model: they are `supportedSeconds` and `defaultSeconds` in its `spec.video`; see [Model compatibility](https://docs.inworld.ai/router/video-generation.md#model-compatibility).
- `resolution` (string) — Output resolution, case-insensitive. The allowed values and the default depend on the model; see [Model compatibility](https://docs.inworld.ai/router/video-generation.md#model-compatibility).
- `aspect_ratio` (string) — Frame shape. The allowed values and the default depend on the model; see [Model compatibility](https://docs.inworld.ai/router/video-generation.md#model-compatibility). With `frame_images`, leave it out or set `adaptive`: the video takes its shape from the first frame.
- `frame_images` (object[]) — A first frame, and optionally a last frame, for the video. At most one of each. Not every model accepts a last frame. Cannot be combined with `input_references`. For each model's frame support, see [Model compatibility](https://docs.inworld.ai/router/image-to-video.md#model-compatibility).
  - `type` (enum<string>; required; options: "image_url")
  - `image_url` (object; required)
    - `url` (string; required) — An HTTPS URL on a public host, up to 4,096 bytes. Base64 `data:` URLs are rejected. The model provider downloads the image when generation starts; we recommend keeping a signed URL valid for at least an hour. The API doesn't check this, and a URL the provider can't use fails the job with `generation_failed`.
  - `frame_type` (enum<string>; required; options: "first_frame", "last_frame") — Where the image goes in the video. A `last_frame` needs a `first_frame`.
- `input_references` (oneOf[]) — Images, videos or audio clips that guide the video without fixing any frame. Each model sets how many of each type it accepts, and not every model accepts video or audio. Cannot be combined with `frame_images`. For each model's limits, see [Model compatibility](https://docs.inworld.ai/router/reference-to-video.md#model-compatibility).
  - `type` (enum<string>; required; options: "image_url", "video_url", "audio_url") — The kind of reference, which names the field to set.
  - `image_url` (object) — The image.
    - `url` (string; required) — An HTTPS URL on a public host, up to 4,096 bytes. Base64 `data:` URLs are rejected. The model provider downloads the image when generation starts; we recommend keeping a signed URL valid for at least an hour. The API doesn't check this, and a URL the provider can't use fails the job with `generation_failed`.
  - `video_url` (object) — The video. It must be an MP4 or MOV file of up to 100 MB; the API downloads it when you create the job.
    - `url` (string; required) — An HTTPS URL on a public host, up to 4,096 bytes.
  - `audio_url` (object) — The audio clip. It can be sent on its own, without an image or video reference, unless the model lists `requiredOneOf` in its `spec.video.inputReferences`: then the request also needs an image or video reference. The API doesn't download audio clips, so it doesn't check their format or length when you create the job.
    - `url` (string; required) — An HTTPS URL on a public host, up to 4,096 bytes.

#### Request example

```json
{
  "model": "alibaba/wan-3.0",
  "prompt": "A red fox trots across a snowy meadow at sunrise, slow tracking shot, soft golden light",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}
```

### Response

Status: `200`. Content type: `application/json`.

- `id` (string; required) — The job id.
- `object` (enum<string>; required; options: "video")
- `model` (string; required)
- `status` (enum<string>; required; options: "queued", "in_progress", "completed", "failed", "cancelled") — `queued`: accepted; waiting for or being submitted for generation, so cancellation may already be unavailable. `in_progress`: generating. `completed`: generation succeeded; download available until `expires_at`. `failed`: see `error`. `cancelled`: cancelled before generation started. The last three are terminal.
- `created_at` (integer; required) — When the job was created, in Unix seconds.
- `completed_at` (integer) — When the video finished, in Unix seconds. Present once `status` is `completed`.
- `expires_at` (integer) — Until when the video can be downloaded, in Unix seconds: 7 days after it finished. After it, the job is no longer listed. Present only when `status` is `completed`.
- `seconds` (integer; required) — The requested clip length, with the model's default filled in.
- `resolution` (string; required) — The requested resolution, with the model's default filled in.
- `aspect_ratio` (string; required) — The requested aspect ratio, with the model's default filled in. `adaptive` for a job with `frame_images`, whose video takes the first frame's shape.
- `operation` (string) — The job's [long-running operation](https://google.aip.dev/151). Poll it with `GET https://api.inworld.ai/lro/v1alpha/{operation}` as an alternative to retrieving the job. The operation reports progress and the outcome but never the download link. See [Poll the operation instead](https://docs.inworld.ai/router/video-generation.md#poll-the-operation-instead).
- `error` (object) — Why the job failed. Present only when `status` is `failed`.
  - `code` (enum<string>; options: "content_filtered", "invalid_request", "generation_failed", "generation_timeout") — `content_filtered`: the prompt or the generated video was blocked by the model provider's content policy. `invalid_request`: the model provider rejected the request. `generation_failed`: generation failed for another reason. `generation_timeout`: generation did not finish in time.
  - `message` (string)
- `output` (object) — The finished video. Returned only by [Retrieve video](https://docs.inworld.ai/api-reference/videoAPI/retrieve-video.md), only while `status` is `completed` and before `expires_at`.
  - `videos` (object[])
    - `index` (integer)
    - `content_type` (string)
    - `bytes` (integer) — File size in bytes.
    - `url` (string) — A signed HTTPS link to the MP4. Anyone with the link can download the file until `url_expires_at`, so treat it like a secret.
    - `url_expires_at` (integer) — When `url` stops working, in Unix seconds: up to an hour after the request, and never after the job's `expires_at`.

### Response examples

#### 200: default_response

```json
{
  "id": "video_8f14e45fceea167a5a36dedd4bea2543",
  "object": "video",
  "model": "alibaba/wan-3.0",
  "status": "queued",
  "created_at": 1790000000,
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "operation": "workspaces/my-workspace/videoGenerationJobs/video_8f14e45fceea167a5a36dedd4bea2543/operations/1790000000000-a1b2c3"
}
```

#### 400: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

#### 401: default_response

```json
"Unauthorized"
```

#### 403: default_response

```json
"Forbidden"
```

#### 409: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

#### 429: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

#### 500: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

#### 503: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

### Code examples

#### cURL

```bash
# Generate one key per video and reuse it for retries.
# Deletion or automatic job removal releases the key.
# export VIDEO_REQUEST_KEY="$(uuidgen)"
curl -X POST 'https://api.inworld.ai/v1/videos' \
  -H "Authorization: Basic $INWORLD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $VIDEO_REQUEST_KEY" \
  -d '{
    "model": "alibaba/wan-3.0",
    "prompt": "A red fox trots across a snowy meadow at sunrise, slow tracking shot, soft golden light",
    "seconds": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }'
```

#### Python

```python
import os
import requests

# Keep one key per video outside the process for retries after a timeout.
# Deletion or automatic job removal releases the key.
request_key = os.environ["VIDEO_REQUEST_KEY"]

response = requests.post(
    "https://api.inworld.ai/v1/videos",
    headers={
        "Authorization": f"Basic {os.environ['INWORLD_API_KEY']}",
        "Idempotency-Key": request_key,
    },
    json={
        "model": "alibaba/wan-3.0",
        "prompt": "A red fox trots across a snowy meadow at sunrise, slow tracking shot, soft golden light",
        "seconds": 5,
        "resolution": "720p",
        "aspect_ratio": "16:9",
    },
    timeout=30,
)
response.raise_for_status()
video = response.json()
print(video["id"], video["status"])
```

#### JavaScript

```javascript
const options = {method: 'POST', headers: {"Authorization":"<api_key>","Content-Type":"application/json"}, body: JSON.stringify({
  "model": "alibaba/wan-3.0",
  "prompt": "A red fox trots across a snowy meadow at sunrise, slow tracking shot, soft golden light",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9"
})};

fetch('https://api.inworld.ai/v1/videos', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```

#### Node

```javascript
// Keep one key per video outside the process for retries after a timeout.
// Deletion or automatic job removal releases the key.
const requestKey = process.env.VIDEO_REQUEST_KEY;

const response = await fetch('https://api.inworld.ai/v1/videos', {
  method: 'POST',
  headers: {
    Authorization: `Basic ${process.env.INWORLD_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': requestKey,
  },
  body: JSON.stringify({
    model: 'alibaba/wan-3.0',
    prompt: 'A red fox trots across a snowy meadow at sunrise, slow tracking shot, soft golden light',
    seconds: 5,
    resolution: '720p',
    aspect_ratio: '16:9',
  }),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const video = await response.json();
console.log(video.id, video.status);
```
