Models → Pricing → Docs → Blog → Changelog → Contact → Status →
Get started freeLog in

Image Generation

Create and edit images up to 4K with the OpenAI Images API.

⏱ 5 min read

Image generation

POST https://freemodel.in/v1/images/generations
POST https://freemodel.in/v1/images/edits
GET  https://freemodel.in/v1/images/models

Create images from a text prompt — or edit your own picture with a prompt — through the same OpenAI-compatible API you already use. It is the same engine as Image Studio in your dashboard, with the same models and the same price.

  • Models: e.g. sunburst-2.5 — photoreal detail, up to 4K (3840 px). New image models appear by themselves in GET /v1/images/models and in Image Studio — no code change needed, just send the new model ID.
  • Price: per image, paid from your account balance (sunburst-2.5: $0.0018; each model's price is in the models list). You pay only for images you actually receive — a failed request costs nothing.
  • Works with: the official OpenAI SDKs (Python, Node), cURL and any tool that speaks the OpenAI Images API.

Quick start

curl https://freemodel.in/v1/images/generations \
  -H "Authorization: Bearer fm_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sunburst-2.5",
    "prompt": "A red fox sitting in fresh snow, golden hour, photoreal",
    "size": "1792x1024"
  }'
{
  "created": 1793981265,
  "data": [{ "b64_json": "iVBORw0KGgo…", "revised_prompt": "A red fox sitting in fresh snow…" }],
  "usage": { "images": 1, "requested": 1, "cost_usd": 0.0018, "tokens": 0 },
  "model": "sunburst-2.5",
  "size": "1792x1024",
  "id": "img_3f1c9a0b7d2e4c5a61"
}

List image models

No key needed. Returns every image model that is on right now, with its price per image, sizes and whether it can edit.

curl https://freemodel.in/v1/images/models
{
  "object": "list",
  "data": [{
    "id": "sunburst-2.5", "object": "model", "type": "image",
    "name": "Sunburst 2.5", "description": "Photoreal detail · up to 4K",
    "endpoints": ["/v1/images/generations", "/v1/images/edits"],
    "price_usd_per_image": {"1k": 0.0018, "2k": 0.0018, "4k": 0.0018},
    "sizes": ["1024x1024", "1792x1024", "3840x2160", "…"],
    "max_n": 4, "edit": true
  }]
}

Image models are listed here, not in /v1/models (that list is for chat models, so chat apps never pick an image model by mistake).

Request

FieldTypeRequiredDescription
promptstringYesWhat you want to see. 3–4000 characters.
modelstringNoImage model ID, e.g. sunburst-2.5. Defaults to the first available model.
nintNoNumber of images, 1–4 (default 1). Each image is billed separately.
sizestringNoWidth×height, e.g. 1024x1024, 1792x1024, 3840x2160. Any size works — it snaps to the closest supported shape and resolution. Default 1024x1024.
qualitystringNohigh (default) or standard.
response_formatstringNob64_json (default) or url — a signed link to the stored image, valid for 7 days.
fm_stylestringNoOptional FreeModel style preset: photo, cinematic, anime, 3d, neon, fantasy, watercolor, product, logo, pixel.

Sizes

Pick a shape and a resolution. Every resolution costs the same.

Shape1K2K4K
1:1 square1024x10242048x20483840x3840
16:9 wide1792x10242048x11523840x2160
9:16 tall1024x17921152x20482160x3840
3:21536x10242304x15363456x2304
2:31024x15361536x23042304x3456
4:31365x10242048x15363072x2304
3:41024x13651536x20482304x3072

Python

import base64
from openai import OpenAI

client = OpenAI(api_key="fm_your_key_here", base_url="https://freemodel.in/v1")

img = client.images.generate(
    model="sunburst-2.5",
    prompt="A cozy wooden cabin in snowy mountains at night, northern lights above",
    size="3840x2160",
    n=1,
)
with open("cabin.png", "wb") as f:
    f.write(base64.b64decode(img.data[0].b64_json))

Node.js

import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({ apiKey: "fm_your_key_here", baseURL: "https://freemodel.in/v1" });

const img = await client.images.generate({
  model: "sunburst-2.5",
  prompt: "A premium matte black water bottle on a stone pedestal, studio light",
  size: "1024x1024",
  response_format: "url",
});
console.log(img.data[0].url); // signed link, valid 7 days

Edit an image

Send 1–4 reference images with a prompt. The model looks at your images and follows the prompt — change colours, add or remove things, restyle, turn a photo into a poster.

curl https://freemodel.in/v1/images/edits \
  -H "Authorization: Bearer fm_your_key_here" \
  -F model=sunburst-2.5 \
  -F image=@car.jpg \
  -F prompt="Change the car colour to bright red, keep everything else the same" \
  -F size=1792x1024
img = client.images.edit(
    model="sunburst-2.5",
    image=open("car.jpg", "rb"),          # or a list of up to 4 files
    prompt="Turn this into a snowy winter night with a full moon",
    size="1792x1024",
)

References must be JPG, PNG or WEBP, up to 10 MB each. They are scaled to at most 2048 px before the model sees them.

Billing

  • When a request starts, the price of the images you asked for is held from your balance. When it finishes you are charged only for the images you received; the rest goes straight back. A failed request is fully refunded.
  • Parallel requests can never spend the same money twice — if your balance covers 3 images, at most 3 are created, however fast you send requests.
  • Every answer carries the exact cost in usage.cost_usd and the headers X-FreeModel-Cost-Usd and X-FreeModel-Request-Id.
  • Your images are stored on FreeModel: you also find them in Image Studio → History on any device.

Errors

Errors use the OpenAI shape: {"error": {"message", "type", "code"}}. The code is always one of ours:

HTTPcodeMeaning
400IMG_REJECTEDThe prompt cannot be turned into an image — change the wording. Not charged.
400IMG_OPTIONThat size or quality is not available right now.
401invalid_api_keyMissing, wrong or revoked API key.
402IMG_NO_BALANCEBalance too low for one image — add balance.
404IMG_MODEL_OFFUnknown or paused model. The message lists the models you can use.
422IMG_PROMPT / IMG_REFPrompt missing / too long, or a reference image that cannot be read.
429IMG_TOO_MANY / IMG_DAILY_LIMITToo many requests running at once for your account (max 4), or the daily image limit was reached.
502IMG_UNAVAILABLE / IMG_FAILEDImage creation is temporarily unavailable. Not charged — retry shortly.
503IMG_BUSYVery busy right now. Not charged — retry in a few seconds.
504IMG_TIMEOUTThe image took too long. Not charged — retry.

Limits

  • Up to 4 images per request and 4 requests running at the same time per account.
  • A request takes about 25–45 seconds (4K takes the longest). Set your HTTP client timeout to at least 300 seconds.
  • Prompts up to 4000 characters.
Was this page helpful?
Still stuck?
Open a support ticket from your dashboard or ask the community on Telegram.
CommunityGet help