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

# Image Generation

> Synthesize high-resolution imagery from text prompts via /v1/images/generations.

The `/v1/images/generations` endpoint provides OpenAI Images API compatibility to generate images from natural language descriptions.

<CodeGroup>
  ```python Python (OpenAI SDK) icon="python" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  from openai import OpenAI
  import os

  client = OpenAI(
      base_url="https://api.neosantara.xyz/v1",
      api_key=os.environ["NEOSANTARA_API_KEY"]
  )

  response = client.images.generate(
      model="imagen-4.0-fast",
      prompt="Terraced rice fields in Ubud Bali at sunrise, photorealistic, cinematic lighting.",
      size="1024x1024",
      n=1
  )

  image_url = response.data[0].url
  print(f"Image URL: {image_url}")
  ```

  ```javascript Node.js (OpenAI SDK) icon="js" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.neosantara.xyz/v1",
    apiKey: process.env.NEOSANTARA_API_KEY,
  });

  const response = await client.images.generate({
    model: "imagen-4.0-fast",
    prompt: "Terraced rice fields in Ubud Bali at sunrise, photorealistic.",
    size: "1024x1024",
    n: 1,
  });

  console.log("Image URL:", response.data[0].url);
  ```

  ```bash cURL icon="terminal" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  curl -X POST https://api.neosantara.xyz/v1/images/generations \
    -H "Authorization: Bearer $NEOSANTARA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "imagen-4.0-fast",
      "prompt": "Terraced rice fields in Ubud Bali at sunrise.",
      "size": "1024x1024",
      "n": 1
    }'
  ```
</CodeGroup>

## Request Parameters

| Parameter         | Type      | Required | Description                                                      |
| :---------------- | :-------- | :------- | :--------------------------------------------------------------- |
| `prompt`          | `string`  | Yes      | Visual description of the desired image.                         |
| `model`           | `string`  | Yes      | Model identifier (e.g., `imagen-4.0-fast`, `titan-image-g1`).    |
| `size`            | `string`  | Optional | Output resolution (`1024x1024`, `512x512`). Default `1024x1024`. |
| `n`               | `integer` | Optional | Number of image variations to generate (1 to 4). Default `1`.    |
| `response_format` | `string`  | Optional | Output format: `"url"` or `"b64_json"`. Default `"url"`.         |

## Technical Architecture & Caching

* **Synchronous vs Asynchronous**: The standard `/v1/images/generations` endpoint operates synchronously for real-time applications. For high-resolution generation or batch pipelines, use the [Responses API](/en/gateway/responses-api) with `background: true` to prevent HTTP timeouts.
* **Ephemeral CDN & TTL Caching**: Generated images are delivered through high-speed edge CDN storage via signed URLs. Links remain valid for **5 minutes** (TTL). Ingest assets into permanent cloud storage (S3/GCS/R2) if long-term persistence is required.
* **SSRF Mitigation**: When providing input image URLs for variations or inpainting, the gateway security bridge validates public IP ranges and blocks loopback or private addresses to prevent Server-Side Request Forgery.
* **Rupiah Metering**: Image generation is billed on a per-image unit basis rather than token count. Costs are deducted directly from your prepaid Rupiah balance.

## Visual Showcase

Output examples generated directly through the Neosantara API:

### Fast Inference

**Model**: `imagen-4.0-fast`

<Frame caption="Prompt: 'A vibrant digital painting of a high-tech laboratory in Jakarta, neon highlights, futuristic design, extremely detailed.'">
  <img src="https://mintcdn.com/neosantara/uq2XlSQ_dSPDIOXL/images/showcase-imagen.png?fit=max&auto=format&n=uq2XlSQ_dSPDIOXL&q=85&s=43447f08eedeefd471665b5be062ef0c" alt="Imagen 4.0 Fast output showcase" width="1024" height="1024" data-path="images/showcase-imagen.png" />
</Frame>

### Artistic & Fantasy

**Model**: `sdxl-lightning`

<Frame caption="Prompt: 'A majestic Indonesian temple in the clouds, ethereal lighting, high fantasy art style, 8k.'">
  <img src="https://mintcdn.com/neosantara/uq2XlSQ_dSPDIOXL/images/showcase-artistic.png?fit=max&auto=format&n=uq2XlSQ_dSPDIOXL&q=85&s=af48e6100f66ad2de9e171b21fae5759" alt="Artistic fantasy output showcase" width="1024" height="1024" data-path="images/showcase-artistic.png" />
</Frame>

### Realistic Photography

**Model**: `titan-image-g1`

<Frame caption="Prompt: 'A realistic high-detail photograph of a Balinese traditional dancer performing at night, focused lighting.'">
  <img src="https://mintcdn.com/neosantara/uq2XlSQ_dSPDIOXL/images/showcase-titan-base.png?fit=max&auto=format&n=uq2XlSQ_dSPDIOXL&q=85&s=c4bf3ea5d76fad12e98add5e77b5a68f" alt="Realistic photography output showcase" width="512" height="512" data-path="images/showcase-titan-base.png" />
</Frame>

### Image-to-Image Transformation

**Model**: `stable-diffusion-v1-5-img2img`

Transform existing images into new visual styles while preserving original structural composition.

<CardGroup cols={2}>
  <Card title="Original Image" icon="image" img="/images/showcase-titan-base.png">
    Input reference photograph of a Balinese dancer.
  </Card>

  <Card title="Sketch Transformation" icon="sparkles" img="/images/showcase-img2img-result.png">
    Stylized output transformed into a minimalist charcoal sketch.
  </Card>
</CardGroup>

## Available Image Generation Models

| Model ID                        | Provider     | Context Window | Capabilities | Pricing (Input/Output per 1M) |
| :------------------------------ | :----------- | :------------- | :----------- | :---------------------------- |
| `agnes-image-2.0-flash`         | Agnes AI     | N/A            | Image Gen    | Free / Included               |
| `agnes-image-2.1-flash`         | Agnes AI     | N/A            | Image Gen    | Free / Included               |
| `agnes-image-2.5-flash`         | Agnes AI     | N/A            | Image Gen    | Free / Included               |
| `titan-image-g1`                | Amazon       | N/A            | Image Gen    | \$0.01/img                    |
| `imagen-4.0-fast`               | Google       | N/A            | Image Gen    | \$0.02/img                    |
| `neosantara-gen-2045`           | Neosantara   | N/A            | Image Gen    | Rp 1,500/img                  |
| `gpt-image-2`                   | OpenAI       | N/A            | Image Gen    | \$0.04/img                    |
| `sdxl-lightning`                | Stability AI | N/A            | Image Gen    | Rp 200/img                    |
| `stable-diffusion-v1-5-img2img` | Stability AI | N/A            | Image Gen    | Rp 200/img                    |
| `grok-imagine-image`            | xAI          | N/A            | Image Gen    | \$0.02/img                    |


## Related topics

- [Video Generation](/en/gateway/capabilities/video-generation.md)
- [Multimodal Vision](/en/gateway/chat-completions/vision.md)
- [Model Catalog](/en/gateway/models.md)
