Image generation is available for every project with no setup needed (user_pays billing by default). Building a no-login app (like a public photo editor)? user_pays bills the signed-in visitor, so anonymous callers get 401 LOGIN_REQUIRED - set image to owner_pays so it works for everyone (see billing below).
Plan availability: Image generation is limited to 3 uses per month on the Free plan, then unlimited on Pro (Gipity GPU models, below, don't count toward the cap). The cap is checked on the paying user's plan (you under
owner_pays, the signed-in visitor underuser_pays). When that user is on Free and over the cap, this endpoint returns 403 FORBIDDEN with an upgrade message - handle that response in the app's UI.
Two modes: generate OR edit
- Generate (text → image): send just a
prompt, get a brand-new image. - Edit (image + instruction → image): send
promptand animagesarray of source image(s). The prompt is an edit instruction applied to them - "make it night", "add a hat", "remove the car in the background", "turn this into a watercolor". This is how you build a photo editor: upload → edit → show before/after.
Editing runs on Gemini automatically (its image model does instruction editing natively) - you don't pick a provider for it, just pass images (a Gemini model id in model is honoured; anything else is ignored). No GPU job, no custom model, no img2img endpoint to stand up. Same { url, credits_used, ... } response as generation.
For purely mechanical changes that don't need a model - crops, rotations, simple filters, overlays/compositing - do it client-side with canvas/WebGL (free, instant, no round trip).
To switch billing mode (owner_pays ↔ user_pays), declare it in a
type: servicesdeploy phase ingipity.yaml(it ships with the app and every deploy reproduces it). The definitions go underservices:(notservices:):- name: services type: services services: - service: image billing_mode: owner_pays # you pay; no visitor login neededThe same entry can limit providers app-wide:
allowed_providers: [gemini, openai](any other provider is a 400) anddefault_provider: gemini(used when a request names none; must be allowed). Image editing runs ongemini, so keep it in the list if the app edits photos. Both are checked at deploy; remove a key and redeploy to reset it.See deploy for the full services-phase reference and app-llm for billing modes.
Providers & Models
- OpenAI:
gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst - BFL/Flux:
flux-2-pro, flux-2-flex, flux-2-max, flux-2-klein-9b, flux-2-klein-4b, flux-3-image - Gemini/Nano Banana:
gemini-nano-banana-2.1, gemini-3.1-flash-lite-image, gemini-2.5-flash-image, gemini-3.1-flash-image, gemini-3-pro-image
Quality tiers (recommended over pinning a model)
Instead of a concrete model id, pass a quality tier as model - it resolves to a current provider+model that we keep pointed at the best option, so your app keeps working when the model lineup refreshes (a pinned concrete id 400s the day it's retired). A tier sets the provider for you (overriding provider):
fast- cheapest, fastest; for thumbnails, drafts, high-volume generationstandard- balanced general-purpose quality (the sensible default)high- high fidelity; for hero images and detailed scenesultra- maximum fidelity; slowest and most expensive
{ "prompt": "A sunset over mountains", "model": "high" }
GET /image/models returns the live tier→provider/model map (tiers) alongside the concrete model list. Pin a concrete id only when you specifically need that exact model.
Endpoints
GET /api/<PROJECT_GUID>/services/image/models- list available providers and modelsPOST /api/<PROJECT_GUID>/services/image- generate an image
Request Format (POST /image)
{
"prompt": "A sunset over mountains",
"provider": "openai",
"model": "gpt-image-2",
"size": "1024x1024",
"quality": "medium"
}
Fields:
prompt(required): Image description (generate) or edit instruction (edit), max 4,000 charsimages: Edit mode. Array (1-4) of source images to edit - each{ "data": "<base64>", "media_type": "image/png" }(jpeg/png/gif/webp). When present,promptis an edit instruction applied to these images and the request routes to Gemini (provideris ignored for edits;modelis honoured only if it is a Gemini model id). Omit for plain generation.provider: "openai", "bfl", or "gemini" (default: bfl)model: A quality tier -fast,standard,high, orultra(recommended; survives model refreshes and sets the provider) - OR a concrete model id (default: provider's default). See Quality tiers above.size: "WxH" format (default: the provider's default, 512x512 for bfl, 1024x1024 for gemini and openai). OpenAI sizes: 1024x1024, 1024x1536, 1536x1024. BFL: any size (rounded to 32px), exceptflux-3-image, which renders in fixed tiers: the smallest of 768x768, 1K or 2K total area that covers the size you ask for, at the closest supported aspect ratio. Gemini also renders in fixed tiers, never exact pixels: the smallest tier the model supports that covers the long side, at the closest aspect ratio; the response'snotesays when the output won't match the size you asked for. An edit with nosizeoraspect_ratiokeeps the source image's shapequality: OpenAIgpt-image-*models only: low/medium/high/auto (default: medium)aspect_ratio: Gemini only. Aspect ratio: 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 4:5, 5:4, 21:9image_size: Gemini only. Resolution tier (about 512, 1024, 2048 or 4096 px on the long side): 512, 1K, 2K, 4K, but each model supports only some: gemini-nano-banana-2.1 (1K, 2K, 4K); gemini-3.1-flash-lite-image (1K); gemini-2.5-flash-image (1K); gemini-3.1-flash-image (512, 1K, 2K, 4K); gemini-3-pro-image (1K, 2K, 4K). A tier the model lacks is a 400 naming the ones it has. Default: mapped fromsize(1K when neither is set)seed: BFL FLUX.2 models only (ignored by openai/gemini and byflux-3-image, which has no seed input). A non-negative integer that makes generation deterministic - reuse one seed across a series of prompts to keep the images visually coherent (e.g. every illustration in one clip). Omit it for fresh randomness each call.
Response Format
{
"url": "https://media.gipity.ai/med_abc12345.png",
"content_type": "image/png",
"revised_prompt": "...",
"model": "gpt-image-2",
"provider": "openai",
"credits_used": 63.6,
"width": 1024,
"height": 1024
}
The url is a permanent public CDN URL. No auth needed to fetch it. width and height are the real pixel size of the image that came back. A Gemini response also carries note when its tiers couldn't match the size you asked for.
BFL responses also include a seed field - the seed that produced this image (the one you passed, or the random one BFL picked). Capture it and pass it back as seed on later calls to keep a series of images visually coherent.
Gipity GPU models (queued, half price)
Models whose id starts with gipity- run on Gipity's own GPU. Each costs half what other hosts charge for that same model, and you pay with time: they render one after another in a shared queue that can be long. Paid accounts go ahead of free ones in the queue (a free job that has waited an hour joins them), nothing already rendering is ever interrupted, and a job not started within 24 hours expires. Failed, cancelled and expired images are free. They don't count against the Free plan's monthly image cap: credits are the only limit.
- List them (with price, sizes, how many reference and uploaded images each takes, and the current wait) at
GET /services/image/models: they haveprovider: "gipity"andasync_only: true, plus a top-levelgipity_gpu: { online, queue, est_wait_s: { paid, free } }. - They are async only: the plain
POST /imagereturns400 ASYNC_REQUIREDfor them. Use the generations API below. - Shape:
aspect(portrait|square|landscape) instead ofsize;n1-4 (seedsseed,seed+1, ...); optionalavoid(only models withavoid_supported),format(jpegdefault, orpng),text(key/value strings embedded in the full-size file). references: up to the model'smax_referencesearlier succeeded Gipity GPU generations of the same app (ids), to keep the same person, car or place across images; name them in the prompt as "picture 1", "picture 2".images: photos the user uploaded to your app's storage, as[{ file_guid }](upload withGipity.uploadfirst; see app-files). The listing says how each model takes them:image_mode: "reference"models use up tomax_imagesof them like references (uploads andreferencestogether count againstmax_references; name them "picture 1", ...),image_mode: "start"models take one and redraw it from your prompt, withstrength(0.05 to 1, default 0.6) for how much changes, andimage_mode: nullmodels take none.- Uploaded photos are SFW only. A request with
imagescan't sendnsfw: trueor use an NSFW model (VALIDATION_ERROR), and its prompt is checked as SFW. The same holds for anything made from an upload later: a generation withfrom_upload: truepasses that on to every image that uses it as a reference. The rules on minors apply everywhere. - Every prompt passes a safety check; a blocked prompt fails with
CONTENT_BLOCKEDand the reason. - NSFW models (
nsfw: truein the listing) appear only when the app owner's account has "Allow NSFW services" turned on (gipity account nsfw on), and a request for one must sendnsfw: true. Underuser_paysthe signed-in user needs it on too.
Async generations (any image model)
Submit, then get the result later. Works for every model; Gipity GPU models require it.
POST /services/image/generations- body is one request ({ model, prompt, ... }) or{ requests: [ ... up to 16 ... ] }, all-or-nothing. Returns202 { data: [generation, ...] }at once.GET /services/image/generations/:id- one generation.GET /services/image/generations?ids=a,b- several, in order.?status=open- the caller's unfinished ones.POST /services/image/generations/:id/cancel(orPOST .../generations/cancel { ids }) - a queued one is cancelled at once; one already rendering is stopped and reportscancelled.- Get told when it's done instead of polling, with
notifyon the request:notify: { on_complete: "image-done" }- the platform calls that function of your app withctx.body = { type: "image.succeeded" | "image.failed" | "image.cancelled" | "image.expired", data: <generation> }andctx.trigger.type === "generation_complete". It runs as the owner, so the function can beauth: member.notify: { realtime: { room, channel, to_user: true } }- publishesimage.progress(at most every 2 s) and the finalimage.<status>message with{ generation }to that room (see app-realtime);to_usersends it only to the user who asked.
- A generation:
{ id: "gen_...", status: "queued" | "dispatched" | "running" | "succeeded" | "failed" | "cancelled" | "expired", model, prompt, seed, width, height, metadata, queue_position, eta_ms, phase, step, total, progress, outputs, error, credits_charged, from_upload, created_at, started_at, finished_at }.metadata(up to 4 KB) comes back unchanged: put your own row id there. While a Gipity GPU image renders,phase/step/total/progress/eta_msupdate every couple of seconds (andnotify.realtimepushes each change asimage.progress), so show a live progress ring instead of a spinner; a finished one addstimings(GPU ms per phase) andrender_ms. Models in the listing carryrev(bumped when a model's settings change) andfamily. outputs(when succeeded):{ full, display, thumb }, each{ url, file_guid, bytes, mime, width, height }. For Gipity GPU images,fullis the full-size JPEG/PNG,displaya WebP up to 1600 px,thumba WebP up to 256 px; they are private files in your app's storage undergenerations/<id>/(delete them withstorage.delete(file_guid)). Cloud models return justfullwith a CDNurl.
// functions/make-image.js (services: [image], image service owner_pays)
export default async function (ctx, { image, db }) {
const { generations } = await image.submit({
model: 'gipity-krea2-realistic', prompt: ctx.body.prompt, aspect: 'portrait',
metadata: { row: ctx.body.rowId },
notify: { on_complete: 'image-done', realtime: { room: 'studio', channel: 'images', to_user: true } },
});
return { id: generations[0].id, queue_position: generations[0].queue_position };
}
// functions/image-done.js
export default async function (ctx, { db }) {
const g = ctx.body.data;
if (g.status === 'succeeded') await db.query('UPDATE pictures SET file = $1 WHERE id = $2', [g.outputs.full.file_guid, g.metadata.row]);
}
Cost
Each image is billed at what the provider charges for it, plus 20%, and credits_used (1 credit = $0.001) is the exact charge. So the price follows the model, the size, and for Gemini the resolution tier: a bigger tier costs more. Approximate charges for one ~1024px image:
| Model | Credits |
|---|---|
gpt-image-2 (and 2.5) at quality: low |
~7 |
flux-2-klein-4b |
~17 |
flux-2-pro (default) |
~36 |
gemini-nano-banana-2.1 |
~47 (2K ~66, 4K ~142) |
gpt-image-2 at quality: medium |
~64 |
gemini-3.1-flash-image |
~82 (512 ~55, 2K ~122, 4K ~183) |
gemini-3-pro-image |
~165 (4K ~291) |
FLUX.2 bills per megapixel, so a 1440x1440 image costs a bit more than 1024x1024. OpenAI defaults to quality: medium (~64 credits at 1024x1024); high or auto (which often picks high) costs up to ~250. For high-volume generation, use the fast tier or a small size.
CLI
For one-off image generation during development (downloads the result to a local file), skip the HTTP call and use gipity generate image. It writes to ./generated.png in the current directory by default - pass -o <path> to land the file directly in your source tree so it deploys:
gipity generate image "a cat wearing a top hat" -o src/assets/images/hat-cat.png
gipity generate image "landscape sunset" --provider gemini --aspect-ratio 16:9 -o src/assets/images/hero.png
gipity generate image "product photo" --provider openai --model gpt-image-2 --size 1536x1024 --quality high -o src/assets/images/product.png
Gipity GPU models from the CLI wait in the queue and show the position, then save the file: gipity generate image "a red canoe at dawn" --model gipity-krea2-realistic --aspect landscape -o src/assets/canoe.jpg. --no-wait prints the generation id and exits; gipity generate status|cancel|list follow up, and gipity generate models lists every image model with prices and the current wait.
To edit an existing image (the photo-editor flow) from the CLI, pass --input <file> - the prompt becomes an edit instruction and, with a cloud model, it routes to Gemini automatically (same as the images app-service param). Use this to verify the edit end-to-end without hand-rolling a token + base64 POST:
gipity generate image "make it night time" --input photo.jpg -o after.png
With a Gipity GPU model, --input uploads each photo privately to your project and sends it as images: a start-mode model redraws it (--strength 0.05-1, default 0.6) and a reference model uses the photos as "picture 1", "picture 2". SFW only, so --nsfw can't be combined with --input:
gipity generate image "the same street at night" --model gipity-krea2-realistic --input street.jpg --strength 0.5 -o night.jpg
Client Code Example
Call it with the client SDK's Gipity.service('image', body) (auto-injected into every deployed page). It finds this instance's API, mints and caches the app token, sends the signed-in user's session (so user_pays resolves the payer), and throws on non-2xx with err.status set (403 plan cap, 402 out of credits, 401 sign-in needed). Don't hand-roll fetch with a hardcoded a.gipity.ai; see app-llm for the raw-fetch details if you ever need them.
The image service replies with a flat body - url, content_type, model, credits_used at the top level, which Gipity.service returns as is.
const { url } = await Gipity.service('image', { prompt: 'A cat wearing a top hat' });
// Display
const img = document.createElement('img');
img.src = url; // permanent public CDN URL
document.body.appendChild(img);
Editing an uploaded photo (before/after)
A photo editor uploads the user's picture, sends it with an edit instruction, and shows the result next to the original. Read the file the user picked as base64 and pass it as images:
// file is a File from <input type="file">
const dataUrl = await new Promise((r) => {
const fr = new FileReader();
fr.onload = () => r(fr.result);
fr.readAsDataURL(file);
});
const base64 = dataUrl.split(',')[1]; // strip the "data:...;base64," prefix
const media_type = file.type; // e.g. "image/png"
const { url } = await Gipity.service('image', {
prompt: 'make it night time', // the plain-English edit
images: [{ data: base64, media_type }],
}); // url of the edited image
// Show it beside the original for a before/after.
Keep inline images reasonable (the request body caps at 10 MB - a base64 photo is ~1.33× its byte size). Downscale a huge camera photo on a canvas before sending, or for very large originals upload via app-files first. From a serverless function it's the same, via the injected image() service:
const edited = await services.image({ prompt: 'add a party hat', images: [{ data, media_type: 'image/jpeg' }] });
Limits
- Rate limit: 600 requests per 5-minute window (per caller: API key, signed-in user, else IP)
- Max prompt length: 4,000 chars
- Timeout: 120s
- Standard
RateLimit-*headers included in responses