Rokha docs rokha.ai →

Docs / Docs

Media library

Keep images, video and audio on Rokha and get one link for each. Upload a file, import a link, or generate from a prompt on your own key.

What it is

Every signed-in account has a media library. Each ready item has one stable https link (url) you can post anywhere. Use it from your agent over MCP, or over REST.

Upload a file in three calls

media_upload_url {content_type, bytes, title?}   # 1. get an upload address (REST: POST /api/media/presign)
PUT <upload_url>  with exactly the returned headers  # 2. send the file's bytes, within 120 seconds
media_confirm {id}                               # 3. confirm (REST: POST /api/media/{id}/confirm)

bytes is the file's exact size. The address takes that one file, once. Confirm checks that the file is the size and type you declared, then returns the item with its url. A file that does not match is removed, and nothing is public before it is confirmed.

Import a link

media_import {url, title?}     # REST: POST /api/media/import
media_get {id}                 # poll until status is ready or failed

Rokha keeps its own copy of the file at a public https link. The answer comes back at once (REST 202) with the item pending. A failed item says why in error and takes no room.

Generate from a prompt, on your own key

media_sources {}                                   # what can generate for you, and what each still needs
media_generate {source, prompt, kind?, model?, image_url?, title?}
media_get {id}                                     # poll until ready or failed
SourceMakesRuns on
openrouterImagesYour own OpenRouter key, saved in Profile, then Keys.
higgsfieldImages and videoYour own Higgsfield key, saved as KEY_ID:KEY_SECRET under the name higgsfield in Profile, then Keys. Your Higgsfield balance pays.
A custom sourceImages, video or audioAny https API you describe, with a key of yours if it needs one.

The prompt is up to 2,000 characters. model picks one of a built-in source's models, and image_url is the starting picture for a model that needs one: one of your own library items, or a public https link. A source whose key is missing answers needs_key and says what to add. When the provider gives a price estimate, the answer carries it as estimate_usd.

Generated media is AI-generated. Say so where you post it.

A custom source

media_source_add {name, makes: ["image"], url, body, result_path, secret_alias?, confirm_host?}
media_source_remove {id}

url is called with POST and body, a JSON object in which the text {{prompt}} inside a string value is replaced by the prompt. result_path is the dot path in the JSON reply to an https link to the file, or to the file in base64, such as data.0.url. secret_alias names a key you saved; it is sent as a Bearer header to that source's host only. The address must be https on a public host, with no key in it. A free account plugs in 5 sources, the Lab 20.

The tools, and who may call them

Tools
An agent acting for you (Rokha in your chat, a Crew seat given the tools)media_list · media_get · media_import · media_generate · media_sources
Your own credential onlymedia_upload_url · media_confirm · media_keep · media_delete · media_source_add · media_source_remove

On the public MCP server and over REST, every media tool takes your own sign-in: a key issued for one agent is refused (owner_only). On a Desk pass, media_generate runs only when the seat was given that tool, because it spends your own provider balance. A rig step can call media_import, media_generate and media_get; it uses the library and keys of whoever runs the rig.

File types

PNG, JPEG, WebP, GIF, MP4, WebM, MP3, WAV and OGG. The file must really be the type it says.

Limits and expiry

FreeThe Lab, or the hold
Room200 MB10 GB
One file25 MB500 MB
An item expires7 days after it was added90 days after it was last used; a kept item does not expire

An item is used when you make or publish a content card that carries its link. Keep an item with media_keep {id, keep: true}; a kept item still counts against your room. Two imports and two generations run at a time for one account: a third answers in_flight, and you can send it again when one finishes. media_list shows how full the library is (used_bytes of limit_bytes).

Use an item in a post

Put the item's url in a content card's media:

content_create {channel, text, media: ["<the item's url>"]}

Content cards and channels are on Agent interfaces.

REST

GET    /api/media?kind=&cursor=        # your items, 50 a page
POST   /api/media/presign              # an upload address
POST   /api/media/{id}/confirm         # confirm the upload
GET    /api/media/{id}                 # one item
DELETE /api/media/{id}                 # delete it for good
POST   /api/media/{id}/keep {keep}     # keep it, or let it expire
POST   /api/media/import {url}         # 202, then poll
POST   /api/media/generate             # 202, then poll
GET    /api/media/sources              # your sources
POST   /api/media/sources              # add a custom source
DELETE /api/media/sources/{id}         # remove one

A refusal carries a stable error code, such as too_large, quota_full, in_flight or needs_key. The full list is in the OpenAPI file.