Skip to content
Guides

Upload Image to API: URLs, Base64 and Upload IDs

How to send your own pictures, frames, faces and clips to an image or video API: URLs, base64 data URIs or upload ids, with limits, formats and expiry.

Updated 7 min read

To upload an image to an API for generation, you have three choices: put a public URL in the request, paste the picture inline as a base64 data URI, or send the file once to an upload endpoint and use the id it returns. On Frameport all three work for reference pictures, first and last frames and faces; a clip on your disk goes up as an upload, and anything you already generated needs none of them, because its file_… id can be sent as it is.

This guide compares the ways, shows which field takes what, lists the limits and formats, explains how long each id lives, and ends with a script that uploads a clip and a face and runs Frameport Replace 1 on them.

Three ways to upload an image to the API

WayLooks likeBest forWatch out for
Public URLhttps://cdn.example.com/look.jpgFiles already online, on your CDN or a public bucketIt must open without a login or cookies, and still open when the job reads it
Base64 data URIdata:image/png;base64,iVBORw0…A small picture in one self-contained requestPictures only, and the whole request body is 16 MB at most
Upload idupl_7Rk2PqV9wXm4Tn8Lc1BdZeFiles on your disk, every clip, a picture used in several requestsOne extra call first, and the id lasts a day
Your own outputfile_8Hc2RkQw5ZpT1mVb7nXe3LChaining jobs: an image becomes a frame, a clip goes to an editFinished outputs of the same workspace only

Choosing is quick. When the file already sits at a public https address, send the URL. When it lives on your disk or behind a login, upload it. Keep data URIs for small pictures, where one request without a second call matters more than its size. And when the file came out of an earlier job, pass its file_… id: there is nothing to download or send again.

How a URL is read depends on the request. For an image or video generation, the link is handed to the model as you sent it, so the model's servers must be able to open it. For a clip edit, Frameport downloads the file itself: the URL must be https, on a public host name rather than an IP address, without credentials, and every redirect is checked the same way (the clip rules). A presigned link from your storage works in both cases, as long as it does not expire before the job starts reading.

Which fields take a file

FieldEndpointWhat it isTakes
reference_imagesPOST /v1/images/generationsPictures to keep or to editURL, data URI, picture upload, image output
reference_imagesPOST /v1/videos/generationsThe first frame, or with "reference_mode": "identity" the people, products or places to keepURL, data URI, picture upload, image output
end_imagePOST /v1/videos/generationsThe last frameURL, data URI, picture upload, image output
videoPOST /v1/videos/editsThe clip to edithttps URL, clip upload, video output
facesPOST /v1/videos/editsOne picture per person replacedhttps URL, data URI, picture upload, image output

Not every model reads pictures. Frameport Image 1 takes up to 10 and edits a picture by instruction, and Nano Banana Pro up to 6. GPT Image 2.5 Sunburst, Nano Banana 2.1 and Seedream 5.0 Pro read none: they render from the prompt alone. On the video side, Seedance 2.5 takes a first and a last frame, or up to 4 reference pictures (frames, references). Each model page says what it takes, and the image to video guide covers frames in depth.

One request can mix the forms. Here a product shot on your CDN, a logo uploaded earlier and an image you generated last week go into the same Frameport Image 1 edit:

POST /v1/images/generations
{
  "model": "fp-image-1",
  "prompt": "Put the logo from the second picture on the bottle from the first, in the light of the third",
  "reference_images": [
    "https://cdn.example.com/bottle.jpg",
    "upl_3Tn8Lc1BdZeR7Rk2PqV9wX",
    "file_2Tn7XcQ9vLm4Ra8Ws1KbZd"
  ],
  "aspect_ratio": "4:3"
}

Uploads and their ids

POST /v1/uploads takes the file itself as the request body, not a multipart form, with its Content-Type and an optional filename in the query. The file streams through as it arrives, and its first bytes are checked, so it has to be what its type says it is. The answer is the upload, with the id you will send:

201 Created
{
  "id": "upl_7Rk2PqV9wXm4Tn8Lc1BdZe",
  "object": "upload",
  "type": "video",
  "status": "ready",
  "content_type": "video/mp4",
  "bytes": 18327441,
  "filename": "dance.mp4",
  "created_at": "2026-11-28T10:00:00.000Z",
  "expires_at": "2026-11-29T10:00:00.000Z"
}

An upload belongs to its workspace: a key of another workspace cannot use it, and a picture upload cannot stand in for a clip or the other way round. GET /v1/uploads/{id} reads its status (ready, expired or deleted), and DELETE /v1/uploads/{id} removes the file at once. A workspace keeps up to 100 uploads live at a time. Uploading costs nothing; it has its own limit of 10 a minute, apart from the 60 requests a minute that start work (uploads).

Limits and formats

PicturesClips
FormatsPNG, JPEG or WebP (a data URI on a generation may also be GIF)MP4 or MOV
Upload size10 MB100 MB, then each editor's own cap
As a data URIAbout 6 MB a picture on a generation, 10 MB for a faceNot taken
As a URLhttp or https on a generation; https on a clip edithttps, public host

Clips meet a second set of limits, set by the editor they go to. Frameport Replace 1 takes 2 to 10 seconds at 24 frames a second, up to 64 MB, and Frameport Upscale 1 takes 1 to 30 seconds (5 s billed at least), up to 100 MB and 900 frames. GET /v1/models lists them in each editor's edit block (formats, lengths, size, frames, faces), so your app can check a file before it uploads anything (editor limits).

