For agents

Connect an agent.

Montage is built to be driven by software. One API key and a handful of HTTP calls take a beat from a file on disk to a published YouTube video.

What your agent can do

An API key acts as you. Anything the web app can do, an agent holding that key can do too:

  • Check your subscription, credit balance, and connected channels
  • Upload audio
  • Render a video from a YouTube segment, an uploaded clip, or an image
  • Track render progress and retry failures
  • List your finished videos
  • Publish to YouTube — full video, a vertical Short, or both
An API key can publish to your channel
Treat a Montage key like a password. It can spend your credits and upload videos to any YouTube channel you have connected. Give it only to agents you run yourself, and revoke it the moment you suspect it leaked.

Step 1 — Mint an API key

01
Open your API keys page

Go to usemontage.com/account/api-keys — also in the avatar menu at the top-right of any page, under API Keys. You need to be signed in with your browser.

02
Create a key

Give it a name you will recognize later (the agent it belongs to, for example) and optionally an expiry of 30, 90, or 365 days. Keys never expire by default.

03
Copy it once

The key is shown exactly once, at creation. It looks like mk_live_…. We store only a hash, so if you lose it there is no way to recover it — revoke it and mint another.

04
Put it in the environment, not in a prompt

Your agent should read it from an environment variable so it never ends up in chat history, logs, or a repository.

~/.zshrc or your agent's env file
export MONTAGE_API_KEY="mk_live_..."

Verify the key works before you wire anything up:

verify
curl -sS https://www.usemontage.com/api/me \
  -H "Authorization: Bearer $MONTAGE_API_KEY"

A 200 with your email, credit balance, and channel list means you are connected. A 401 means the key is wrong, revoked, or expired.

Step 2 — Pick how your agent talks to Montage

Three options, easiest first. They all use the same key.

Option A — The CLI (recommended)

A single Node file, no dependencies, no install step. It wraps the whole pipeline including polling, backoff, and resumable state — which is precisely the part agents get wrong when they call the API by hand.

install
mkdir -p ~/.montage
curl -sS https://www.usemontage.com/montage-cli.mjs -o ~/.montage/montage-cli.mjs
node ~/.montage/montage-cli.mjs preflight

preflight exits non-zero if your subscription, credits, or YouTube connection are not ready — a good first command for an agent to run. One beat, start to published, is a single call:

full pipeline
node ~/.montage/montage-cli.mjs run \
  --audio-file ./beat.mp3 \
  --youtube "https://www.youtube.com/watch?v=VIDEO_ID" \
  --start 30 --end 150 \
  --title "Dark Trap Type Beat - \"Nightshift\"" \
  --description "Free for non-profit use." \
  --tags "type beat,trap,free beat" \
  --privacy public

Every command prints exactly one JSON object on stdout, so an agent can parse the result without scraping prose. Exit codes are 0 ok, 1 API error, 2 bad arguments, 3 timeout.

Resumable by design
run writes a state file after each step. If the agent crashes or the poll times out, re-running the same command picks up where it left off instead of rendering — and billing — the beat a second time.

Option B — Raw HTTP

Any language, any framework. Send Authorization: Bearer mk_live_… to https://www.usemontage.com and follow the steps below. The full endpoint list is in the API reference.

Option C — OpenAPI / tool-calling frameworks

If your framework generates tools from a spec, point it at usemontage.com/openapi.json. It describes every documented endpoint, with a bearer security scheme your framework can fill from MONTAGE_API_KEY.

Step 3 — Brief your agent

Agents do not need this page — they need the rules. Paste one of these blocks into your agent’s system prompt, skill file, or CLAUDE.md. Both assume MONTAGE_API_KEY is already in the environment.

If your agent uses the CLI

paste into your agent's instructions
Montage CLI is at ~/.montage/montage-cli.mjs (Node 20+, no dependencies).
MONTAGE_API_KEY is already set in the environment — never print its value.

Every command prints exactly one JSON object on stdout; that JSON is the source
of truth. Progress notes go to stderr.
Exit codes: 0 ok | 1 API error | 2 bad arguments | 3 timeout.

