Before you can use a local file as a reference image or audio input in any generation call, you need to upload it to Muapi.ai to receive a hosted URL. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/anil-matcha/open-generative-ai/llms.txt
Use this file to discover all available pages before exploring further.
uploadFile function handles this using a multipart/form-data POST to /api/v1/upload_file and uses an XMLHttpRequest internally so you can track upload progress in real time. The returned URL is what you pass as image_url, audio_url, or inside the images_list array in downstream generation calls.
uploadFile(apiKey, file, onProgress)
Upload a single file to Muapi.ai and receive a hosted URL. Uses XMLHttpRequest for browser-native progress events and resolves the URL from the url, file_url, or data.url field in the JSON response.
Your Muapi.ai API key. Obtain one at muapi.ai/access-keys.
A browser
File object. Typically obtained from an <input type="file"> element or a drag-and-drop handler. The file is sent as the file field in a FormData body.Optional progress callback invoked as the upload proceeds. Receives a single
percent argument — an integer from 0 to 100 computed from event.loaded / event.total.Promise<string> — resolves to the hosted URL string of the uploaded file. Rejects with an Error if the upload fails, the server returns a non-2xx status, or the response body contains no URL.
uploadFile is browser-only. It relies on XMLHttpRequest and FormData, which are not available in Node.js. For server-side uploads, post the file as multipart/form-data directly to https://api.muapi.ai/api/v1/upload_file with the x-api-key header using any HTTP library that supports multipart bodies.Example — upload a reference image with progress tracking
Supported File Types
Pass files matching the formats expected by the downstream model. Sending an incompatible type will cause the generation call (not the upload itself) to fail.| Use case | Accepted formats |
|---|---|
| Image models (reference images, style inputs) | JPEG, PNG, WebP, GIF |
| Lip sync models (audio-driven talking video) | MP3, WAV, M4A |
Upload History and localStorage Caching
The Open Generative AI app caches every uploaded URL (along with a thumbnail) inlocalStorage so the same file is not re-uploaded across browser sessions. When you open the reference image picker, all previously uploaded images appear as reusable thumbnails. The cache key is upload_history and each entry stores the hosted URL and a display name.
If you are embedding uploadFile in your own application and want to replicate this behaviour, store the returned URL in localStorage after a successful upload:
Multi-Image Upload
Models that accept multiple reference images (such asnano-banana-2-edit, which supports up to 14 images) require an images_list array rather than a single image_url. Upload each file individually with uploadFile, collect the returned URLs, then pass the array to the generation call.
images_list input with varying maximum counts:
| Model | Max images |
|---|---|
| Nano Banana 2 Edit | 14 |
| Nano Banana Edit | 10 |
| Flux Kontext Dev I2I | 10 |
| Kling O1 Edit Image | 10 |
| GPT-4o Edit / GPT Image 1.5 Edit | 10 |
| Bytedance Seedream Edit v4 / v4.5 | 10 |
| Flux 2 Flex/Pro Edit | 8 |
| Nano Banana Pro Edit | 8 |
| Vidu Q2 Reference to Image | 7 |
| GPT-4o Image to Image | 5 |
| Flux 2 Klein 4b/9b Edit | 4 |
| Qwen Image Edit Plus / 2511 | 3 |
| Wan 2.5/2.6 Image Edit | 2–3 |
| Flux Kontext Pro/Max I2I | 2 |
Server-Side Upload
uploadFile uses XMLHttpRequest and cannot run in Node.js or edge runtimes. For server-side environments — such as a Next.js API route, a background job, or a CLI tool — post the file as multipart/form-data directly to https://api.muapi.ai/api/v1/upload_file with the x-api-key header, using any HTTP library that supports multipart bodies (e.g., form-data + node-fetch, axios, or undici).
For standard browser usage,
uploadFile is the recommended path — it handles the multipart encoding, progress events, and URL extraction automatically.