AI Media Router

v0.1.0
io.github.jutsuhq/ai-media-router Checked 4 days ago Published 1 month ago

Image and video generation across 40+ providers with your own keys, plus a local asset library.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

add_to_collection

Add assets to a collection, creating it when missing.

ParameterTypeDescription
asset_ids *array
collection *stringCollection name; add_to_collection creates it when missing.
descriptionstring | nulladd_to_collection only: replaces the collection's description.

add_to_reference

Append assets to a reference, optionally with a role (e.g. "side").

ParameterTypeDescription
asset_ids *array
reference *stringReference name or id.
rolestring | nulladd_to_reference only: role of these assets, e.g. "front", "side", "palette".

cancel_job

Cancel a waiting or running job: it becomes failed with `cancelled`, and jobs waiting on it fail too. The provider is not asked to stop, so a running generation may still bill there.

ParameterTypeDescription
job_id *string

check_spec

Check a spec without saving or calling the provider: validates it (pointers, template variables), replays recorded fixtures, and with model/input renders the exact HTTP requests it would send.

ParameterTypeDescription
inputobject | nullGeneration input for the rendered requests.
modelstring | nullWith `model`, also render the exact HTTP requests a generation would send (nothing is sent).
providerstring | nullCheck the loaded spec of this provider. Omit when passing `spec`.
specstring | nullTOML text of a candidate spec (not saved). Format: docs/provider-spec.md.
varsobject | nullValues for variables later steps capture from earlier responses (e.g. {"id": "task-123"}).

concat

