Images
POST /v1/images/generations: image generation.
/v1/images/generationsGenerates images from a text description. The format is compatible with OpenAI Images: client.images.generate(...) works. The response is synchronous, and the image arrives in the body as b64_json. There is no image hosting, so the response_format: "url" mode is not supported.
Headers
| Header | Value |
|---|---|
Authorization | Bearer <key>. Required. x-api-key: <key> is accepted instead |
Content-Type | application/json |
X-Morphogen-Space | spc_…: the spending space. Optional |
Request body
modelstringrequiredAn image model from GET /v1/models: for example flux-2-klein or gpt-image-1-mini.
promptstringrequiredThe image description.
nintegerThe number of images, from 1 to 10. 1 by default.
sizestringThe size, for example 1024x1024. Allowed values depend on the model.
qualitystringThe quality, for example low. Not all models support it.
aspect_ratiostringThe aspect ratio, for example 16:9.
output_formatstringThe file format: png, jpeg or webp, if the model supports them.
seedintegerA seed for reproducibility, if the model accepts one.
input_referencesarraySource images for models that can edit.
Streaming is not supported, and stream: true gives 400. Images have no PII masking: the prompt goes to the model unchanged, and an explicit X-PII-Masking: on gives 400.
Request example
curl https://api.morphogen.ru/v1/images/generations \
-H "Authorization: Bearer $MORPHOGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-klein",
"prompt": "красное яблоко на белом столе"
}' | jq -r '.data[0].b64_json' | base64 -d > apple.jpgResponse example
{
"created": 1760104212,
"data": [{ "b64_json": "/9j/4AAQSkZJRgABAQ...", "media_type": "image/jpeg" }],
"usage": { "cost": 0.014 }
}In the example the b64_json string is cut. Images weigh megabytes, so the response is not buffered and arrives whole.
Errors
unsupported_response_formatThe request asks for response_format: "url". Only b64_json is supported.image_streaming_unsupportedThe request has stream: true.invalid_image_countn is not an integer from 1 to 10.model_category_mismatchThe model is not in the image category.pii_masking_unsupported_endpointThe request has X-PII-Masking: on.invalid_api_keyThe key is missing, invalid, revoked or expired.insufficient_fundsThe balance does not cover the request reserve.model_not_allowedThe model is not in the key's list.model_not_foundThere is no such model in the catalog.rate_limit_exceededThe request limit per minute is exceeded.Other codes: Errors. Guide: Images and video.