Image generation
Generate images with FLUX.1 Schnell via POST /v1/images/generations — OpenAI-compatible shape.
Basic request
curl https://api.ecohash.com/v1/images/generations \
-H "Authorization: Bearer eco_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-1-schnell",
"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. Currently "flux-1-schnell" |
prompt | string | — | Required. Max ~1000 characters |
size | string | "1024x1024" | One of 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) |
seed | integer | random | Non-OpenAI extension — deterministic generation when set |
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="flux-1-schnell",
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
- FLUX.1 Schnell is a 4-step model. It's fast (~1–2 seconds for 1024×1024) but less controllable than FLUX.1 Dev. Use short, focused prompts; long negative-prompt systems aren't necessary.
- Describe the subject, style, lighting, mood. "a golden retriever wearing a top hat, oil painting, Rembrandt lighting" beats "a dog in a hat."
- Use
seedif you need reproducible output for testing. - Horizontal vs vertical — use
1024x768for landscapes,768x1024for portraits.
Billing
Image generation bills per image at a flat rate. Typical cost per 1024×1024 image is in the single-digit cents range.
Try it in the playground
See Playground for an interactive UI where you can iterate prompts visually before writing code.