---
title: "Edit a video based on a prompt.
This is an asynchronous operation that returns a request_id for polling."
method: POST
path: "/v1/videos/edits"
tags: ["v1"]
---

# Edit a video based on a prompt.
This is an asynchronous operation that returns a request_id for polling.

`POST /v1/videos/edits`

## Request body

- EditVideoRequest — Request for editing video for `/v1/videos/edits` endpoint
  - `model` string, nullable — Model to be used.
  - `output` VideoOutput — Output destination for generated video.
    - `upload_url` string, required — Signed URL to upload the generated video via HTTP PUT.
  - `prompt` string, required — Prompt for video editing.
  - `storage_options` StorageOptions — Configuration for storing generation output in the Files API. When provided in a generation request, the output is stored as a permanent file and a `file_output` reference is included in the response.
    - `expires_after` integer, nullable — Seconds from now until the file auto-expires. Maximum 2592000 (30 days). If omitted, the file does not expire.
    - `filename` string, required — Filename for the stored file.
    - `public_url` union — Accepts either `true` (create public URL with defaults) or a configuration object with explicit options. **Variant order matters for `#[serde(untagged)]`:** `Flag` must come before `Options` so that JSON `true`/`false` match `Flag` rather than falling through to the object variant. **Serialization note:** Proto→REST readback always constructs `Options(...)`, never `Flag`, so responses always emit the object form. `Flag` only appears on the deserialization (request) path.
      - boolean — `true` = create public URL with default options (no independent expiry). `false` = no public URL (equivalent to omitting the field).
      - PublicUrlOptions — Configuration for creating a public URL alongside file storage.
        - `expires_after` integer, nullable — Seconds from now until the public URL expires. Must be between 3600 (1 hour) and 2592000 (30 days). If omitted and the file has a TTL (`expires_after` on the file), the public URL inherits the file's expiry. If omitted and the file has no TTL, the public URL remains valid indefinitely until the file is deleted or the URL is explicitly revoked via `POST /v1/files/{file_id}/public-url/revoke`.
  - `user` string, nullable — A unique identifier representing your end-user.
  - `video` VideoUrl, required — Video input for editing and extension requests. Accepts a public URL, a base64-encoded data URL, or a file_id from the xAI Files API.
    - `file_id` string, nullable — File ID from the xAI Files API. Mutually exclusive with `url`. The file must be a video (e.g., MP4) and fully uploaded.
    - `url` string — URL of the video (public URL or base64-encoded data URL). The video must have the `.mp4` file extension and be encoded with `.mp4` supported codecs such as H.265, H.264, AV1, etc. Required when `file_id` is not set.

## Response `200`

Video editing started successfully

- StartDeferredResponse — Response for starting a deferred operation.
  - `request_id` string, required — A unique request ID to poll for the result.

## Other responses

- `400` — Bad request. The request is invalid or an invalid API key is provided.
- `422` — Unprocessable Entity. There are missing fields in the request body.

---

[API](https://skmtc.net/x/apis/xai-s-rest-api.md) · [All operations](https://skmtc.net/x/apis/xai-s-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/x/xai-s-rest-api/versions/8f6014272113/schema)