Typical run (renders and publishes, resumable):
  node ~/.montage/montage-cli.mjs run \
    --audio-file ./beat.mp3 \
    --youtube "https://www.youtube.com/watch?v=VIDEO_ID" \
    --start 30 --end 150 \
    --title "Title" --privacy public

The run command writes a state file after each step and resumes from it, so
re-running after a crash or timeout never renders or bills the same beat twice.

Other commands: preflight | channels | upload <file> | create | job <id> |
wait-job <id> | retry-job <id> | publish | publish-status | wait-publish.
Run with --help for full flags.

On exit code 1 with a 402 or 403 status, STOP and report to the human.

If your agent calls the API directly

paste into your agent's instructions
You have access to Montage (https://www.usemontage.com), which renders a video
from an audio track plus a background clip and publishes it to YouTube.

Auth: every request needs the header  Authorization: Bearer $MONTAGE_API_KEY
Base URL: https://www.usemontage.com

Never print, echo, or log the value of MONTAGE_API_KEY.

Workflow — do these in order:
1. GET /api/me
   Confirm subscription.status is "active" or "trialing", credits.balance >=
   credits.costPerVideo, and youtubeChannels is non-empty (only if publishing).
   If any check fails, STOP and tell the human. Do not work around it.
2. Upload the audio.
   Under 4 MB — one call, stays on the Montage domain:
     POST /api/upload/audio   (multipart/form-data, field "audio")
     -> {fileKey}
   Over 4 MB — the host rejects bodies that big, so presign instead:
     POST /api/upload/audio/presign  {filename, filetype, filesize}
     -> {presignedUrl, fileKey}
     then PUT the raw bytes to presignedUrl with Content-Type set to filetype
     and NO Authorization header — it is a storage URL, not Montage.
3. (Optional) GET /api/youtube/templates to reuse a saved metadata preset.
4. POST /api/montage/schedule
   {title, audioStoragePath: fileKey, video_source_type: "youtube",
    source_youtube_url, startTime, endTime}
   -> {jobId}.  Persist jobId immediately: this call is NOT idempotent, and
   re-running it renders and bills a second video.
5. GET /api/jobs/<jobId> every 10s until status is "complete" or "error".
   Give up after 30 minutes. On "complete", read montage.id.
6. POST /api/publish/intent
   {montageId, channelId, title, description, tags, privacy}
   -> {intentId}.  Safe to retry on network errors. Returns 409 once the upload
   has started (code "publish_in_progress": keep polling) or finished
   (code "already_published": done). Never re-post to hurry a slow publish.
7. GET /api/publish/intent?id=<intentId> every 15s until status is "published"
   or "error". On success, report youtubeUrl to the human.

Error handling:
- 402 (no credits) and 403 (YouTube not connected): permanent. STOP, tell the
  human, do not retry and do not try another channel on your own.
- 429: read the Retry-After header and wait that many seconds.
- 5xx and network errors: retry up to 3 times with 1s, 3s, 9s backoff.
- Never create a second job for the same track because the first one is slow.
Tell your agent not to echo the key
Both briefs include that instruction. Keep it. Agents routinely print their environment while debugging, and a key in a transcript is a key you have to revoke.

The happy path, step by step

What the CLI does for you, spelled out. Full request and response shapes are in the API reference.

01
Preflight
shell
curl -sS https://www.usemontage.com/api/me \
  -H "Authorization: Bearer $MONTAGE_API_KEY"

Check subscription.status, that credits.balance covers credits.costPerVideo, and that youtubeChannels has the channel you intend to publish to. Do this first — it is one cheap call that prevents every avoidable failure later.

02
Upload the audio

Under 4 MB, one call — and it never touches a storage host, which is what sandboxed agents need:

shell
curl -sS -X POST https://www.usemontage.com/api/upload/audio \
  -H "Authorization: Bearer $MONTAGE_API_KEY" \
  -F "[email protected]"

Returns fileKey, which is what the schedule call wants. For anything larger, use the two-step presign flow below — the host rejects request bodies over roughly 4.5 MB before Montage ever sees them.

03
Or presign, for files over 4 MB
shell
curl -sS -X POST https://www.usemontage.com/api/upload/audio/presign \
  -H "Authorization: Bearer $MONTAGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filename":"beat.mp3","filetype":"audio/mpeg","filesize":5242880}'

