Use MuAPI's unified asynchronous API for image and video generation when a workflow needs model choice without a separate integration for every provider. The catalog and each model's input schema are authoritative; this skill does not guess fields, bundle an SDK, or hide a billable generation request. For a capability overview, see the MuAPI AI video API.
MUAPI_API_KEY in the environment. Never ask the user to paste it
into chat, source files, command history, or logs.| Operation | Method and endpoint |
|---|---|
| List current models | GET https://api.muapi.ai/api/v1/models |
| Read one model's schema | GET https://api.muapi.ai/api/v1/models/{model} |
| Submit a generation | POST https://api.muapi.ai/{catalog endpoint} |
| Poll a prediction | GET https://api.muapi.ai/api/v1/predictions/{request_id}/result |
Generation and prediction requests use:
x-api-key: $MUAPI_API_KEY
Content-Type: application/json
The catalog returns a model name, category, endpoint, and other metadata. The
endpoint value already includes /api/v1/; append it to https://api.muapi.ai
without adding a second version prefix. Model input and output fields vary, so
read the selected model's schema immediately before preparing a request.
Use a temporary directory for response files and keep credentials out of every file. The catalog lookup is read-only:
workdir=$(mktemp -d "${TMPDIR:-/tmp}/muapi-media.XXXXXX")
curl --fail --silent --show-error \
--header "Accept: application/json" \
"https://api.muapi.ai/api/v1/models" \
--output "$workdir/models.json"
jq -r '
.models[]
| select(((.category // "") | ascii_downcase | test("image|video|audio|3d")))
| [.name, .category, .endpoint]
| @tsv
' "$workdir/models.json"
Select a model from the current catalog, then fetch its detailed schema. Do not copy a payload from a different model just because the names look similar:
export MUAPI_MODEL="<model name from the catalog>"
curl --fail --silent --show-error \
--header "Accept: application/json" \
"https://api.muapi.ai/api/v1/models/${MUAPI_MODEL}" \
--output "$workdir/model.json"
jq '.input_schema.schemas.input_data' "$workdir/model.json"
Check required fields, types, enum values, size limits, and the output schema. If the model requires an image or video input, use the exact documented field and an authorized HTTPS input URL; do not invent an upload contract.
Set the key only in the environment and stop before submission if it is absent:
test -n "${MUAPI_API_KEY:-}" || {
echo "Set MUAPI_API_KEY before generation." >&2
exit 1
}
export MUAPI_PROMPT="A small paper boat crossing a calm pond at sunrise, steady camera"
# Add only fields confirmed by model.json. This example uses a prompt field;
# many models also require duration, resolution, aspect ratio, or an input URL.
jq -n \
--arg prompt "$MUAPI_PROMPT" \
'{prompt: $prompt}' \
> "$workdir/request.json"
Review the model, requested parameters, destination, and estimated cost with
the user. Do not put MUAPI_API_KEY in request.json.
Resolve the catalog endpoint and make one POST. Do not automatically retry a generation POST after a timeout: the original task may have been accepted.
model_endpoint=$(jq -er --arg name "$MUAPI_MODEL" '
.models[]
| select(.name == $name)
| .endpoint
| select(type == "string" and startswith("/api/v1/"))
' "$workdir/models.json")
curl --fail --silent --show-error \
--request POST \
"https://api.muapi.ai${model_endpoint}" \
--header @- \
--header "Content-Type: application/json" \
--data "@$workdir/request.json" \
--output "$workdir/submit.json" <<EOF
x-api-key: ${MUAPI_API_KEY}
EOF
request_id=$(jq -er '
.request_id // .id // .data.request_id // .data.id // .output.id
| select(type == "string" and length > 0)
' "$workdir/submit.json")
Keep the request ID for diagnosis. Never print request headers or the key.
Poll the original request ID, accept only documented terminal states, and stop after a bounded number of attempts. The response shape can vary, so use the selected model's output schema when extracting the result URL:
result_url="https://api.muapi.ai/api/v1/predictions/${request_id}/result"
for attempt in $(seq 1 120); do
curl --fail --silent --show-error \
"$result_url" \
--header @- \
--output "$workdir/result.json" <<EOF
x-api-key: ${MUAPI_API_KEY}
EOF
status=$(jq -r '.status // .data.status // .output.status // "unknown"' \
"$workdir/result.json")
case "$status" in
completed|succeeded|success) break ;;
failed|error|canceled|cancelled|timeout)
jq -r '.error // .data.error // .output.error // "MuAPI generation failed"' \
"$workdir/result.json" >&2
exit 1
;;
esac
sleep 2
done
test "$status" = completed \
|| test "$status" = succeeded \
|| test "$status" = success
Do not create a second paid task merely because polling was interrupted. First poll the known request ID again and inspect its sanitized status.
Extract an HTTPS output URL using the model's output schema. Download it with a fresh request that has no MuAPI header, validate the file, and only then return or publish it:
output_url=$(jq -er '
.output.outputs[0]
// .data.output.outputs[0]
// .outputs[0]
// .data.outputs[0]
// .output.video
// .data.output.video
| select(type == "string" and startswith("https://"))
' "$workdir/result.json")
curl --fail --silent --show-error \
"$output_url" \
--output "$workdir/output.bin"
test -s "$workdir/output.bin"
file "$workdir/output.bin"
Do not add x-api-key to this request. Reject non-HTTPS output URLs, avoid
following unvalidated redirects, and use a downloader that checks each
redirect destination and DNS result when the service returns a redirecting or
user-controlled URL. Never execute a downloaded file as code.
curl --fail --silent --show-error \
"https://api.muapi.ai/api/v1/models" \
| jq -r '.models[] | [.name, .category, .endpoint] | @tsv'
1. Discover a current Text to Video model.
2. Fetch its detailed input_schema and confirm that prompt and the requested
duration/resolution fields are accepted.
3. Obtain approval, submit one POST with MUAPI_API_KEY, and save request_id.
4. Poll the result endpoint at most 120 times.
5. Download the HTTPS output without the API key and validate the video file.
MUAPI_API_KEY in JSON payloads or
process arguments; pass authenticated curl headers through protected stdin or
a protected config file.