Skip to Content
agentic-yt

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 --json

Over 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

FieldRequiredNotes
startyesWhere the clip begins.
endyesWhere it ends. Must be greater than start.
kind, format, quality, audio_bitrate, use_accountnoExactly as for downloads.

Writing times

start and end each accept any of:

FormExampleSeconds
Number of seconds90 or 90.590, 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> --json gives every segment's start and end. Find the sentences that matter, clip from the first start to the last end, and pad a second or two on each side.
  • From chapters. ayt video <ref> --json → chapters[] already has start and end in seconds.
  • From a link. A URL with t= or start= resolves to start_seconds via ayt 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, or end not after start. The message names the field.
  • Everything a download can return.

On this page