Skip to main content
Use the Images API when your workflow is primarily about image generation or image editing rather than a broader conversational interaction.

When To Use It

  • generating images from prompts
  • editing an existing image with prompt instructions
  • building image-only tools or automation jobs
If you need multimodal conversations with text, images, files, or audio in the same flow, also review Multimodal Inputs.

Endpoint Families

  • POST /v1/images/generations creates new images from a prompt
  • POST /v1/images/edits edits one or more uploaded images with a prompt and optional mask
The responses return either hosted URLs or base64 image payloads, depending on response_format.

Quick Example

from openai import OpenAI

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

response = client.images.generate(
    model="gpt-image-1",
    prompt="A neon koi fish swimming through a midnight city canal",
)

print(response.data[0].url)

Usage Tracking

The Images API includes a usage object in its response, which you can use to track token consumption. Depending on the model, it typically reports output_tokens or total_tokens corresponding to the generated images.
Example Usage Shape
{
  "usage": {
    "input_tokens": null,
    "output_tokens": 1536,
    "total_tokens": 1536
  }
}

Reference