Clip Video
curl --request POST \
--url https://mavi-backend.memories.ai/serve/api/v2/video/clip \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_id": "re_657739295220518912"
}
'import requests
url = "https://mavi-backend.memories.ai/serve/api/v2/video/clip"
payload = { "asset_id": "re_657739295220518912" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({asset_id: 're_657739295220518912'})
};
fetch('https://mavi-backend.memories.ai/serve/api/v2/video/clip', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mavi-backend.memories.ai/serve/api/v2/video/clip",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'asset_id' => 're_657739295220518912'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mavi-backend.memories.ai/serve/api/v2/video/clip"
payload := strings.NewReader("{\n \"asset_id\": \"re_657739295220518912\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mavi-backend.memories.ai/serve/api/v2/video/clip")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"asset_id\": \"re_657739295220518912\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mavi-backend.memories.ai/serve/api/v2/video/clip")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"asset_id\": \"re_657739295220518912\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"task_id": "f432bc84bfd141d1b05c1d24af0abe6a"
},
"failed": false,
"success": true
}
{
"code": 200,
"message": "SUCCESS",
"data": {
"data": {
"data": [
{
"end": 46,
"start": 0
},
{
"end": 143,
"start": 47
},
{
"end": 214,
"start": 144
},
{
"end": 290,
"start": 215
},
{
"end": 466,
"start": 291
},
{
"end": 518,
"start": 467
},
{
"end": 605,
"start": 519
}
],
"exec_time": 7.277834177017212
},
"msg": "Scene detection completed successfully",
"success": true
},
"task_id": "a33f84793d0849f78825dc83c3b42671"
}
Video Editing Agent
Scene Detection
Detect scene boundaries in a video asset
POST
/
video
/
clip
Clip Video
curl --request POST \
--url https://mavi-backend.memories.ai/serve/api/v2/video/clip \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_id": "re_657739295220518912"
}
'import requests
url = "https://mavi-backend.memories.ai/serve/api/v2/video/clip"
payload = { "asset_id": "re_657739295220518912" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({asset_id: 're_657739295220518912'})
};
fetch('https://mavi-backend.memories.ai/serve/api/v2/video/clip', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mavi-backend.memories.ai/serve/api/v2/video/clip",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'asset_id' => 're_657739295220518912'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mavi-backend.memories.ai/serve/api/v2/video/clip"
payload := strings.NewReader("{\n \"asset_id\": \"re_657739295220518912\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mavi-backend.memories.ai/serve/api/v2/video/clip")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"asset_id\": \"re_657739295220518912\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mavi-backend.memories.ai/serve/api/v2/video/clip")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"asset_id\": \"re_657739295220518912\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"task_id": "f432bc84bfd141d1b05c1d24af0abe6a"
},
"failed": false,
"success": true
}
{
"code": 200,
"message": "SUCCESS",
"data": {
"data": {
"data": [
{
"end": 46,
"start": 0
},
{
"end": 143,
"start": 47
},
{
"end": 214,
"start": 144
},
{
"end": 290,
"start": 215
},
{
"end": 466,
"start": 291
},
{
"end": 518,
"start": 467
},
{
"end": 605,
"start": 519
}
],
"exec_time": 7.277834177017212
},
"msg": "Scene detection completed successfully",
"success": true
},
"task_id": "a33f84793d0849f78825dc83c3b42671"
}
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)This endpoint performs scene detection (automatic segmentation), not manual video clipping. It identifies natural scene transitions in the video and returns the frame ranges for each detected scene.
This is an async endpoint. You must configure a webhook URL in Webhooks Settings before calling this endpoint, otherwise you will not receive the processing results. See Webhooks Configuration Guide for details.
Pricing:
- $0.02/second of video
Code Examples
const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
const API_KEY = "sk-mavi-...";
const response = await fetch(`${BASE_URL}/video/clip`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': API_KEY
},
body: JSON.stringify({
asset_id: 're_657739295220518912'
})
});
const data = await response.json();
console.log(data);
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/clip`, {
asset_id: 're_657739295220518912'
}, {
headers: {
'Authorization': API_KEY
}
});
console.log(response.data);
import requests
BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2"
API_KEY = "sk-mavi-..."
HEADERS = {
"Authorization": f"{API_KEY}"
}
def video_clip(asset_id):
url = f"{BASE_URL}/video/clip"
data = {"asset_id": asset_id}
response = requests.post(url, json=data, headers=HEADERS)
return response.json()
# Usage example
result = video_clip("re_657739295220518912")
print(result)
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| asset_id | string | Yes | The video asset ID to detect scenes in |
Response
Returns task information for the video clip creation operation.{
"code": 200,
"msg": "success",
"data": {
"task_id": "f432bc84bfd141d1b05c1d24af0abe6a"
},
"failed": false,
"success": true
}
{
"code": 200,
"message": "SUCCESS",
"data": {
"data": {
"data": [
{
"end": 46,
"start": 0
},
{
"end": 143,
"start": 47
},
{
"end": 214,
"start": 144
},
{
"end": 290,
"start": 215
},
{
"end": 466,
"start": 291
},
{
"end": 518,
"start": 467
},
{
"end": 605,
"start": 519
}
],
"exec_time": 7.277834177017212
},
"msg": "Scene detection completed successfully",
"success": true
},
"task_id": "a33f84793d0849f78825dc83c3b42671"
}
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 clip creation task |
| success | boolean | Indicates whether the operation was successful |
| failed | boolean | Indicates whether the operation failed |
Callback Response Parameters
When the video clipping 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 scene segmentation results |
| data.data | object | Inner data object containing the clipping information |
| data.data.data | array | Array of scene segments with frame ranges |
| data.data.data[].start | integer | Starting frame number of the scene segment (based on original video FPS, convert to seconds: start / fps) |
| data.data.data[].end | integer | Ending frame number of the scene segment (based on original video FPS, convert to seconds: end / fps) |
| data.data.exec_time | number | Execution time for the clipping operation in seconds |
| data.msg | string | Detailed message about the clipping result |
| data.success | boolean | Indicates whether the clipping was successful |
| task_id | string | The task ID associated with this clipping request |
Understanding the Callback Response
The callback response contains an array of scene segments identified in the video, each with start and end frame numbers. Response Structure:callback_response
├── code: 200
├── message: "SUCCESS"
├── data
│ ├── data
│ │ ├── data: [array of scene segments]
│ │ │ └── [
│ │ │ {
│ │ │ start: 0,
│ │ │ end: 46
│ │ │ },
│ │ │ {
│ │ │ start: 47,
│ │ │ end: 143
│ │ │ },
│ │ │ ...
│ │ │ ]
│ │ └── exec_time: 7.277834177017212
│ ├── msg: "Scene detection completed successfully"
│ └── success: true
└── task_id: "a33f84793d0849f78825dc83c3b42671"
- Scene segments:
callback_response.data.data.data - Number of scenes detected:
callback_response.data.data.data.length - First scene start frame:
callback_response.data.data.data[0].start - First scene end frame:
callback_response.data.data.data[0].end - Execution time:
callback_response.data.data.exec_time - Success status:
callback_response.data.success - Task ID:
callback_response.task_id
start: The frame number where the scene begins (inclusive)end: The frame number where the scene ends (inclusive)- Frame numbers are 0-indexed and based on the original video’s FPS
- Scenes are automatically detected based on visual content changes
time_in_seconds = frame_number / fps
{start: 0, end: 46}→ 0s to 1.92s{start: 47, end: 143}→ 1.96s to 5.96s
Notes
- Video clipping is processed asynchronously
- Returns a task_id that can be used to track the clip creation progress
- Use the task_id to query the status and results of clip creation
- Original video remains unchanged
Authorizations
Body
application/json
The video asset ID to create a clip from
Example:
"re_657739295220518912"
Response
200 - application/json
Video clip creation initiated successfully
Response code indicating the result status
Example:
200
Response message describing the operation result
Example:
"success"
Response data object containing task information
Show child attributes
Show child attributes
Indicates whether the operation was successful
Example:
true
Indicates whether the operation failed
Example:
false
