Prerequisites

  1. A Mosaic account – Sign up or join the waitlist
  2. An API key starting with mk_… from the Developer Portal
  3. curl, jq (optional), and a video file

1. Set credentials

export MOSAIC_API_KEY="YOUR_API_KEY_HERE"
export BASE_URL="https://api.usemosaic.ai/api"

2. Request upload URL

curl -s -X POST "$BASE_URL/video/get-upload-url" \
  -H "Authorization: Bearer $MOSAIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "YOUR_FILENAME_HERE",
    "file_size": YOUR_FILE_SIZE_IN_BYTES,
    "content_type": "YOUR_VIDEO_FORMAT_HERE"
  }' > upload.json

3. Extract upload details

UPLOAD_URL=$(jq -r .upload_url upload.json)
VIDEO_ID=$(jq -r .video_id upload.json)

4. Upload video file

curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: YOUR_CONTENT_TYPE_HERE" \
  --data-binary @YOUR_VIDEO_FILE_PATH

5. Finalize upload

curl -s -X POST "$BASE_URL/video/finalize-upload/$VIDEO_ID" \
  -H "Authorization: Bearer $MOSAIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}' | jq -r .file_uuid > file_id.txt

FILE_ID=$(cat file_id.txt)

6. Run an agent

Let Mosaic choose an agent based on your prompt:
curl -s -X POST "$BASE_URL/run-agent" \
  -H "Authorization: Bearer $MOSAIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "file_id": "'$FILE_ID'",
    "prompt": "YOUR_PROMPT_HERE"
  }' > run.json

7. Save run ID

RUN_ID=$(jq -r .agent_run_id run.json)

8. Check status

until [[ $(curl -s "$BASE_URL/get-agent-run-simple/$RUN_ID" \
  -H "Authorization: Bearer $MOSAIC_API_KEY" | jq -r .status) != "running" ]]; do
  echo -n "."; sleep 5;
done

9. Get output URLs

curl -s "$BASE_URL/get-agent-run-outputs/$RUN_ID" \
  -H "Authorization: Bearer $MOSAIC_API_KEY" > outputs.json

10. Download result

curl -L $(jq -r .outputs[0].download_url outputs.json) -o enhanced.mp4
🎉 Your AI-enhanced video is ready!
The auto flag lets Mosaic’s AI pick sensible defaults based on your video content.