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

# Edit Video

> Edit and compose videos with AI-powered instructions

<Info>
  **Product**: Visual Agents
  **Use case**: Managed endpoints powering Memories.ai's open-source video search and editing agents (queries, video clipping/editing, screenplay extraction)
  **Host**: `https://mavi-backend.memories.ai/serve/api/v2`
  **Auth**: `Authorization: sk-mavi-...` (no `Bearer` prefix)
</Info>

This endpoint allows you to edit videos by combining multiple assets with custom orientation and AI-guided editing instructions.

<Warning>
  This is an **async endpoint**. You must configure a webhook URL in [Webhooks Settings](https://api-platform.memories.ai/webhooks) before calling this endpoint, otherwise you will not receive the processing results. See [Webhooks Configuration Guide](/visual-intelligence/getting-started/webhooks) for details.
</Warning>

<Note>
  **Pricing:**

  * \$0.15/min of video
</Note>

### Code Examples

<CodeGroup>
  ```javascript fetch theme={null}
  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  const response = await fetch(`${BASE_URL}/video/edit`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': API_KEY
    },
    body: JSON.stringify({
      asset_ids: ['re_657739295220518912', 're_657739295220518913'],
      orientation: 'portrait',
      user_prompt: 'Create a dynamic montage with smooth transitions'
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```javascript axios theme={null}
  import axios from 'axios';

  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  const response = await axios.post(`${BASE_URL}/video/edit`, {
    asset_ids: ['re_657739295220518912', 're_657739295220518913'],
    orientation: 'portrait',
    user_prompt: 'Create a dynamic montage with smooth transitions'
  }, {
    headers: {
      'Authorization': API_KEY
    }
  });

  console.log(response.data);
  ```

  ```python Python theme={null}
  import requests

  BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2"
  API_KEY = "sk-mavi-..."
  HEADERS = {
      "Authorization": f"{API_KEY}"
  }

  def video_edit(asset_ids, orientation, user_prompt):
      url = f"{BASE_URL}/video/edit"
      data = {
          "asset_ids": asset_ids,
          "orientation": orientation,
          "user_prompt": user_prompt
      }
      resp = requests.post(url, headers=HEADERS, json=data)
      return resp.json()

  # Usage example
  asset_ids = ["re_657739295220518912", "re_657739295220518913"]
  result = video_edit(
      asset_ids=asset_ids,
      orientation="portrait",
      user_prompt="Create a dynamic montage with smooth transitions"
  )
  print(result)
  ```
</CodeGroup>

### Request Body

| Field        | Type           | Required | Description                                                                                                  |
| ------------ | -------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| asset\_ids   | array\[string] | Yes      | Array of video asset IDs to combine and edit                                                                 |
| orientation  | string         | Yes      | Output video orientation: `"landscape"` or `"portrait"`                                                      |
| user\_prompt | string         | Yes      | AI editing instructions describing desired output (max 500 characters, English recommended for best results) |

<Note>
  * **Prompt language**: English is recommended for best editing results. Other languages may work but are not guaranteed.
  * **Prompt length**: Keep prompts under 500 characters for optimal performance.
  * **Output duration**: The output video duration is determined by the AI based on the input assets and prompt — it cannot be manually specified.
</Note>

### Response

Returns task information for the video editing operation.

<ResponseExample>
  ```json Response theme={null}
  {
    "code": 200,
    "msg": "success",
    "data": {
      "task_id": "f432bc84bfd141d1b05c1d24af0abe6a"
    },
    "failed": false,
    "success": true
  }
  ```

  ```json Callback Response theme={null}
  {
    "code": 200,
    "message": "SUCCESS",
    "data": {
      "asset_id": "re_666942269501235201",
      "create_time": "1768470628237",
      "extension": "mp4",
      "file_size": 62217261,
      "modify_time": "1768470628237",
      "original_filename": "final_video",
      "upload_status": "SUCCESS"
    },
    "task_id": "b5b93c1ff93e460aaea67d328ab463f0"
  }
  ```
</ResponseExample>

### Response Parameters

| Parameter     | Type    | Description                                      |
| ------------- | ------- | ------------------------------------------------ |
| code          | string  | Response code indicating the result status       |
| msg           | string  | Response message describing the operation result |
| data          | object  | Response data object containing task information |
| data.task\_id | string  | Unique identifier of the video editing task      |
| success       | boolean | Indicates whether the operation was successful   |
| failed        | boolean | Indicates whether the operation failed           |

### Callback Response Parameters

When the video editing is complete, a callback will be sent to your configured webhook URL.

| Parameter               | Type    | Description                                                  |
| ----------------------- | ------- | ------------------------------------------------------------ |
| code                    | string  | Response code (200 indicates success)                        |
| message                 | string  | Status message (e.g., "SUCCESS")                             |
| data                    | object  | Response data object containing the edited video information |
| data.asset\_id          | string  | Unique asset ID for the edited video                         |
| data.create\_time       | string  | Creation timestamp in milliseconds                           |
| data.extension          | string  | File extension of the edited video (e.g., "mp4")             |
| data.file\_size         | integer | Size of the edited video in bytes                            |
| data.modify\_time       | string  | Last modification timestamp in milliseconds                  |
| data.original\_filename | string  | Filename of the edited video (e.g., "final\_video")          |
| data.upload\_status     | string  | Upload status of the edited video (e.g., "SUCCESS")          |
| task\_id                | string  | The task ID associated with this video editing request       |

### Understanding the Callback Response

The callback response contains metadata about the final edited video created from combining and editing the input assets.

**Response Structure:**

```
callback_response
├── code: 200
├── message: "SUCCESS"
├── data
│   ├── asset_id: "re_666942269501235201"
│   ├── create_time: "1768470628237"
│   ├── extension: "mp4"
│   ├── file_size: 62217261
│   ├── modify_time: "1768470628237"
│   ├── original_filename: "final_video"
│   └── upload_status: "SUCCESS"
└── task_id: "b5b93c1ff93e460aaea67d328ab463f0"
```

**How to access the data:**

* Edited video asset ID: `callback_response.data.asset_id`
* Video file size: `callback_response.data.file_size`
* Video filename: `callback_response.data.original_filename`
* Upload status: `callback_response.data.upload_status`
* Creation timestamp: `callback_response.data.create_time`
* Task ID: `callback_response.task_id`

### Prompt Examples

The `user_prompt` parameter guides the AI editing process. Here are some effective prompt examples:

| Use Case           | Example Prompt                                                              |
| ------------------ | --------------------------------------------------------------------------- |
| **Montage**        | `"Create a dynamic montage with smooth transitions"`                        |
| **Highlight Reel** | `"Create a 30-second highlight reel focusing on the most exciting moments"` |
| **Summary**        | `"Compile a brief summary video with key scenes from all clips"`            |
| **Style**          | `"Edit with fast-paced cuts and energetic transitions for social media"`    |
| **Narrative**      | `"Arrange clips in chronological order with fade transitions"`              |

### Notes

* Video editing is processed asynchronously using AI
* Returns a task\_id that can be used to track the editing progress
* Use the task\_id to query the status and results of video editing
* Supports combining multiple video assets
* Orientation options: `landscape` (16:9) or `portrait` (9:16)
* User prompt guides AI editing decisions — be specific about the desired style, pacing, and transitions
* Processing time varies based on complexity and video length


## OpenAPI

````yaml POST /video/edit
openapi: 3.1.0
info:
  title: MAVI API Reference
  description: REST APIs for memory management, search, and entity operations
  version: v1.0.1
servers:
  - url: https://mavi-backend.memories.ai/serve/api/v2
security:
  - ApiKeyAuth: []
paths:
  /video/edit:
    post:
      summary: Edit Video
      operationId: video_edit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                asset_ids:
                  type: array
                  items:
                    type: string
                  description: Array of video asset IDs to combine and edit
                  example:
                    - re_657739295220518912
                    - re_657739295220518913
                orientation:
                  type: string
                  enum:
                    - landscape
                    - portrait
                  description: Output video orientation
                  example: portrait
                user_prompt:
                  type: string
                  description: AI editing instructions describing desired output
                  example: Create a dynamic montage with smooth transitions
              required:
                - asset_ids
                - orientation
                - user_prompt
      responses:
        '200':
          description: Video editing initiated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: 200
                    description: Response code indicating the result status
                  msg:
                    type: string
                    example: success
                    description: Response message describing the operation result
                  data:
                    type: object
                    properties:
                      task_id:
                        type: string
                        example: f432bc84bfd141d1b05c1d24af0abe6a
                        description: Unique identifier of the video editing task
                    description: Response data object containing task information
                  success:
                    type: boolean
                    example: true
                    description: Indicates whether the operation was successful
                  failed:
                    type: boolean
                    example: false
                    description: Indicates whether the operation failed
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````