Background texture

POST /v1/images/generations

POST/v1/images/generations

Generates images from a text prompt. OpenAI DALL-E compatible format.

Request

Headers

HeaderValue
AuthorizationBearer {api_key}
Content-Typeapplication/json

Body

{
  "model": "imagen-3",
  "prompt": "A futuristic city skyline at sunset, digital art",
  "n": 1,
  "size": "1024x1024",
  "response_format": "b64_json"
}

Parameters

ParameterTypeRequiredDescription
modelstringYesImage model ID.
promptstringYesText description of the desired image.
nintegerNoNumber of images. Default 1.
sizestringNoImage dimensions, e.g. "1024x1024".
qualitystringNo"standard" or "hd".
response_formatstringNo"url" (default) or "b64_json".
stylestringNo"natural" or "vivid".

Response

{
  "created": 1709123456,
  "data": [
    {
      "url": "https://storage.example.com/generated-image.png",
      "revised_prompt": "A futuristic city skyline at golden hour sunset..."
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
FieldTypeDescription
createdintegerUnix timestamp.
data[].urlstringImage URL (when response_format is "url").
data[].b64_jsonstringBase64 image data (when response_format is "b64_json").
data[].revised_promptstringThe prompt as interpreted by the model.

Status codes

StatusDescription
200Success
400Invalid request or model doesn't support image generation
401Unauthorized
402Insufficient balance
502Upstream provider error

Examples

curl -X POST https://api.modelmax.io/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MODELMAX_API_KEY" \
  -d '{
    "model": "imagen-3",
    "prompt": "A watercolor painting of a mountain lake",
    "n": 1,
    "size": "1024x1024"
  }'
from openai import OpenAI

client = OpenAI(api_key="your-key", base_url="https://api.modelmax.io/v1")

response = client.images.generate(
    model="imagen-3",
    prompt="A watercolor painting of a mountain lake",
    n=1,
    size="1024x1024",
)

print(response.data[0].url)
import OpenAI from "openai";

const client = new OpenAI({ apiKey: "your-key", baseURL: "https://api.modelmax.io/v1" });

const response = await client.images.generate({
  model: "imagen-3",
  prompt: "A watercolor painting of a mountain lake",
  n: 1,
  size: "1024x1024",
});

console.log(response.data[0].url);