> ## Documentation Index
> Fetch the complete documentation index at: https://docs.naga.ac/llms.txt
> Use this file to discover all available pages before exploring further.

# Images API

> Generate or edit images with direct image-focused endpoints.

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](/build/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

<CodeGroup>
  ```python Python theme={null}
  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)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    baseURL: 'https://api.naga.ac/v1',
    apiKey: 'YOUR_API_KEY',
  });

  const response = await client.images.generate({
    model: 'gpt-image-1',
    prompt: 'A neon koi fish swimming through a midnight city canal',
  });

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

  ```bash cURL theme={null}
  curl https://api.naga.ac/v1/images/generations \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-image-1",
      "prompt": "A neon koi fish swimming through a midnight city canal"
    }'
  ```
</CodeGroup>

## 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.

```json Example Usage Shape theme={null}
{
  "usage": {
    "input_tokens": null,
    "output_tokens": 1536,
    "total_tokens": 1536
  }
}
```

## Related Docs

* [Image Generation](/api/images/image-generation)
* [Image Edits](/api/images/image-edits)
* [Multimodal Inputs](/build/multimodal-inputs)
* [Error Handling](/build/error-handling)

## Reference

* [Generate images](/api-reference/endpoints/images/generations)
* [Edit images](/api-reference/endpoints/images/edits)
