Skip to main content

Image generations

OpenAI-compatible image generation endpoint.

POST https://api.ecohash.com/v1/images/generations

Headers

HeaderValue
AuthorizationBearer eco_YOUR_KEY
Content-Typeapplication/json

Request body

FieldTypeRequiredNotes
modelstringyesImage model ID (e.g. flux2-klein, qwen-image, z-image-turbo)
promptstringyesText prompt — up to ~1000 characters
nintegernoNumber of images. Currently only 1 is supported
sizestringno512x512, 768x768, 1024x1024, 1024x768, 768x1024. Default 1024x1024
response_formatstringno"b64_json" (default) or "url"
stepsintegernoDenoising steps. Omit to use the model's default (turbo models use a low count automatically)
seedintegernoDeterministic generation (non-OpenAI extension)

Example 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",
"size": "1024x1024",
"response_format": "b64_json"
}'

Response body

{
"created": 1776391234,
"data": [{
"b64_json": "iVBORw0KGgo...",
"revised_prompt": null
}]
}

With response_format: "url", the response has url: "https://..." instead of b64_json — URL is valid for 24 hours.

Image edits

POST https://api.ecohash.com/v1/images/edits

Edit an existing image with a prompt. Send as multipart/form-data with an edit-capable model (for example flux2-klein, qwen-image).

FieldTypeRequiredNotes
modeltextyesAn edit-capable image model
imagefileyesThe source image
prompttextyesThe change to apply
sizetextnoOutput size
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

The response shape matches /v1/images/generations. A text-to-image-only model returns an error here.

Errors

See Errors. Common: 401, 402, 404, 429.