Skip to main content

POST /v1/images/generations

Create an image from a text prompt.

  • Method: POST
  • Path: /v1/images/generations
  • Auth: Bearer token in Authorization header
  • Content-Type: application/json

Request parameters

  • model (string, required): Image generation model (e.g., flux-1-schnell).
  • prompt (string, required, 1..8192): The text prompt for image generation.
  • quality (string | null, optional): Provider-specific quality preset.
  • size (string | null, optional): Target image resolution (e.g., 1024x1024).
  • n (integer ≥ 1 | null, optional): Number of images to generate.
  • response_format (enum: url | b64_json, default url): Output format per image.

Example requests

from openai import OpenAI

client = OpenAI(base_url="https://api.naga.ac/v1", api_key="YOUR_API_KEY")

resp = client.images.generate(
model="flux-1-schnell",
prompt="A white siamese cat",
size="1024x1024",
n=1,
response_format="url", # or "b64_json"
)
print(resp.data) # array of images with url or b64_json

Response

Returns a JSON object with a data array of generated images. Each item contains either:

  • url when response_format = "url", or
  • b64_json when response_format = "b64_json".