Image Generation
Create and edit images up to 4K with the OpenAI Images API.
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 newmodelID. - 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
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | What you want to see. 3–4000 characters. |
model | string | No | Image model ID, e.g. sunburst-2.5. Defaults to the first available model. |
n | int | No | Number of images, 1–4 (default 1). Each image is billed separately. |
size | string | No | Width×height, e.g. 1024x1024, 1792x1024, 3840x2160. Any size works — it snaps to the closest supported shape and resolution. Default 1024x1024. |
quality | string | No | high (default) or standard. |
response_format | string | No | b64_json (default) or url — a signed link to the stored image, valid for 7 days. |
fm_style | string | No | Optional 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.
| Shape | 1K | 2K | 4K |
|---|---|---|---|
| 1:1 square | 1024x1024 | 2048x2048 | 3840x3840 |
| 16:9 wide | 1792x1024 | 2048x1152 | 3840x2160 |
| 9:16 tall | 1024x1792 | 1152x2048 | 2160x3840 |
| 3:2 | 1536x1024 | 2304x1536 | 3456x2304 |
| 2:3 | 1024x1536 | 1536x2304 | 2304x3456 |
| 4:3 | 1365x1024 | 2048x1536 | 3072x2304 |
| 3:4 | 1024x1365 | 1536x2048 | 2304x3072 |
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_usdand the headersX-FreeModel-Cost-UsdandX-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:
| HTTP | code | Meaning |
|---|---|---|
| 400 | IMG_REJECTED | The prompt cannot be turned into an image — change the wording. Not charged. |
| 400 | IMG_OPTION | That size or quality is not available right now. |
| 401 | invalid_api_key | Missing, wrong or revoked API key. |
| 402 | IMG_NO_BALANCE | Balance too low for one image — add balance. |
| 404 | IMG_MODEL_OFF | Unknown or paused model. The message lists the models you can use. |
| 422 | IMG_PROMPT / IMG_REF | Prompt missing / too long, or a reference image that cannot be read. |
| 429 | IMG_TOO_MANY / IMG_DAILY_LIMIT | Too many requests running at once for your account (max 4), or the daily image limit was reached. |
| 502 | IMG_UNAVAILABLE / IMG_FAILED | Image creation is temporarily unavailable. Not charged — retry shortly. |
| 503 | IMG_BUSY | Very busy right now. Not charged — retry in a few seconds. |
| 504 | IMG_TIMEOUT | The 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.