AI Icon Generation API — App Icons and UI Assets (2026)

Sep 12, 2026·6 min read

A design system with 40 feature icons needs a consistent visual language — same stroke weight, same corner radius, same color treatment — but hand-drawing 40 icons (and another 40 when the product adds a dark mode) doesn't scale for a two-person team shipping weekly. Generating icon sets programmatically, from a single style reference, turns that into an API call per icon instead of a design sprint per release.

This guide covers authenticating against the GenRelay image API, generating a single icon, keeping a full icon set visually consistent via reference-guided generation, and the cost of generating an icon library at scale.

How Do I Authenticate and Generate a Single Icon?

Authenticate with a Bearer token and POST to the images endpoint with a prompt describing the icon and its style.

import requests
import os

API_KEY = os.environ["GENRELAY_API_KEY"]
BASE_URL = "https://genrelay.ai/v1"

def generate_icon(prompt, model="gpt-image-2", size="1024x1024"):
    response = requests.post(
        f"{BASE_URL}/images/generations",
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json"
        },
        json={
            "model": model,
            "prompt": prompt,
            "size": size
        }
    )
    response.raise_for_status()
    return response.json()["data"][0]["url"]

icon_url = generate_icon(
    "Flat vector icon of a cloud upload arrow, single color #4F46E5, "
    "2px rounded stroke, white background, minimalist app icon style"
)

Definition: reference-guided generation means passing an existing image alongside a text prompt so the model matches its style — stroke weight, color palette, geometry — rather than inventing a new visual style each call. This is the mechanism that keeps an icon set consistent across dozens of generations.

GPT-image-2 responds well to precise instruction-based prompts ("2px rounded stroke", "single color") and is the lowest-cost option per image at $0.014, which matters when generating icon variants across light/dark mode and multiple sizes.

How Do I Keep an Entire Icon Set Visually Consistent?

Generate one icon first, then pass it back as a reference image for every subsequent icon in the set so the model matches stroke weight, palette, and geometry instead of drifting between calls.

def generate_icon_with_reference(prompt, reference_url, model="nano-banana-pro"):
    response = requests.post(
        f"{BASE_URL}/images/generations",
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json"
        },
        json={
            "model": model,
            "prompt": prompt,
            "reference_image_url": reference_url,
            "size": "1024x1024"
        }
    )
    response.raise_for_status()
    return response.json()["data"][0]["url"]

# First icon establishes the style
base_icon = generate_icon(
    "Flat vector icon of a cloud upload arrow, single color #4F46E5, 2px rounded stroke"
)

# Subsequent icons reference it to match stroke, color, and geometry
settings_icon = generate_icon_with_reference(
    "Flat vector icon of a gear/settings symbol, matching the reference icon's style exactly",
    reference_url=base_icon
)
notification_icon = generate_icon_with_reference(
    "Flat vector icon of a bell notification symbol, matching the reference icon's style exactly",
    reference_url=base_icon
)

Nano Banana Pro is the stronger choice for the reference-guided calls in a set — it holds stroke weight and proportions more reliably across repeated reference calls than a pure text-to-image request, which matters once you're past 3–4 icons and drift becomes visible when they're placed side by side in a nav bar.

Which Model Should I Use for Which Part of an Icon Set?

Model Best for Price per 1024×1024 icon Reference-guided support
GPT-image-2 First-pass icons from precise text instructions $0.014 Instruction-based editing, not reference images
Nano Banana Pro Matching style across a growing icon set $0.030 (1K) Yes — reference image input
Nano Banana 2 Bulk generation once style is locked $0.020 (1K) Yes — reference image input

A practical split: use GPT-image-2 to draft the first 2–3 icons cheaply while you settle on style, switch to Nano Banana Pro to lock a reference-guided set for launch-critical icons, then use Nano Banana 2 for lower-stakes bulk additions (empty states, onboarding illustrations) where minor style drift is acceptable.

What Does Generating a Full Icon Library Cost?

Icon set size GPT-image-2 (draft) Nano Banana Pro (reference-guided, 1K) Nano Banana 2 (bulk, 1K)
20 icons $0.28 $0.60 $0.40
50 icons $0.70 $1.50 $1.00
100 icons (incl. dark mode variants) $1.40 $3.00 $2.00

Even a 100-icon design system with light and dark variants stays under $3 generated through Nano Banana Pro. The cost isn't the constraint — prompt iteration to land on a style you want to standardize on is the real time cost, which is why drafting cheaply with GPT-image-2 before committing to a reference-guided batch is worth doing.

How Do I Generate Multiple Icon Sizes for App Store and UI Requirements?

App icons need multiple fixed sizes (iOS requires up to 1024×1024 down to 20×20; Android has its own density buckets). Generate at the largest size and downscale locally rather than re-generating at each size — re-generation risks the model rendering the icon differently at each call.

from PIL import Image
import requests as req

def download_and_resize(url, sizes):
    img_data = req.get(url).content
    with open("icon_master.png", "wb") as f:
        f.write(img_data)
    master = Image.open("icon_master.png")
    outputs = {}
    for size in sizes:
        outputs[size] = master.resize((size, size), Image.LANCZOS)
    return outputs

icon_sizes = download_and_resize(base_icon, [1024, 512, 180, 120, 60])
for size, img in icon_sizes.items():
    img.save(f"icon_{size}.png")

Generating once at 1024×1024 and resizing locally is both cheaper and more consistent than requesting the same icon at five different resolutions.

Internal Links

FAQ

Can the API generate icons with transparent backgrounds?
Request a transparent or white background explicitly in the prompt (e.g., "transparent background, no shadow"). Output format support for alpha-channel PNG depends on the model — verify the returned file's format before dropping it into a design pipeline that expects transparency.

How do I keep icon style consistent if I add new icons months later?
Save the reference image URL (or the source file) from your original icon set generation and reuse it as the reference_image_url input for new icons, even if the original batch was generated months earlier. This anchors new additions to the original style rather than a re-derived one.

Does GPT-image-2 support reference images for style matching?
GPT-image-2's editing mode works via instruction-based prompts on an existing image rather than a separate reference-image parameter. For strict style-matching across many icons, Nano Banana Pro's reference-guided generation is the more direct mechanism.

What's the difference between icon generation and logo generation on GenRelay?
Icons are typically simpler, single-concept symbols generated in a consistent set for UI use; logos are usually a single, more distinctive brand mark. The same models handle both — see the logo generation guide for brand-mark-specific prompting.

Is there a free tier to test icon generation before committing to a full set?
Yes. GenRelay includes free credits on signup, enough to draft a handful of icons across GPT-image-2 and Nano Banana Pro before deciding on a reference-guided workflow for the full set.


As of September 2026. Pricing subject to change — verify current rates at genrelay.ai.

Related posts

Join our DiscordAI Icon Generation API — App Icons and UI Assets (2026) — GenRelay