Returns presignedUrl and fileKey. Keep the fileKey.

04
Upload the bytes
shell
curl -sS -X PUT "$PRESIGNED_URL" \
  -H "Content-Type: audio/mpeg" \
  --data-binary @beat.mp3
No Authorization header here
This request goes to object storage, not to Montage. Sending a bearer token alongside the presigned signature makes the upload fail.
05
Schedule the render
shell
curl -sS -X POST https://www.usemontage.com/api/montage/schedule \
  -H "Authorization: Bearer $MONTAGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Dark Trap Type Beat",
    "audioStoragePath": "'"$FILE_KEY"'",
    "video_source_type": "youtube",
    "source_youtube_url": "https://www.youtube.com/watch?v=VIDEO_ID",
    "startTime": 30,
    "endTime": 150
  }'
Persist the jobId before you do anything else
This is the one call in the pipeline that is not idempotent. It spends credits. If your agent loses the jobId and retries, you have paid for two videos.
06
Poll until the render finishes
shell
curl -sS https://www.usemontage.com/api/jobs/$JOB_ID \
  -H "Authorization: Bearer $MONTAGE_API_KEY"

Every 10 seconds, until status is complete or error. Give up after 30 minutes. On success, take montage.id.

07
Queue the publish
shell
curl -sS -X POST https://www.usemontage.com/api/publish/intent \
  -H "Authorization: Bearer $MONTAGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "montageId": "'"$MONTAGE_ID"'",
    "channelId": "UCxxxxxxxxxxxxx",
    "title": "Dark Trap Type Beat - \"Nightshift\"",
    "description": "Free for non-profit use.",
    "tags": "type beat,trap,free beat",
    "privacy": "public"
  }'

Safe to retry after a network error. Once the upload has started or finished, repeating the call returns 409 rather than publishing the video twice. A slow publish is not a failed one — keep polling instead of posting again.

08
Poll until it is live
shell
curl -sS "https://www.usemontage.com/api/publish/intent?id=$INTENT_ID" \
  -H "Authorization: Bearer $MONTAGE_API_KEY"

Every 15 seconds until status is published — which brings back youtubeUrl — or error.

Rules that keep agents out of trouble

SituationWhat your agent should do
402 insufficient creditsStop and tell the human. Never retry — the balance will not change on its own.
403 YouTube not connectedStop and send the human to /connections. Do not try a different channel.
429 rate limitedRead the Retry-After header and wait exactly that long.
5xx or network errorRetry up to three times with 1s, 3s, 9s backoff.
A render is taking a long timeKeep polling. Never schedule a second job for the same track — that bills twice.
A render ended in errorPOST /api/jobs/retry re-queues it at no extra credit cost.

Limits worth knowing up front

LimitValue
Concurrent active jobs10
New render jobs20 per hour
Publish requests25 per hour
Audio upload requests200 per hour
Audio file size200 MB
Short / clip length60 seconds

Limits are per account, shared between your browser session and every key you have issued. The live values for concurrency and cost are always in GET /api/me — prefer reading them over hardcoding.

Keeping keys safe

  • One key per agent. If you have to revoke one, you only break that agent.
  • Environment variables, never prompts. A key pasted into a conversation lives in that transcript forever.
  • Set an expiry for anything experimental — 30 days costs you nothing and limits the blast radius.
  • Revoke on suspicion, not on proof. Revoking is instant and minting a replacement takes seconds.
  • Check last_used_at on your keys page. A key being used when your agent is idle is worth investigating.

Keys inherit your account’s permissions exactly — there are no read-only or scope-limited keys today. Anything you would not want an agent to do on your channel, do not hand it a key for.