Join two or more video assets in order into one MP4 (first clip's size, 30 fps); returns the new asset.

ParameterTypeDescription
asset_ids *arrayTwo or more video assets in playback order. Output takes the first clip's size (others are letterboxed) at 30 fps; clips without sound get silence when any clip has sound.
save_to

delete_asset

Delete an asset's file and library entry; it leaves every reference and collection. Jobs keep their record of it.

ParameterTypeDescription
asset_id *string

delete_budget

Delete a budget; its jobs stay in the history.

ParameterTypeDescription
name *string

delete_recipe

Delete a recipe; jobs made from it stay in the history.

ParameterTypeDescription
name *string

delete_reference

Delete a reference; its assets stay in the library.

ParameterTypeDescription
reference *stringReference name or id.

delete_snippet

Delete a snippet; inputs that still use it fail with the list of known snippets.

ParameterTypeDescription
name *string

doctor

Check the installation: data directory, database, ffmpeg/ffprobe, which providers have keys, spec override errors, recorded fixtures of configured providers, jobs no worker is polling, and the last day's failure kinds. online=true also pings every configured provider. Run it first when something does not work.

ParameterTypeDescription
onlineboolean | nullAlso send one GET to every configured provider's base URL (any HTTP answer counts as reachable).

estimate_cost

Estimate a generation's USD cost: an offer's price (offer_id from search_prices) times the duration or image count read from input, plus the median of past jobs on this provider and model. Says which formula and input fields it used. With recipe (and vars) instead: every step of that recipe and the sum.

ParameterTypeDescription
inputobjectGeneration input. Seconds are read from duration, duration_seconds, duration_secs, seconds, video_length or length; the output count from num_images, n, num_outputs, image_count, number_of_images, sam…
modelstring | nullThe provider's model id, as passed to generate. Required unless `recipe` is given.
offer_idstring | nullOffer from search_prices to price; without it only the history median is used.
providerstring | nullProvider key, e.g. "kie". Required unless `recipe` is given.
recipestring | nullPrice a run_recipe instead: each step from its own estimated_cost_usd or offer_id (edits cost 0), and the sum.
reuseboolean | nullAs in generate: report (with cost 0) when the run would return an identical job's outputs.
varsobject | nullThe recipe's variables, as in run_recipe.

export_collection

Export a collection as a ZIP in <home>/exports/: the files, their previews, and collection.json with each asset's metadata (review status, rating, notes), the job that made it (provider, model, input, cost) and its references. only_approved=true ships only assets approved with review_asset.

ParameterTypeDescription
collection *string
only_approvedboolean | nullOnly assets approved with review_asset.

extract_frame

Save one frame of a video as a PNG asset: at "first", "last" or seconds. Use the last frame as the start image of the next clip.

ParameterTypeDescription
asset_id *stringA video asset.
at"first", "last", or seconds from the start (e.g. 1.5). Default "first".
save_toFile the new asset into a collection and/or reference.

generate

Start a generation. Returns the job immediately (status running); poll it with get_job. Results are downloaded into the library. Library files go into input as "{{asset:<id>}}" / "{{ref:<name>}}"; save_to files the outputs into a collection and/or reference. `recipe` names a saved single-generation preset (list_recipes shows the user's presets), so provider and model can be omitted.

ParameterTypeDescription
input *objectModel input passed to the provider unchanged (prompt, image_urls, duration, ...). Library files go in as placeholders, uploaded through the provider before submit: "{{asset:<id>}}" or "{{ref:<name>}}"…
budgetstring | nullCount this job against a budget (set_budget); the job is refused if it would exceed it.
estimated_cost_usdnumber | nullExpected cost in USD. With `budget` and no value, it is computed like estimate_cost.
modelstringThe provider's own model id or endpoint, e.g. "kling-2.6/image-to-video" on kie. Required unless `recipe` is given.
offer_idstring | nullOffer from search_prices this job buys; its price × the duration or image count in `input` becomes the job's estimate when `estimated_cost_usd` is not given.
providerstringProvider key, e.g. "kie". See get_provider for what `model` means there. Required unless `recipe` is given.
recipestring | nullA saved single-generation recipe used as a preset: its provider, model, input (variables filled, defaults applied), save_to, offer_id and budget are the defaults. Fields given here win; `input` merges…
retryResubmit after a retryable failure (rate_limit, provider_error, network, timeout): {attempts: 1-5, delay_secs}. Off by default, since a provider may bill a failed attempt.
reuseboolean | nulltrue: when a job with the same provider, model and input (library files compared by content) is done and its outputs are still in the library, or is still running, return those outputs as a new job at…
save_toFile the outputs into a collection and/or an existing reference when the job finishes.
varsobject | nullThe recipe's variables, as in run_recipe.

generate_batch

Start up to 100 jobs at once: items (e.g. one prompt on several provider/model pairs) x matrix (top-level input fields to vary). Item input merges over defaults.input. With defaults.budget the sum of estimates is admitted first. Returns the batch; follow it with get_batch.

ParameterTypeDescription
defaultsShared by every job; items override provider, model, save_to and estimated_cost_usd, and merge their input over this input.
itemsarray | nullOne entry per variant, e.g. the same prompt on several provider/model pairs (a bench).
labelstring | nullFree text to recognise the batch by.
matrixobject | nullTop-level input fields to vary: {"aspect_ratio": ["16:9", "9:16"], "seed": [1, 2]}. Every item runs with every combination. At most 100 jobs in total.
recipestring | nullRun a saved recipe: its provider, model, input and save_to are the defaults, and `matrix` keys, `defaults.vars` and item `vars` fill its "{{var:<name>}}" variables instead of input fields.

get_asset

Metadata and local path of one asset.

ParameterTypeDescription
asset_id *string

get_batch

A batch's jobs per status, each job's outputs, and every output file. wait_secs blocks until all finish (max 50).

ParameterTypeDescription
batch_id *string
wait_secsinteger | nullBlock up to this many seconds (max 50) for every job to finish. Default 0.

get_job

Job status, provider progress and stored result files. wait_secs blocks until done (max 50); debug=true adds the raw provider exchanges.

ParameterTypeDescription
job_id *string
debugboolean | nullInclude `trace`: the exact request and raw provider response of each step. Use it when a job failed or stays running, to see which pointer or URL in the spec is wrong.
wait_secsinteger | nullBlock up to this many seconds (max 50) for the job to finish. Default 0.

get_lineage

Generation graph of an asset: the assets and references it was made from (ancestors) and everything made from it (descendants), with the job of each step.

ParameterTypeDescription
asset_id *string

get_provider

How to call one provider: model id format, an example generate call, docs link, upload support, known quirks.

ParameterTypeDescription
provider *stringProvider key from list_providers, e.g. "fal".

get_recipe

One recipe by name.

ParameterTypeDescription
name *string

get_reference

One reference by name or id, with its assets in order and their local paths.

ParameterTypeDescription
reference *stringReference name or id.

get_spec

Read a provider's active spec (TOML), whether it is built-in or a local override, and its fixture names. First step of fixing a provider.

ParameterTypeDescription
provider *stringProvider key from list_providers, e.g. "fal".

get_stats

Per provider and model: jobs, done/failed share, failure kinds, average rating, approved share, average USD cost and seconds to finish. Filter by provider, model or collection. Use it to pick a model that worked before.

ParameterTypeDescription
collectionstring | nullOnly jobs that read from or wrote into this collection.
modelstring | nullThe provider's model id.
providerstring | nullProvider key, e.g. "kie".

import_asset

Copy a local file into the asset library, e.g. a reference image. Files made by ai-media-router carry their provider, model, input, job and parent assets: import restores prompt, tags and lineage, and returns that provenance.

ParameterTypeDescription
path *stringAbsolute path of a local file.
promptstring | nullDescription used for search; defaults to the prompt stored in the file by ai-media-router.
tagsstring | nullSpace-separated tags, e.g. "character hero".

list_budgets

Budgets with their limit, spent and remaining USD.

list_collections

List collections (projects) with their asset counts. search_assets {collection} lists one's assets.

list_jobs

Generation history, newest first, with provider, model, input, cost, input assets and outputs. Filter by reference, collection, status or error_kind.

ParameterTypeDescription
batchstring | nullOnly jobs of this batch (generate_batch).
collectionstring | nullOnly jobs that read from or wrote into this collection.
error_kindOnly failed jobs of this kind, e.g. "moderation" or "rate_limit".
limitinteger | nullDefault 20.
referencestring | nullOnly jobs that used this reference (name or id) as input or filed outputs into it.
statusstring | null`running`, `done` or `failed`.

list_keys

Every provider key any loaded spec uses: whether it is set, where it comes from, and the command that sets it. Never returns key values (only the last 4 characters), so it is safe to show the user; keys are added by the user in a terminal.

list_providers

List providers, whether their API keys are set, and whether each runs the built-in spec or a local override.

list_recipes

List recipes with their provider, model, input or steps, and variables.

list_references

List references, most recently changed first; filter by kind or a substring of name, description or tags.

ParameterTypeDescription
kind
limitinteger | nullDefault 20.
querystring | nullSubstring of name, description or tags.

list_snippets

List snippets with their text.

mux_audio

Put an audio track (audio asset or another video's sound) under a video, replacing its sound; returns the new asset.

ParameterTypeDescription
audio_asset_id *stringAn audio asset, or a video whose sound is taken. Replaces the video's sound; padded with silence or cut to the video's length.
video_asset_id *string
save_to

overlay

Draw an image (packshot, logo) over an image or video at x, y pixels, optionally scaled to width; returns the new asset.

ParameterTypeDescription
base_asset_id *stringImage or video to draw on (e.g. a generated plate).
overlay_asset_id *stringImage drawn on top (e.g. a real packshot or a logo; PNG transparency is kept).
save_to
widthinteger | nullScale the overlay to this width in pixels, keeping its aspect. Default: its own size.
xinteger | nullLeft edge in pixels of the base (get_asset shows its width and height). Default 0.
yinteger | nullTop edge in pixels of the base. Default 0.

preflight

Dry run of generate with the same arguments: checks the provider and keys, snippets and placeholders (assets, references, parent jobs), upload support, save_to, cost and budget, and renders the exact HTTP requests. Sends nothing, spends nothing; `ready` says whether generate would start. Use it before an expensive or unfamiliar generation. With recipe and vars instead: every step of run_recipe (checks named <step>/<check>), the summed estimate and the budget.

ParameterTypeDescription
budgetstring | nullWith a recipe of steps, the sum of every step's estimate is checked against it.
estimated_cost_usdnumber | null
inputobjectAs in generate.
modelstring | nullAs in generate; required unless `recipe` is given.
offer_idstring | null
providerstring | nullAs in generate; required unless `recipe` is given.
recipestring | nullCheck a run_recipe instead: every step of the recipe, their summed estimate and the budget for the sum.
retry
reuseboolean | nullAs in generate: report (with cost 0) when the run would return an identical job's outputs.
save_to
varsobject | nullThe recipe's variables, as in run_recipe.

reframe

Change an image's or video's aspect ratio (e.g. 16:9 to 9:16) by centered crop or black padding; returns the new asset.

ParameterTypeDescription
aspect *stringTarget aspect ratio "W:H", e.g. "9:16", "1:1", "16:9", or a number like "1.91".
asset_id *stringAn image or video asset.
mode`crop` (default): cut the edges away, centered. `pad`: add black bars.
save_to

remove_from_collection

Remove assets from a collection (not from the library); an emptied collection disappears.

ParameterTypeDescription
asset_ids *array
collection *stringCollection name; add_to_collection creates it when missing.
descriptionstring | nulladd_to_collection only: replaces the collection's description.

remove_from_reference

Remove assets from a reference; they stay in the library.

ParameterTypeDescription
asset_ids *array
reference *stringReference name or id.
rolestring | nulladd_to_reference only: role of these assets, e.g. "front", "side", "palette".

reset_spec

Delete a provider's local override so the built-in spec is used again.

ParameterTypeDescription
provider *stringProvider key from list_providers, e.g. "fal".

review_asset

Review assets: status approved/rejected/draft, rating 1-5, notes. Rejected assets are skipped when a {{ref:…}} expands; export_collection {only_approved} ships only approved ones; get_stats averages ratings per model.

ParameterTypeDescription
asset_ids *array
notesstring | nullWhat is right or wrong with it, e.g. "extra fingers, logo warped"; replaces earlier notes, searched by search_assets.
ratinginteger | null1-5.
status`approved` (ready to use), `rejected` (skipped by {{ref:…}} expansion) or `draft`.

run_recipe

Start a generation from a recipe with values for its variables (defaults fill the rest). Returns the job like generate. A recipe with steps starts every step at once in one batch, admitting the sum of their estimates against `budget`; it returns the last step's job, and get_batch {batch_id} follows the whole run.

ParameterTypeDescription
name *string
budgetstring | nullWith steps, the sum of every step's estimate is admitted before anything is submitted.
estimated_cost_usdnumber | nullWith `budget` and no value, it is computed like estimate_cost. Not for a recipe with steps: set it per step.
offer_idstring | nullOffer from search_prices; prices the run from the filled input. Not for a recipe with steps: set it per step.
retryResubmit after a retryable failure (rate_limit, provider_error, network, timeout): {attempts: 1-5, delay_secs}. Off by default, since a provider may bill a failed attempt.
reuseboolean | nulltrue: when a job with the same provider, model and input (library files compared by content) is done and its outputs are still in the library, or is still running, return those outputs as a new job at…
save_toReplaces the recipe's save_to for this run (with steps: for the final steps).
varsobject | nullValues for the recipe's variables, e.g. {"language": "de", "duration": 5}.

save_recipe

Save a generation template: from_job copies a working job, or give provider, model and input. "{{var:<name>}}" in input marks what changes per run; every recipe also appears as the MCP prompt recipe:<name>. A chain: `steps` (generations and ffmpeg edits linked by "{{step:<name>}}"), or from_job / from_asset with chain: true to take the final job's whole lineage.

ParameterTypeDescription
name *stringUnique name; saving again replaces the recipe.
budgetstring | nullBudget every run counts against unless the call names another.
chainboolean | nullWith from_job / from_asset: also save the jobs that made its inputs ({{job:…}}, {{asset:…}} made by a job, asset ids of an edit), back to imported files and references, as earlier steps; their ids…
descriptionstring | null
from_assetstring | nullLike from_job, with the job that made this asset.
from_jobstring | nullStart from this job's provider, model, input and save_to; other fields given here override them.
inputobject | nullGeneration input. "{{var:<name>}}" as a whole string becomes the variable's JSON value, inside a longer string its text. Text and media placeholders ({{snippet:…}}, {{ref:…}}, {{asset:…}}) stay…
modelstring | nullRequired unless from_job is given.
offer_idstring | nullOffer from search_prices that prices every run; single-generation recipes only.
providerstring | nullRequired unless from_job is given.
save_toWith steps: where the final steps' outputs are filed.
stepsarray | nullA chain instead of provider/model/input, run in order by one run_recipe: each step is a generation {name, provider, model, input} or an ffmpeg edit {name, op, input: <that tool's parameters>}. Later s…
variablesobject | nullDeclared variables; ones used in input but not listed here are added as required.

save_reference

Create or update a reference: a named, typed set of assets (character, style, product, environment, composition, brand) plus a description, reused in generate input as "{{ref:<name>}}". asset_ids, when given, replaces its assets.

ParameterTypeDescription
name *stringUnique name, used as "{{ref:<name>}}" in generate input, e.g. "main-character".
asset_idsarray | nullWhen given, the reference holds exactly these assets in this order (first = default image).
descriptionstring | nullWhat must stay consistent, e.g. "red-haired woman, cyberpunk jacket".
kindRequired when creating: character, style, product, environment, composition or brand.
tagsstring | nullSpace-separated tags.

save_snippet

Create or replace a snippet: a reusable prompt block (brand style, series paragraph, voice) used as "{{snippet:<name>}}" inside any string of generate input.

ParameterTypeDescription
name *stringUsed as "{{snippet:<name>}}" inside any string of generate input, e.g. "brand-style".
text *stringThe prompt block, e.g. "soft window light, muted teal palette, 35mm". May contain "{{ref:<name>.description}}" but not other snippets.
descriptionstring | null

save_spec

Save a spec as a local override in <home>/providers/ (or add a new provider). Active immediately in every AI Media Router process; returns the check result.

ParameterTypeDescription
spec *stringFull TOML text of the spec. Saved as `<home>/providers/<key>.toml`, active immediately in every process.

search_assets

Search the local asset library by prompt, tags, description and review notes, optionally within one collection, by review status or minimum rating.

ParameterTypeDescription
collectionstring | nullOnly assets in this collection.
limitinteger | nullDefault 20.
min_ratinginteger | nullOnly assets rated at least this (1-5).
querystring | nullWords matched against the generation prompt, tags, description and review notes; omit to list the newest assets.
statusOnly assets with this review status.

search_prices

Find video (USD per second) and image (USD per image) generation offers across providers, cheapest first; kind filters one of them. Offers carry provider_key and offer_id for generate.

ParameterTypeDescription
configured_onlyboolean | nullOnly offers from providers whose keys are set. Default: true when any key is set.
kindstring | null`video` (USD per second) or `image` (USD per image); both when omitted, videos first.
limitinteger | nullDefault 20.
modestring | nullVideo: `generate`, `video input`, `motion / avatar`; image: `generate`, `edit`, `generate + edit`.
providerstring | nullSubstring of the provider name, e.g. "kie".
qualitystring | nullImage quality tier, e.g. "high".
querystring | nullSubstring of the model family or name, e.g. "seedance" or "kling 2.6".
resstring | nullResolution, e.g. "720p" or "1080p".

set_budget

Create a spending cap in USD, or change its limit. Jobs started with generate {budget, estimated_cost_usd} count against it and are refused when they would exceed it.

ParameterTypeDescription
limit_usd *numberSpending cap in USD.
name *stringBudget name, e.g. a session or project; passed as `budget` to generate.

similar_assets

Find assets similar in meaning to a text query or to another asset (embeddings of prompt, tags and description). Needs EMBEDDINGS_API_KEY or EMBEDDINGS_URL in config; search_assets is the keyword search.

ParameterTypeDescription
asset_idstring | nullFind assets similar to this one.
collectionstring | nullOnly assets in this collection.
limitinteger | nullDefault 20.
querystring | nullText to find similar assets for, e.g. "red-haired woman in neon rain". Or use asset_id.

test_key

Check one provider's key with the spec's free [auth_check] request (account, balance or model list): accepted, refused, not_configured, not_supported or inconclusive. Spends nothing and never returns the key.

ParameterTypeDescription
provider *stringProvider key from list_providers, e.g. "fal".

trim

Cut a video or audio asset to start..end seconds; returns the new asset.

ParameterTypeDescription
asset_id *stringA video or audio asset.
endnumber | nullSeconds; default the end of the file.
save_to
startnumber | nullSeconds; default 0.

update_asset

Replace an asset's tags and/or description (both are searched by search_assets).

ParameterTypeDescription
asset_id *string
descriptionstring | nullReplaces the description; searched like prompt and tags.
tagsstring | nullReplaces the tags (space-separated).

upload_asset

Upload a library asset to a provider; returns the reference (URL, file id or data URI) and where to put it in generate input. Usually not needed: "{{asset:<id>}}" in generate input does this automatically.

ParameterTypeDescription
asset_id *string
provider *stringProvider key, e.g. "kie".