Skip to main content

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 IDNotes
flux2-kleinFast, unified generation and editing
qwen-imageStrong text rendering and precise editing
z-image-turboDistilled 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

ParameterTypeDefaultNotes
modelstringRequired. One of the image model IDs above
promptstringRequired. Max ~1000 characters
sizestring"1024x1024"Common sizes: 512x512, 768x768, 1024x1024, 1024x768, 768x1024
ninteger1Number of images. Currently only n=1 is supported
response_formatstring"b64_json""b64_json" returns inline base64; "url" returns a hosted URL (24h expiry)
stepsintegermodel defaultDenoising 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
seedintegerrandomDeterministic generation when set
Default steps

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
FieldTypeRequiredNotes
modeltextyesAn edit-capable image model
imagefileyesThe source image to edit
prompttextyesWhat to change
sizetextnoOutput 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-image is strong when the image contains text.
  • Use seed for reproducible output when testing.
  • Orientation — use 1024x768 for landscapes, 768x1024 for 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.