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

# Image Generation

> Generate one or more images from a text prompt.

`POST /v1/images/generations` creates images from a prompt.

Use this endpoint when your workflow is primarily about generating images, not running a broader multimodal conversation.

## Common fields

| Field             | Common use                                    |
| ----------------- | --------------------------------------------- |
| `model`           | image generation model                        |
| `prompt`          | image description or instruction              |
| `size`            | output dimensions                             |
| `response_format` | `url` or `b64_json`                           |
| `n`               | number of images, when supported by the model |

## Example Request

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

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

  result = client.images.generate(
      model="gpt-image-1",
      prompt="A cinematic watercolor fox reading in a lantern-lit library.",
      size="1024x1024",
      response_format="url",
  )

  print(result.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 result = await client.images.generate({
    model: 'gpt-image-1',
    prompt: 'A cinematic watercolor fox reading in a lantern-lit library.',
    size: '1024x1024',
    response_format: 'url',
  });

  console.log(result.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 cinematic watercolor fox reading in a lantern-lit library.",
      "size": "1024x1024",
      "response_format": "url"
    }'
  ```
</CodeGroup>

## Response Shape

```json theme={null}
{
  "created": 1710000000,
  "data": [
    {
      "url": "https://api.naga.ac/outputs/..."
    }
  ],
  "usage": {
    "input_tokens": 42,
    "output_tokens": 512,
    "total_tokens": 554
  }
}
```

## Notes

* `response_format` can be `url` or `b64_json`
* `n` and `size` constraints depend on the model
* the prompt is moderated before generation

## Common mistakes

* using `Images API` for workflows that should really be multimodal Responses prompts
* assuming every model supports the same `size` or `n` combinations
* forgetting to handle `b64_json` differently from hosted image URLs

## Reference

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