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
Step 1 — Mint an API key
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.
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.
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.
Your agent should read it from an environment variable so it never ends up in chat history, logs, or a repository.
export MONTAGE_API_KEY="mk_live_..."Verify the key works before you wire anything up:
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.
mkdir -p ~/.montage
curl -sS https://www.usemontage.com/montage-cli.mjs -o ~/.montage/montage-cli.mjs
node ~/.montage/montage-cli.mjs preflightpreflight 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:
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 publicEvery 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.
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
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
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.The happy path, step by step
What the CLI does for you, spelled out. Full request and response shapes are in the API reference.
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.
Under 4 MB, one call — and it never touches a storage host, which is what sandboxed agents need:
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.
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.
curl -sS -X PUT "$PRESIGNED_URL" \
-H "Content-Type: audio/mpeg" \
--data-binary @beat.mp3curl -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
}'jobId and retries, you have paid for two videos.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.
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.
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
| Situation | What your agent should do |
|---|---|
402 insufficient credits | Stop and tell the human. Never retry — the balance will not change on its own. |
403 YouTube not connected | Stop and send the human to /connections. Do not try a different channel. |
429 rate limited | Read the Retry-After header and wait exactly that long. |
5xx or network error | Retry up to three times with 1s, 3s, 9s backoff. |
| A render is taking a long time | Keep polling. Never schedule a second job for the same track — that bills twice. |
| A render ended in error | POST /api/jobs/retry re-queues it at no extra credit cost. |
Limits worth knowing up front
| Limit | Value |
|---|---|
| Concurrent active jobs | 10 |
| New render jobs | 20 per hour |
| Publish requests | 25 per hour |
| Audio upload requests | 200 per hour |
| Audio file size | 200 MB |
| Short / clip length | 60 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_aton 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.