CosmoMaker API
Make videos from your own code. Every tool the Studio’s agent uses is one HTTPS call, with the same credits and rules as the Studio.
Connecting ChatGPT, Claude or another agent? You don’t need this page. Give it https://mcp.cosmomaker.ai/mcp, or follow its steps on your Profile page, under Connected agents.
Your key
Make one on your Profile page, under API keys: Create API key. It’s shown once, so keep it somewhere safe. Send it with every call:
Authorization: Bearer cm_…
Each key has its own rules, which you can change any time under Manage: how many credits it may spend a day without asking, which workflows it sees, and whether it may start renders by itself.
Call a tool
POST the tool’s arguments as JSON to the tool’s address:
curl https://api.cosmomaker.ai/v1/tools/create_workflow \
-H "Authorization: Bearer $COSMOMAKER_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Paper boat"}'Every answer has the same two fields: text, the answer in words, and ids, every id it names, in order.
{"text": "made wf_a8e7b371 \"Paper boat\": 16:9, 720P",
"ids": ["wf_a8e7b371"]}An id starts with what it is: wf_ a workflow, pic_ a picture, vid_ a video, take_ a rendered take, job_ a render.
Long work
Pictures, previews and renders take from seconds to minutes. A call still going after 40 seconds answers 202 with its call id. Pass it to wait, which answers when the call ends, or after up_to seconds (202 again if it’s still going):
POST /v1/tools/wait {"ids": "call_5c0e1f2a", "up_to": 80}To follow everything on a workflow, renders included, pass the workflow instead. When it answers nothing is under way, everything is done.
POST /v1/tools/wait {"workflow": "wf_a8e7b371", "up_to": 80}
{"text": "job_81289cac: the take landed, take_bb6c5a36",
"ids": ["job_81289cac", "take_bb6c5a36"]}Send a file
upload_file gives you a one-time link. Send the file to it, then add it to the workflow’s library:
POST /v1/tools/upload_file {"name": "script.md", "type": "text/markdown", "size": 18234}
PUT <the link in its answer> the file's bytes
POST /v1/tools/add_to_library {"workflow": "wf_a8e7b371", "url": "<the url in its answer>"}Pictures and audio up to 10 MB, documents (.md, .txt, .docx, .doc, .pdf) up to 50 MB, video up to 2 GB.
Credits and limits
quotegives the exact price before anything starts. It changes nothing.- Your changes go into a draft.
landputs the draft on the workflow and starts its renders, if the key may; if not, you press Use these changes in the Studio. - Work within the key’s daily limit starts at once. Past it, it waits for your Go in the Studio.
whoamishows your credits, what’s left of today’s limit, and what the key may do.
Errors
A call that fails answers with an HTTP status and the reason, in words:
{"error": {"type": "invalid_request_error",
"message": "S1 has no reference picture, so the take can't start: …"},
"request_id": "9b1c2f…"}400 | The tool said no, or the body isn’t the tool’s arguments. The message says why, and what to do next. |
401 | The key is wrong, or it was removed. |
403 | The key is paused, or it’s an app’s sign-in pass, which works only at the agents’ address. |
404 | There’s no tool by that name. |
429 | More than 10 calls a second. Wait a moment and try again. |
A whole video
From nothing to an MP4, in Python with requests:
import requests
API = "https://api.cosmomaker.ai/v1/tools/"
KEY = {"Authorization": "Bearer cm_…"}
def call(tool, **args):
r = requests.post(API + tool, json=args, headers=KEY, timeout=150)
r.raise_for_status()
while r.status_code == 202: # still going: wait for it
r = requests.post(API + "wait", json={"ids": r.json()["call"]}, headers=KEY, timeout=150)
r.raise_for_status()
return r.json()
wf = call("create_workflow", name="Paper boat")["ids"][0]
call("add_segments", workflow=wf, count=1, seconds=5)
# a scene is filmed from a picture of its place or its people
pic = call("make_picture", workflow=wf,
words="A red paper boat on a rainy street puddle at dusk, no people")["ids"][0]
call("add_to_bible", workflow=wf, kind="place", name="Rainy street", picture=pic)
call("set_references", workflow=wf, segment="S1", cast="@Rainy street")
# our cinematographer writes the scene from a note
call("write_segment", workflow=wf, segment="S1",
note="The boat drifts across the puddle.", shots="0-5 s: wide, slow push in")
print(call("quote", workflow=wf)["text"]) # the price, before anything starts
call("shoot", workflow=wf)
call("land", workflow=wf) # the key must be allowed to start renders
while "nothing is under way" not in call("wait", workflow=wf, up_to=80)["text"]:
pass
take = [i for i in call("open_workflow", workflow=wf)["ids"] if i.startswith("take_")][0]
print(call("deliver", workflow=wf, take=take)["text"]) # the MP4's linkTools
All 49, read from GET /v1/tools as this page opens, so the list always matches the API. Each tool’s words are the ones agents read.
whoamiYour credits, what's left of today's limit, the workflows you can see, and whether your changes land without Use.
No parameters.
list_workflowsThe workflows you can see, newest first: id, name, scenes, takes.
querystringoptional- words in the name
create_workflowA new workflow. It joins the ones you can see. Free.
namestring- its name
orientationstringoptional- landscape unless asked (portrait, landscape)
resolutionstringoptional- 720P unless asked (480P, 720P)
speech_languagestringoptional- the language its spoken lines are in
likestringoptional- a wf_ id: its settings, and with cast its people and places, come along
caststringoptional- with like: the people and places to carry over, by name with commas
copy_workflowA private copy of a workflow: its scenes, cast, library and takes, on the same files. It joins the ones you can see. Free.
workflowstring- a wf_ id
namestringoptional- its name; the old name and (copy) if left out
find_resourcesSearch everything in the workflows you can see, by words, kind, who made it or where it is: pictures, audio, videos, documents, and the people and places of their bibles. Each with its id, its workflow, what uses it, who made it and its link.
querystringoptional- words in its name or prompt
kindstringoptional- (picture, audio, video, document, bible)
workflowstringoptional- a wf_ id: only there
made_bystringoptional- agents: only what an agent made (agents)
upload_fileA one-time link to send a file from your disk straight to our bucket, which costs you no tokens: run its curl line, then add_to_library. Pictures and audio up to 10 MB, documents (.md, .txt, .docx, .doc, .pdf) 50 MB, video 2 GB.
namestring- the file's name, with its extension
typestring- its content type, e.g. text/markdown, image/png
sizeinteger- its exact size in bytes
get_guideHow to write for the models and work the Studio, by topic. Call it with no topic for the list.
topicstringoptional- (words, crew, bible, pictures, frames, checking, editing, music)
open_workflowThe workflow as you would change it, your draft's changes in it: its settings, cast and places, every scene with its id, length, price and the start of its words, the library's newest, the Sound lane, the takes. look reads a scene whole.
workflowstring- a wf_ id
previzA 480P test of one scene, from your draft: 0.55 credits for 10 s with 2 pictures. Within the creator's daily limit it starts at once, above it the creator gets a Go card. wait follows it, then look at it by its job_ id.
workflowstring- a wf_ id
segmentstring- a scene: S2 (its place now) or seg_ab12cd34
set_wordsOnly for words the creator gave you exactly (else write_segment: our cinematographer writes them). Puts a scene's whole words into the draft; they are checked as the cinematographer's are, and an error says what to fix. get_guide words has the format. Set its references first, so its labels answer.
workflowstring- a wf_ id
segmentstring- a scene: S2 (its place now) or seg_ab12cd34
wordsstring- the exact text the video model reads
shotsstringoptional- its shot plan: '0-5 s: wide, still: what is seen; 5-10 s: close-up: ...'; every scene is shot from one, so it's needed when it has none or this reframes or retimes a shot
copy_bibleCarry people and places from another workflow into this one's bible, in the draft, by name, with their pictures, looks and voices, on the same files. Only who is on that workflow: who is only in a draft comes with Use.
workflowstring- a wf_ id
frmstring- a wf_ id: the workflow they are in
namesstring- their names, with commas
add_to_libraryAdd a file to this workflow's library: an upload_file url once its curl has run, or a small file inline (a picture or a document, under 1.5 MB).
workflowstring- a wf_ id
urlstringoptional- the url upload_file gave
namestring- what to call it, with its extension
content_base64stringoptional- the file's bytes
typestringoptional- with content_base64: its content type
copy_resourcesPut library items of other workflows into this one's library: the same files, new rows.
workflowstring- a wf_ id
idsstring- pic_, aud_, vid_ and doc_ ids with commas
remove_resourceTake a library item off this workflow, only one you made. What the creator made or uploaded stays: ask them.
workflowstring- a wf_ id
idstring- a pic_, aud_, vid_ or doc_ id you made
build_editMake a new take from a saved take's Edit lane: its cuts, look, captions and transitions, as the creator's Build button does. Free. The take stays as it is. Answers with a job id.
workflowstring- a wf_ id
sayPut a line in the dock for the creator to read in Studio: what you are doing, or what you need.
workflowstring- a wf_ id
textstring- one short line
proposeHand the draft to the creator: they see your changes and renders in Studio, with a Use button and a Discard button, and your message. wait with this workflow follows their answer.
workflowstring- a wf_ id
messagestringoptional- what you did and what you ask of them, a sentence or two
landLand the draft on the workflow yourself, only if the creator allowed it (whoami says so). Renders within the daily limit start, the rest wait for their Use.
workflowstring- a wf_ id
add_segmentsAdd empty scenes to the draft. Give them words with write_segment: our cinematographer writes them.
workflowstring- a wf_ id
countinteger- how many, 1-20
afterstringoptional- the scene to add them after; S0 puts them first; left out: at the end
secondsintegeroptional- each one's length, 5-15
modestringoptional- what they render from (omni_reference, first_last_frame)
continuesbooleanoptional- true: each carries on from the scene before it, with no cut
set_segmentChange a scene's length, mode, continuity or place in the order, in the draft. Pass only what changes.
workflowstring- a wf_ id
segmentstring- a scene: S2 (its place now) or seg_ab12cd34
secondsintegeroptional- 5-15
modestringoptional- (omni_reference, first_last_frame)
continuesbooleanoptional- true: no cut from the scene before
move_tointegeroptional- new position, 1 = first
remove_segmentRemove a scene from the draft. The ones after it move up.
workflowstring- a wf_ id
segmentstring- a scene: S2 (its place now) or seg_ab12cd34
write_screenplayHave our screenwriter write a story as a screenplay document in the library: scenes of 5-15 s with every line. Or change a script in the library, the rest kept word for word. Skip it when the creator has a script: upload that.
workflowstring- a wf_ id
briefstring- what the creator asks, word for word
secondsintegeroptional- how long the whole video is, in seconds
episodesintegeroptional- how many episodes
scriptstringoptional- a doc_ id: the script to change; left out, a new story
pitchbooleanoptional- true: two loglines to choose from, nothing saved
script_onlybooleanoptional- true: the creator wants only the script for now
write_segmentHave our cinematographer write a scene's whole words, the exact text the video model reads, from the scene as it is, its shot plan and your note, into the draft. Set its references first. For a whole script use break_down_script.
workflowstring- a wf_ id
segmentstring- a scene: S2 (its place now) or seg_ab12cd34
notestring- what it shows, in the creator's words: every fact, act, line, camera note and timing; for a change, only what changes
shotsstringoptional- its whole shot plan: '0-5 s: wide, eye level, still: what is seen; 5-10 s: close-up, slow push-in: ...'; needed when it has none or the change reframes or retimes a shot
set_referencesSet what a scene renders from, in the draft: who is in it, each on their bible picture, and its other pictures, videos and clips (omni reference), or its first and last frame (first/last frame).
workflowstring- a wf_ id
segmentstring- a scene: S2 (its place now) or seg_ab12cd34
caststringoptional- who is in it, by bible name in the order its words number them, e.g. '@Mia, @Kitchen'; 'none' clears them
picturesstringoptional- its other references in order, pic_, vid_ and aud_ ids with commas: 9 pictures, 3 videos and 3 clips at most, a video 2 s at least; 'pic_ab12cd34:composition' lends framing, light or things only; '' clears them
mutestringoptional- vid_ ids among them whose own sound is off; '' turns all sound on
firststringoptional- a pic_ id, or 'none'
laststringoptional- a pic_ id, or 'none'
add_to_bibleAdd a person or place to the series bible in the draft, or change one, by name.
workflowstring- a wf_ id
kindstring- (person, place)
namestring- their name
lookstringoptional- one sentence in the creator's language: a person's age (an adult), hair, face, build, clothes; a place's look and light
pronounstringoptional- (she, he)
picturestringoptional- a pic_ id: their picture
voicestringoptional- a person's voice, one sentence: gender and age, pitch, timbre, pace, accent; written into every line of theirs
remove_from_bibleRemove a person or place from the series bible, in the draft.
workflowstring- a wf_ id
namestring- their name
make_pictureMake pictures into the library, 1 to 3 cents each, in seconds. With references it edits or combines them. Within the creator's daily limit it starts at once, above it the creator gets a Go card and this answers with a call id for wait. Never a picture that looks like a real person.
workflowstring- a wf_ id
wordsstringoptional- what the picture model reads: for a new picture one English paragraph of 100-200 words, everyone an adult by decade; get_guide pictures says how
referencesstringoptional- pic_ ids to edit or combine, in the order the words name them
ratiostringoptional- its frame (9:16, 16:9)
resolutionstringoptional- 720P unless asked (480P, 720P)
countintegeroptional- how many, 1-4, each its own seed and price
for_biblestringoptional- a bible name: the picture becomes theirs
redostringoptional- the pic_ id of one that missed the ask: the new one takes its place in the draft; twice at most
fixstringoptional- with redo: what was wrong with it
compose_musicMake music into the library from words: a song with its lyrics or an instrumental, about 7 cents a minute. Within the daily limit, else a Go card.
workflowstring- a wf_ id
descriptionstring- its caption; get_guide music says how
secondsinteger- the most it runs, 10-180
vocalsstringoptional- (instrumental, sung)
lyricsstringoptional- the sung words in sections, a lowercase tag on its own line
countintegeroptional- how many, 1-4
lay_under_videobooleanoptional- lay it under the whole video, in the draft
design_soundMake a sound effect or ambience into the library, or an instrumental from a library clip, about a cent. Within the daily limit, else a Go card.
workflowstring- a wf_ id
descriptionstring- the sound; get_guide music says how
secondsinteger- 10-60
clipstringoptional- an aud_ id to make it from
clip_usestringoptional- remix keeps its melody and timing; style makes a new piece with its sound (remix, style)
countintegeroptional- how many, 1-4
lay_atnumberoptional- where on the video's clock to lay it, in seconds, in the draft
lay_trackLay a library audio clip on the Sound lane under the video, in the draft, or move it or change its level or fades.
workflowstring- a wf_ id
clipstring- an aud_ id
startnumberoptional- seconds
endnumberoptional- seconds
volumenumberoptional- 0-2; 1 = as made
fade_innumberoptional- seconds: 0.1 (none), 0.5, 1, 2 or 4
fade_outnumberoptional- seconds: 0.1 (none), 0.5, 1, 2 or 4
remove_trackTake a track off the Sound lane, in the draft.
workflowstring- a wf_ id
trackstring- T#, from open_workflow
set_formatChange the whole video's settings, in the draft. Pass only what changes.
workflowstring- a wf_ id
namestringoptional- the workflow's name
speech_languagestringoptional- the language its spoken lines are in (Arabic, Chinese, English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish)
orientationstringoptional- (portrait, landscape)
resolutionstringoptional- one open_workflow lists
lookRead a scene's whole words or a document's, or see pictures, or have our reviewer watch a take, a preview or a library video, one at a time: it says what it sees, answers your question and sends frames. A whole take or video is heard too.
workflowstring- a wf_ id
targetstring- 'S2' or a doc_ id; or pic_ ids with commas; or a take_ id, a preview like 'S2.1' or a vid_ id, with pic_ ids after it to compare; or one moment, 'take_ab12cd34@13'; or a script's scene as the crew planned it, 'scene 7' or 'scenes 3-5'
questionstringoptional- with a video: one open question in English on how something in it looks (what, who, where, how many, what colour); never yes or no, never naming what people do to each other
framesintegeroptional- with a question: how many frames that show its answer come back, 1-9
break_down_scriptThe one call for a whole script, however long. Our crew breaks it into scenes, makes a picture for everyone and everywhere new (a cent each, within the daily limit), plans every shot and writes every scene, straight onto the workflow, with no stop. Answers with a job id: wait follows it, then quote, shoot and propose.
workflowstring- a wf_ id
scriptstringoptional- the script's doc_ id
directionstringoptional- how the creator wants the whole film shot, in their words
againbooleanoptional- true: break it down again from the start, as new scenes after the last ones, which stay until you remove_segment them
plan_shotsHave our crew read scenes' shot plans back from their words. A scene needs one to render.
workflowstring- a wf_ id
scenesstringoptional- like 'S3,S7-S9'; every scene that lacks one if left out
write_scenesHave our crew write scenes of a broken-down script again, six at a time. Answers with a job id.
workflowstring- a wf_ id
scenesstringoptional- like 'S3,S7-S9'; every scene not written yet if left out
shootAdd a full render of the video, or of a range, to the draft. It starts when the creator presses Use, or with land if they allow it.
workflowstring- a wf_ id
firststringoptional- first scene, S1 if left out
laststringoptional- last scene, the last if left out
quoteThe exact price in credits of a take or a preview, or what it would be with what you pass. Nothing changes.
workflowstring- a wf_ id
segmentstringoptional- a scene: S2 (its place now) or seg_ab12cd34; a take of the whole video if left out
laststringoptional- a take of a range: its last scene
previewbooleanoptional- true: the scene's 480P preview instead of a take
resolutionstringoptional- one open_workflow lists
secondsnumberoptional- what if each were this long
modestringoptional- what if each rendered from (omni_reference, first_last_frame)
picturesintegeroptional- what if each carried this many pictures
clipsintegeroptional- what if each carried this many clips
videosintegeroptional- what if each carried this many videos
deliverSave a take into the library as an MP4, with the Sound lane mixed in, and get its link. Free.
workflowstring- a wf_ id
takestringoptional- a take_ id; the newest if left out
report_brokenSend a render that came out badly broken to our team's test set, with the words and pictures it was made from, when the creator says it is. Free, and nothing here changes.
workflowstring- a wf_ id
segmentstring- a scene: S2 (its place now) or seg_ab12cd34
problemstring- what is wrong, in the creator's own words
videostringoptional- a take_ or job_ id: the video they mean; the scene's newest if left out
pull_stillSave one frame of a take into the library as a picture. Free.
workflowstring- a wf_ id
takestringoptional- a take_ id; the newest if left out
atstringoptional- seconds into it, or 'end'; its first frame if left out
clip_videoCut a stretch of a library video or a take into the library, 60 s at most, or its sound alone as a clip. Free.
workflowstring- a wf_ id
videostring- a vid_ or take_ id
startstringoptional- seconds or a clock (9:50.5); its first second if left out
endstringoptional- the same; its last second if left out
audiobooleanoptional- true: its sound alone
save_documentSave words as a document in the library. For a file on disk use upload_file: it costs you no tokens.
workflowstring- a wf_ id
namestring- its title
textstring- its words, whole
edit_footageEdit a saved take on the Edit lane, in the draft, with no new render: cut a stretch out, or play a library video in it, or with start = end put a video in whole, or put a stretch back. Free: build_edit then makes a new take of it, the take kept as it is.
workflowstring- a wf_ id
takestringoptional- a take_ id; the newest if left out
startnumber- seconds into the take
endnumber- seconds into the take; = start to put a video in there
videostringoptional- a vid_ id
own_soundbooleanoptional- with video over a stretch: keep the take's own sound under it
backbooleanoptional- true: put the stretch back as it was
color_gradeColour a saved take on the Edit lane, in the draft: a named look, then each number moves one slider. Free: build_edit makes a new take with it.
workflowstring- a wf_ id
takestringoptional- a take_ id; the newest if left out
lookstringoptional- original takes the look off (original, warm, cool, vivid, film, mono, vintage, night, airy)
exposureintegeroptional- -100 to 100
contrastintegeroptional- -100 to 100
saturationintegeroptional- -100 to 100
temperatureintegeroptional- -100 (blue) to 100 (orange)
tintintegeroptional- -100 (green) to 100 (magenta)
fadeintegeroptional- 0-100: lifted, matte blacks
subtitleCaptions on a saved take from what is said in it, in the draft: on, off, their style, or one line's words fixed. Free: build_edit burns them in.
workflowstring- a wf_ id
takestringoptional- a take_ id; the newest if left out
onbooleanoptional- true: make them; false: take them off
stylestringoptional- (clean, bold, boxed)
fontstringoptional- (noto-sans-sc, noto-serif-sc, lxgw-wenkai, smiley-sans, zcool-kuaile, zcool-qingke-huangyou, zcool-xiaowei, ma-shan-zheng, zhi-mang-xing, inter, montserrat, bebas-neue, oswald, anton, playfair-display, eb-garamond)
linestringoptional- C#, from open_workflow: the line to fix
textstringoptional- with line: its words as said
set_transitionA dip to black or white or a dissolve on a saved take, where its picture changes, in the draft. Free: build_edit makes it.
workflowstring- a wf_ id
takestringoptional- a take_ id; the newest if left out
kindstring- a dissolve needs a shot either side (black, white, dissolve, none)
scenestringoptional- the scene change into this scene
all_scenesbooleanoptional- true: every scene change
atnumberoptional- seconds into the take: 0, its end or a mark's edge
secondsnumberoptional- 0.3 quick, 0.6 (unless asked), 1 slow
set_production_soundThe video's own sound on the Sound lane, in the draft: its level, or a stretch silent, or heard again.
workflowstring- a wf_ id
volumenumberoptional- 0-1; 1 = as rendered
silent_startnumberoptional- seconds on the video's clock
silent_endnumberoptional- seconds on the video's clock; 0.3 s at least
backbooleanoptional- true: those silent stretches are heard again
waitFollow what is under way: call and job ids, or everything on a workflow, including a Go card and the creator's answer to propose. It answers when one ends, or after up_to seconds, with how long is left: with a shell, sleep that long first, so that waiting costs no tokens.
idsstringoptional- call_ and job_ ids with commas
workflowstringoptional- a wf_ id: everything under way on it
up_tointegeroptional- seconds to hold, 50 if left out, 90 at most