When something is off, the answer says what before anything is held: 400 invalid_video for a clip outside the editor's limits, 400 invalid_input for a picture that cannot be used, and 413 for a body over 16 MB, whose message suggests sending images by URL. Nothing is charged for any of them (error codes).

Expiry: how long each one lasts

  • An upload works for 24 hours (expires_at). A request that uses it keeps it at least 3 hours longer, while the job reads it. Once it has expired or been deleted, a request that names it is refused with 400 file_expired before anything is held.
  • An output (file_…) carries a signed url that opens without a key for 60 to 70 minutes, and your key downloads it any time until the file is no longer stored. Outputs are not kept forever, so copy the ones you keep (keep what you need).
  • A URL lasts as long as your host serves it.
  • A data URI has no id and no expiry: it travels inside the request that uses it, so each request carries it again.

Delete an upload only once the job that reads it has settled: a generation still reading a deleted file may fail.

Upload a clip and a face, then swap

This script sends a clip and a photo from your disk, swaps the face with Frameport Replace 1, saves the result and then deletes both uploads. Use faces only with the consent of everyone involved: the person in the clip and the person whose picture you send (acceptable use).

swap_from_disk.py
import os
import time

import requests

API = "https://frameport.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['FRAMEPORT_API_KEY']}"}


def upload(path, content_type):
    with open(path, "rb") as f:
        res = requests.post(
            f"{API}/uploads",
            params={"filename": os.path.basename(path)},
            headers={**HEADERS, "Content-Type": content_type},
            data=f,
        )
    body = res.json()
    if not res.ok:
        raise SystemExit(f"{path}: {body['error']['message']}")
    return body["id"]


clip = upload("dance.mp4", "video/mp4")
face = upload("face.jpg", "image/jpeg")

gen = requests.post(
    f"{API}/videos/edits",
    headers={**HEADERS, "Idempotency-Key": f"swap-{clip}"},
    json={
        "model": "fp-replace-1",
        "video": clip,
        "faces": [face],
        "resolution": "768p",
        "max_cost_usd": 1.2,
    },
).json()
if gen.get("error"):
    raise SystemExit(f"{gen['error']['code']}: {gen['error']['message']}")

while gen["status"] in ("queued", "running"):
    time.sleep(10)
    gen = requests.get(f"{API}/generations/{gen['id']}", headers=HEADERS).json()

if gen.get("error"):
    print("Failed, nothing charged:", gen["error"]["message"])
else:
    video = requests.get(f"{API}/generations/{gen['id']}/content", headers=HEADERS)
    with open("swapped.mp4", "wb") as out:
        out.write(video.content)
    print("Saved swapped.mp4, charged", gen["cost_usd"])

# The edit has settled, so the uploads can go
for upload_id in (clip, face):
    requests.delete(f"{API}/uploads/{upload_id}", headers=HEADERS)

An edit holds the price of the longest clip the model takes, then comes down to your clip's own price once it is measured, which is why the cap is set for 10 seconds. The face swap video API guide covers several faces, targets and keeping the outfit.

The same uploads feed a video generation. With "reference_mode": "identity", a face uploaded once and a product you generated earlier become the cast of a Seedance 2.5 clip:

POST /v1/videos/generations
{
  "model": "seedance-2-5",
  "prompt": "The woman from the first picture unboxes the speaker from the second on a sunny kitchen counter",
  "reference_images": ["upl_3Tn8Lc1BdZeR7Rk2PqV9wX", "file_8Hc2RkQw5ZpT1mVb7nXe3L"],
  "reference_mode": "identity",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "9:16"
}

Your key is what lets these files in, so keep it on your server (API key security). What the pictures do once sent depends on the job: identity pictures in reference to video, faces in video ad localization and AI headshots.

FAQ

How do I upload an image to an API in Python?

Send the file's bytes as the body of POST /v1/uploads with its Content-Type, as in the upload function above, then put the upl_… id it returns in reference_images, end_image or faces. For a picture already online, skip the upload and send its URL.

Can I send a base64 image instead of a URL?

Yes, as a data URI such as data:image/png;base64,…, in any field that takes a picture. It suits small pictures: about 6 MB each on a generation, and the whole request body is 16 MB at most. Clips cannot be sent this way.

How do I upload an image to the Veo 3.1 API?

Veo 3.1 takes a first frame and a last frame, or up to 3 reference pictures, in reference_images and end_image. Each can be a URL, a data URI, an upload id or one of your image outputs, sent with the same key as every other model.

Can GPT Image 2.5 read an image I upload?

Not here. GPT Image 2.5 Sunburst and GPT Image 2.5 Flare render from the prompt only on Frameport. To edit a picture by instruction, send it to Nano Banana Pro or Frameport Image 1.

How long does an uploaded file last?

24 hours from the upload, and at least 3 hours more once a request uses it. DELETE /v1/uploads/{id} removes it sooner; after that, a request naming it is refused with 400 file_expired and nothing is charged.

Why was my uploaded clip refused?

It misses a limit of the editor you sent it to: its length, its size, its frame count or its format. The 400 invalid_video message names the limit, nothing is charged, and GET /v1/models lists every editor's limits so you can check before uploading.

Start building.

Your API key is free. Top up from $10 when you are ready.