AI Headshot Generator API: Portraits From Your Photos
An AI headshot generator API for your app: portraits from a few photos of the person who asked, style prompts, batches, consent and per-image cost.
Updated 6 min read
An AI headshot generator API takes a few photos of a person and returns professional portraits of them: a studio backdrop, business clothes, a flattering light. On Frameport that is one request to POST /v1/images/generations, with the photos in reference_images, on Frameport Image 2, Frameport Image 3 or Frameport Image 1, billed per image. The photos are the user's own, or photos of people who agreed to this use.
This guide covers what a headshot app needs, which photos to ask for, prompts for each style, a batch in Python, what a set costs, and consent.
What an AI headshot generator API app needs
- Photos in. The user uploads a few photos; your server sends them to
POST /v1/uploadsand keeps theupl_…ids. Pictures are PNG, JPEG or WebP, up to 10 MB each, and an upload lasts 24 hours (uploads). - Consent in the product. The account holder confirms the photos are of them, or that the person in them agreed. More on that below.
- A few styles. A prompt template per look, with the person's photos as the references every time.
- A price before the click.
POST /v1/generations/quoteprices the batch without holding anything, so the app can show it first (quotes). - Delivery. Each output has a signed link that lasts about an hour: copy the portraits to your storage, and let the user delete them (files).
- The key on your server. The app calls your backend, which calls the API; the key never ships in a browser or a phone app (keep keys on the server).
Three of our engines read reference pictures and render portraits:
| Engine | Reference photos | Use it for | Per image |
|---|---|---|---|
| Frameport Image 2 | Up to 4, included | A portrait planned like a shoot: backdrop, light, lens | $0.025 |
| Frameport Image 3 | Up to 4, included | A clean finish on the face, the same person across a series | $0.025 |
| Frameport Image 1 | Up to 10, a fee for each after the first | Editing a photo the user already likes, by instruction | $0.025 |
From other makers, Nano Banana Pro also takes up to 6 pictures and edits by instruction, under its maker's policies. The other image models in the catalog read no pictures, so they cannot make a portrait of a given person.
Reference photos that work
The engine can only keep what the photos show. Ask your users for:
- The face clearly visible: not hidden by hair, hands, sunglasses or deep shadow, at a size where the eyes are sharp.
- A few angles and lights: facing the camera, a three-quarter view, one indoors and one by daylight. Different photos tell the engine what stays the same.
- One person per photo, recent, without beauty filters.
- Not more than the engine takes: up to 4 on Frameport Image 2 and Frameport Image 3. On Frameport Image 1, which takes more, each photo after the first adds a small fee to every image; a quote's
breakdownshows it.
To fix the person for a long series, keep the portrait the user prefers and send its file_… id as the reference from then on, as the consistent character image API guide explains.
Styles and backgrounds
A style is a few words in the prompt. Keep one base that tells the engine to keep the person, and change only the clothes, the backdrop and the light:
| Style | Words to add |
|---|---|
| Corporate | navy suit jacket, plain light grey studio backdrop, soft key light from the left |
| Creative | black crew-neck sweater, warm textured plaster wall, window light from the side |
| Outdoor | open-collar shirt, city street softly out of focus behind, late-afternoon light |
| Actor | plain dark top, neutral grey backdrop, even light, no retouching look |
| Medical or legal | white coat or dark blazer, softly blurred office behind, bright even light |
- Shape:
3:4for a portrait,1:1for a profile picture or an avatar. - The vocabulary of a shoot works better than "realistic": a focal length (85mm), an aperture (f/2.8), named light sources. The photorealistic image generation API guide breaks a prompt into those parts.
- Edit a photo instead of rendering a new one. On Frameport Image 1, a single photo and an instruction change what you ask for and leave the rest: "keep the person and the pose exactly as they are; replace the background with a plain light grey studio backdrop and the T-shirt with a navy blazer".
A headshot batch in Python
This script uploads the user's photos, asks for four takes of each style, saves the portraits, then deletes the photos:
import os
import sys
import time
import requests
API = "https://frameport.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['FRAMEPORT_API_KEY']}"}
MODEL = "fp-image-2"
MAX_PHOTOS = 4 # the reference pictures this model takes
BASE = ("Professional headshot of the person in the reference pictures, keeping their face, hair and features "
"exactly as they are. Head and shoulders, looking into the camera, {style}, 85mm portrait lens, f/2.8")
STYLES = {
"corporate": "navy suit jacket, plain light grey studio backdrop, soft key light from the left",
"creative": "black crew-neck sweater, warm textured plaster wall, window light from the side",
"outdoor": "open-collar shirt, city street softly out of focus behind, late-afternoon light",
}
def upload(path):
kind = "image/png" if path.lower().endswith(".png") else "image/jpeg"
with open(path, "rb") as photo:
res = requests.post(f"{API}/uploads", params={"filename": os.path.basename(path)},
headers={**HEADERS, "Content-Type": kind}, data=photo, timeout=120)
res.raise_for_status()
return res.json()["id"]
# Photos of the person who asked, or of someone who agreed
photos = [upload(path) for path in sys.argv[1:][:MAX_PHOTOS]]
pending = {}
for name, style in STYLES.items():
gen = requests.post(f"{API}/images/generations", headers=HEADERS, timeout=60, json={
"model": MODEL,
"prompt": BASE.format(style=style),
"reference_images": photos,
"aspect_ratio": "3:4",
"n": 4,
}).json()
if gen.get("error"):
raise SystemExit(f"{name}: {gen['error']['code']}: {gen['error']['message']}")
pending[gen["id"]] = name
os.makedirs("headshots", exist_ok=True)
while pending:
time.sleep(3)
for gen_id, name in list(pending.items()):
gen = requests.get(f"{API}/generations/{gen_id}", headers=HEADERS, timeout=30).json()
if gen["status"] in ("queued", "running"):
continue
del pending[gen_id]
for index, output in enumerate(gen["outputs"]):
if output["status"] != "succeeded":
continue # an image that failed is not charged
extension = output["content_type"].split("/")[-1]
with open(f"headshots/{name}-{index + 1}.{extension}", "wb") as out:
out.write(requests.get(output["url"], timeout=120).content)
print(name, gen["status"], "charged", gen["cost_usd"])
# The portraits are saved: delete the photos now rather than in 24 hours
for upload_id in photos:
requests.delete(f"{API}/uploads/{upload_id}", headers=HEADERS, timeout=30)Each request holds the price of its four images and charges each one as it succeeds, so an image that fails costs nothing. Deleting an upload stops it at once, which is why the script waits for every portrait before it does. The image generation API in Python guide explains each call, and the images reference lists every field.
What a headshot set costs
| Images | Frameport Image 2 | Frameport Image 3 | Frameport Image 1, one photo |
|---|---|---|---|
| 1 | $0.025 | $0.025 | $0.025 |
| 12 (three styles, four takes) | $0.30 | $0.30 | $0.30 |
| 100 | $2.50 | $2.50 | $2.50 |
The aspect ratio and the prompt do not move the price; on Frameport Image 1, extra photos do, by the fee a quote shows. A max_cost_usd field caps any request built from user input. Images are paid from a prepaid balance, with no subscription (pricing), and you can try Frameport Image 2 online before writing code.
Consent: whose photos
Headshots are made from the user's own photos, or from photos of people who agreed to this use. Build that into the product:
- Ask before the upload, in words the user has to confirm: these are photos of me, or of someone who agreed.
- Never minors. No school photos, no children's portraits.
- Never someone who did not agree: a colleague's profile picture, a celebrity, a photo found online.
- Say what you keep, and for how long. Delete the photos once the portraits are made, and the portraits when the user asks.
The acceptable use policy applies to every picture you send: nothing involving minors, no real, identifiable person without their consent (faces from photos of private persons included), nothing illegal, impersonation and fraud included. If people use your app, you answer for what they generate through your keys. A request that is refused answers 400 content_policy and costs nothing.
Sending the photos themselves is covered in upload image to API, what costs nothing while you build in the free image generation API guide, and keeping your app's key safe in API key security.
FAQ
What is an AI headshot generator API?
An API that takes photos of a person and returns professional portraits of them. Here, the photos go in reference_images of an image request, the prompt sets the clothes, the backdrop and the light, and each image is billed as it comes out.
Is there a free AI headshot API?
The account, the API key and quotes are free, and an image that fails is never charged. The portraits themselves are paid from a prepaid balance, at $0.025 an image on Frameport Image 2.
How many photos does an AI headshot generator need?
A few clear ones from different angles and lights, up to 4 on Frameport Image 2 and Frameport Image 3. Photos where the face is sharp and unhidden matter more than their number.
Can I make headshots of someone else?
Only if they agreed to it. A real, identifiable person without their consent is never allowed, and neither is anything involving minors.
Which engine makes the most realistic headshots?
It depends on the face and the style, and your own test is the answer. One key calls all three engines, so send the same photos and prompt to each and compare.