Clips
Cut the section between two timestamps, as video or audio, without downloading the whole thing.
A clip is a download with a start and an end. It takes the same options, runs as the same kind of job, and returns the same shape — the file is just shorter.
From the CLI
ayt clip dQw4w9WgXcQ --start 1:30 --end 2:10 # 720p MP4
ayt clip dQw4w9WgXcQ --start 1:30 --end 2:10 -o chorus.mp4
ayt clip dQw4w9WgXcQ --start 90 --end 130 --audio # the same range as MP3
ayt clip dQw4w9WgXcQ --start 1m30s --end 2m10s --quality 1080p --url-only --jsonOver HTTP
curl -X POST "https://api.agentic-yt.crafter.run/v1/videos/dQw4w9WgXcQ/clip?wait=60" \
-H "Authorization: Bearer $AGENTIC_YT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"start":"1:30","end":"2:10"}'Body
| Field | Required | Notes |
|---|---|---|
start | yes | Where the clip begins. |
end | yes | Where it ends. Must be greater than start. |
kind, format, quality, audio_bitrate, use_account | no | Exactly as for downloads. |
Writing times
start and end each accept any of:
| Form | Example | Seconds |
|---|---|---|
| Number of seconds | 90 or 90.5 | 90, 90.5 |
| Clock | "1:30", "00:01:30.5", "1:02:03" | 90, 90.5, 3723 |
| Units | "1m30s", "90s", "1h2m3s" | 90, 90, 3723 |
Use whichever the agent already has — transcript segments and chapters give seconds, people say
"at one thirty". All of them are normalised to seconds before anything else happens, so
"1:30" and 90 are the same request and hit the same cache entry. The job's params shows
the normalised values.
In a clock, minutes and seconds must be below 60: "1:75" is rejected rather than guessed at.
An end past the end of the video is clamped to the video's length. A start at or past the end
fails the job with validation_failed.
Response
The same job object as a download, with type: "clip". The file name records the range:
{
"type": "clip",
"status": "succeeded",
"params": { "start": 90, "end": 130, "kind": "video", "format": "mp4", "quality": "720p", "audio_bitrate": 128 },
"result": {
"assets": [
{ "filename": "dQw4w9WgXcQ_90.000-130.000_720p.mp4", "mime": "video/mp4", "bytes": 4312345, "url": "https://…", "cache_hit": false }
]
}
}Finding the range
An agent rarely knows the timestamps up front. Three ways to get them:
- From the transcript.
ayt transcript <ref> --jsongives every segment'sstartandend. Find the sentences that matter, clip from the firststartto the lastend, and pad a second or two on each side. - From chapters.
ayt video <ref> --json→chapters[]already hasstartandendin seconds. - From a link. A URL with
t=orstart=resolves tostart_secondsviaayt resolve.
The long-video escape hatch
Videos over 4 hours cannot be downloaded whole — that is too_long, and
its hint points here. Clipping is how you get a section of one.
Errors to expect
validation_failed— a time that cannot be parsed, orendnot afterstart. The message names the field.- Everything a download can return.