Before you start
Connect your bucket once: Amazon S3, Cloudflare R2, Backblaze B2, DigitalOcean Spaces or Supabase Storage. Save it on the dashboard’s S3 Storage page or with one API call (see Deliver to your bucket). Every import withstore: true then lands there.
Create your key on the API key page (it’s shown once) and keep it on the machine that runs the script.
The code
build_dataset.py
What you get
The audio is in your bucket underdatasets/<DATASET>/audio/<clip id>.mp3, and <DATASET>.jsonl has one line per clip:
mediaUrl: that link expires after 7 days, and the copy in your bucket is yours.
How it works
includeVideo: false downloads only the audio, so you pay for the audio stream, not the video. The file arrives as MP3.
transcriptMode: "ai" runs speech-to-text on every clip, so every example gets the same kind of sentence-level segments. If you’d rather use the platform’s captions where they exist (cheaper, but line-by-line timing and sometimes auto-generated), send transcriptMode: "auto" (the default) instead: captions when the clip has them, speech-to-text when it doesn’t. See Transcripts.
maxCostDollars caps each link, the download and the transcript together. A link that would go over fails with MAX_COST_EXCEEDED and isn’t charged.
storageFilename names the file after a hash of the link. Without it the file is named after the media title, and two clips with the same title would land on the same key.
Each link is sent once. The link is the key in SQLite, so re-running the script never imports a clip twice, and failed links stay recorded with their error code.
Errors to handle
Every error has a
documentationUrl with the fix. See Error handling.
In production
Thousands of links? RaiseMAX_NEW_PER_RUN slowly: a 429 just moves the rest to the next run. Pass a webhookUrl with each import to save results as they finish instead of polling, and keep the status check as a fallback. See Webhooks.
Need video too, for a video model or evals? Drop includeVideo: false and set videoQuality (for example "480p"). See POST /import for the quality options.
A 10-minute talk costs about $0.12 here: around $0.02 for the audio download and $0.10 for speech-to-text. Status checks are free. Try it free, no card required. See Pricing & credits.