Image generation
Generate images from text with POST /v1/images/generations, and edit images with POST /v1/images/edits — both OpenAI-compatible in shape.
Available image models (pass the ID in model):
| Model ID | Notes |
|---|---|
flux2-klein | Fast, unified generation and editing |
qwen-image | Strong text rendering and precise editing |
z-image-turbo | Distilled turbo model — very few steps, text-to-image |
Basic request
curl https://api.ecohash.com/v1/images/generations \
-H "Authorization: Bearer eco_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux2-klein",
"prompt": "a watercolor painting of a fox in a misty forest, soft light",
"size": "1024x1024",
"n": 1,
"response_format": "b64_json"
}'
Response:
{
"created": 1776391234,
"data": [{
"b64_json": "iVBORw0KGgo...",
"revised_prompt": null
}]
}
Decode the base64 to get the PNG bytes.
Parameters
| Parameter | Type | Default | Notes |
|---|---|---|---|
model | string | — | Required. One of the image model IDs above |
prompt | string | — | Required. Max ~1000 characters |
size | string | "1024x1024" | Common sizes: 512x512, 768x768, 1024x1024, 1024x768, 768x1024 |
n | integer | 1 | Number of images. Currently only n=1 is supported |
response_format | string | "b64_json" | "b64_json" returns inline base64; "url" returns a hosted URL (24h expiry) |
steps | integer | model default | Denoising steps. If omitted, EcoLink applies a sensible per-model default — turbo/distilled models use a low step count automatically, so you don't need to set it |
seed | integer | random | Deterministic generation when set |
You normally don't need to pass steps. Turbo models (like z-image-turbo) are designed for a small number of steps; EcoLink injects that model's intended default when the request omits steps, so you get the fast, intended result rather than an unnecessarily slow one. Set steps only if you specifically want more or fewer.
Editing images
Where a model supports editing (for example flux2-klein and qwen-image), send the source image plus a prompt to POST /v1/images/edits as multipart/form-data:
curl https://api.ecohash.com/v1/images/edits \
-H "Authorization: Bearer eco_YOUR_KEY" \
-F model=flux2-klein \
-F image=@input.png \
-F prompt="make the sky a dramatic sunset" \
-F size=1024x1024
| Field | Type | Required | Notes |
|---|---|---|---|
model | text | yes | An edit-capable image model |
image | file | yes | The source image to edit |
prompt | text | yes | What to change |
size | text | no | Output size |
A text-to-image-only model returns an error on this endpoint — use an edit-capable model.
Python example
from openai import OpenAI
import base64
client = OpenAI(api_key="eco_...", base_url="https://api.ecohash.com/v1")
resp = client.images.generate(
model="flux2-klein",
prompt="a cyberpunk cityscape at sunset, neon reflections",
size="1024x1024",
response_format="b64_json",
)
image_bytes = base64.b64decode(resp.data[0].b64_json)
with open("out.png", "wb") as f:
f.write(image_bytes)
Tips
- Describe subject, style, lighting, mood. "a golden retriever wearing a top hat, oil painting, Rembrandt lighting" beats "a dog in a hat."
- Pick the right model. Turbo models are fastest;
qwen-imageis strong when the image contains text. - Use
seedfor reproducible output when testing. - Orientation — use
1024x768for landscapes,768x1024for portraits.
Billing
Image generation and edits bill per image at the model's rate. See Balance & transactions.
Try it in the playground
See Playground to iterate on prompts visually before writing code.