Image API

Generate, edit, and upscale images. 142 models from $0.003/image. Cost estimation before execution.

POST /v1/generations/image

Generate an image from a text prompt. Returns the image URL and exact cost.

Request body

FieldTypeRequiredDescription
modelstringYesModel key (e.g. "gpt-image-1.5-t2i", "z-image-turbo"). See Model Catalog.
promptstringYesText description of the image to generate.
negative_promptstringNoElements to exclude from the image.
aspect_ratiostringNoAspect ratio: "1:1", "16:9", "9:16", "4:3", "3:4". Default: "1:1".
image_sizestringNoExplicit size: "1024x1024", "1280x720", etc. Overrides aspect_ratio.
seedintegerNoFixed seed for reproducible outputs.
imagestring (URL)NoSource image URL for image-to-image editing.
confirmbooleanNoSet to false to get a cost estimate without generating. Default: true.

Response fields

FieldTypeDescription
idstringUnique generation ID (gen_ prefix).
statusstring"completed" or "failed".
urlstringCDN URL of the generated image.
modelstringModel key used for generation.
modalitystringAlways "image".
cost.microintegerCost in microdollars (1 microdollar = $0.000001).
cost.displaystringHuman-readable cost (e.g. "$0.009").
metadata.widthintegerOutput image width in pixels.
metadata.heightintegerOutput image height in pixels.
metadata.seedintegerSeed used (for reproducibility).

Code examples

curl

curl -X POST https://api.fairstack.ai/v1/generations/image \
  -H "Authorization: Bearer $FAIRSTACK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1.5-t2i",
    "prompt": "A mountain lake at golden hour, photorealistic"
  }'

Python

from fairstack import FairStack

client = FairStack(api_key="fs_live_YOUR_KEY")

result = client.generate.image(
    model="gpt-image-1.5-t2i",
    prompt="A mountain lake at golden hour, photorealistic"
)
print(result.url)   # https://media.fairstack.ai/...
print(result.cost)  # $0.009

Node.js

import { FairStack } from "fairstack";

const client = new FairStack({ apiKey: "fs_live_YOUR_KEY" });

const result = await client.generate.image({
  model: "gpt-image-1.5-t2i",
  prompt: "A mountain lake at golden hour, photorealistic",
});
console.log(result.url);   // https://media.fairstack.ai/...
console.log(result.cost);  // { micro: 9000, display: "$0.009" }

Response

{
  "id": "gen_abc123",
  "status": "completed",
  "url": "https://media.fairstack.ai/image/.../output.png",
  "model": "gpt-image-1.5-t2i",
  "modality": "image",
  "cost": {
    "micro": 9000,
    "display": "$0.009",
    "currency": "USD"
  },
  "metadata": {
    "width": 1024,
    "height": 1024,
    "seed": 42
  }
}

Cost estimation

Set confirm: false to get the exact cost without generating an image or being charged. This is especially useful for AI agents that need to evaluate budget impact before executing.

curl -X POST https://api.fairstack.ai/v1/generations/image \
  -H "Authorization: Bearer $FAIRSTACK_API_KEY" \
  -d '{
    "model": "gpt-image-1.5-t2i",
    "prompt": "test",
    "confirm": false
  }'

# Response (no image generated, no charge):
# { "estimated_cost": { "micro": 9000, "display": "$0.009" } }

Image editing

Upload a source image URL and describe what to change. Models like FLUX Kontext and GPT Image 1.5 support in-context editing.

{
  "model": "flux-kontext-dev",
  "prompt": "Change the background to a tropical beach",
  "image": "https://example.com/photo.jpg"
}

Quality tiers

TierExample ModelPriceBest For
BudgetZ-Image Turbo$0.003-0.004Prototyping, bulk generation, thumbnails
StandardFLUX.1 Pro, Seedream 4.5$0.02-0.04Marketing, social media, product shots
PremiumGPT Image 1.5, Imagen 4 Ultra$0.04-0.06Professional, print quality, hero images

Next steps