AI Image Generation APIs Cheat Sheet

This cheat sheet covers common patterns for calling image generation APIs — model IDs, request parameters, prompting syntax, and cost math.

Getting Started

Image models {.row-span-2}

Model Known for API model ID
FLUX 1.1 Pro Photorealism, prompt adherence flux-pro/v1.1
FLUX Schnell Speed, drafts flux/schnell
Stable Diffusion 3.5 Styles, open weights stable-diffusion-v35-large
DALL·E 3 Instruction following dall-e-3
Imagen 4 Clean detail google/imagen-4.0-generate-001
Recraft V3 Brand styles, SVG recraft-v3

{.show-header}

IDs shown for a multi-provider endpoint; direct provider APIs use their own naming.

Basic call

curl https://api.aimlapi.com/v1/images/generations \

  -H “Authorization: Bearer $API_KEY” \

  -H “Content-Type: application/json” \

  -d ‘{

    “model”: “flux-pro/v1.1”,

    “prompt”: “isometric illustration of a data center, soft colors”,

    “size”: “1024×1024”

  }’

Image APIs are synchronous: one request, one response.

Basic call (Python)

import requests

 

resp = requests.post(

    “https://api.aimlapi.com/v1/images/generations”,

    headers={“Authorization”: f”Bearer {API_KEY}”},

    json={

        “model”: “flux-pro/v1.1”,

        “prompt”: “isometric illustration of a data center”,

        “size”: “1024×1024”,

    },

)

url = resp.json()[“data”][0][“url”]

Response handling

  • response_format: url (default) or b64_json
  • Result URLs usually expire (minutes–hours) — download and store in your own bucket
  • Failed generations are often still billed — validate prompts before batch runs
  • Same prompt + seed = same output; cache instead of regenerating

Parameters and Prompting

Common parameters {.col-span-2}

Parameter Aliases What it does
size width + height, aspect_ratio Output dimensions; models allow fixed sets
n num_images Batch count per request
seed Same seed + prompt ≈ same image
steps num_inference_steps Quality vs speed (diffusion models)
guidance cfg_scale Prompt adherence; too high = artifacts
negative_prompt What to avoid (SD family; some models ignore)
response_format url (default, expires) or b64_json

{.show-header}

Unsupported parameters are silently ignored — check the response, not the docs.

Prompt structure

[subject] [action], [environment], [style],

[lighting], [camera]

 

portrait of a violinist mid-performance,

concert hall bokeh, editorial photography,

dramatic rim lighting, 85mm f/1.4

# Weighting (SD-family syntax)

(golden hour:1.3), (crowd:0.6)

Prompt add-ons

Goal Add
Photorealism 35mm, f/2.8, RAW photo
Illustration flat vector, isometric
Brand consistency fix seed + reuse style block
Clean composition generous whitespace, centered

{.show-header}

Reference

Cost ballpark

Media Range
Image, standard 1024² $0.02–0.08
Image, premium models $0.10–0.25

{.show-header}

  • Published list prices at time of writing — verify with your provider
  • Higher resolutions and quality tiers multiply the price

Common errors

Problem Fix
400 invalid size Models allow a fixed dimension list — check catalog
Content policy rejection Rephrase; avoid real names, brands, violence
429 Image rate limits are lower than LLM limits — queue jobs
Expired result URL Download on completion, store yourself

{.show-header}

Video APIs

Same auth and endpoint family, but asynchronous: submit a job, poll for status, download the result. Check your provider’s video docs for the job contract.

Also see

  • Black Forest Labs docs _(FLUX parameters)_
  • AI/ML API docs _(endpoint and model IDs used in the examples above)_

 

Leave a Reply

Your email address will not be published. Required fields are marked *