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 under user_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

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: services deploy phase in gipity.yaml (it ships with the app and every deploy reproduces it). The definitions go under services: (not services:):

- name: services
  type: services
  services:
    - service: image
      billing_mode: owner_pays   # you pay; no visitor login needed

The same entry can limit providers app-wide: allowed_providers: [gemini, openai] (any other provider is a 400) and default_provider: gemini (used when a request names none; must be allowed). Image editing runs on gemini, 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

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):

{ "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

Request Format (POST /image)

{
  "prompt": "A sunset over mountains",
  "provider": "openai",
  "model": "gpt-image-2",
  "size": "1024x1024",
  "quality": "medium"
}

Fields:

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.

Async generations (any image model)

Submit, then get the result later. Works for every model; Gipity GPU models require it.

// 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