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

# Azure Image generation

***

## Request

<CodeGroup>
  ```shellscript cURL theme={null}
  curl --location 'https://api.znapai.com/azure/openai/deployments/gpt-image-2/images/generations?api-version=2024-02-01' \
  --header 'Authorization: Bearer $ZnapAI_API_KEY' \
  --header 'Content-Type: application/json' \
  --header 'spend-logs-metadata: {"user_id": "user-123", "project_id": "proj_abc", "env": "production"}' \
  --data '{
      "prompt": "A professional product photo of a white desk lamp on a neutral studio background, soft lighting, 50mm lens feel",
      "size": "1536x1024",
      "quality": "low",
      "n": 1,
      "output_format": "jpeg",
      "output_compression": 85,
      "background": "opaque",
      "moderation": "auto"
    }'
  ```
</CodeGroup>

## Response

```json theme={null}
{
    "created": 1778262087,
    "background": "opaque",
    "data": [
        {
            "b64_json": "/9j/4AAQSkZJRgABAQAAAQABAAD/60otSlACEQAAAAEAAEojanVtYgAAAB5qdW1kYzJwYQARABCAAACqADibcQNjMnBhAAAASf1qdW1iAAAAR2p1bWRjMm1hABEAEIAAAKoAOJtxA3VybjpjMnBhOjQzYjU5ZDJhLTMxMDEtNDcyOS1hMGU3LTkyMjBhODMyMmUxMQAAAAQWanVtYgAAAClqdW1kYzJhcwARABCAAACqgA0li0gADKgAErYCRQCQAZUbVlQAPF3gSAAlQCVJFAUkGJWgFAAkCQMGsAABIAJUKBIoBzqKSDCLQAAH/2Q=="
        }
    ],
    "output_format": "jpeg",
    "quality": "low",
    "size": "1536x1024",
    "usage": {
        "input_tokens": 29,
        "input_tokens_details": {
            "image_tokens": 0,
            "text_tokens": 29
        },
        "output_tokens": 158,
        "total_tokens": 187
    }
}
```

## Image from base64 data

<Frame>
  <img src="https://mintcdn.com/znapai/lvtTDTpUBf8bocT2/images/image-copy.png?fit=max&auto=format&n=lvtTDTpUBf8bocT2&q=85&s=ec71daca40e078cd2cb6c1f73b787fe2" alt="Azure Image" width="1536" height="1024" data-path="images/image-copy.png" />
</Frame>

***

## Parameters

<ParamField path="spend-logs-metadata" type="header" required={false}>
  An optional header used for spend logging metadata, containing JSON properties like `user_id`, `project_id`, and `env`.
</ParamField>

<ParamField path="prompt" type="string" required>
  A text description of the desired image(s). Maximum 32,000 characters.
</ParamField>

<ParamField path="n" type="integer" default={1}>
  The number of images to generate. Must be between 1 and 10.
</ParamField>

<ParamField path="size" type="string" default="1024x1024">
  Output image dimensions. Supports arbitrary `WIDTHxHEIGHT` where both edges are multiples of 16, aspect ratio between 1:3 and 3:1, max edge 3840.

  Standard values: `1024x1024`, `1536x1024`, `1024x1536`, `auto`.

  Supported values depend on the selected model. See the [OpenAI image generation guide](https://developers.openai.com/api/docs/guides/image-generation) for the latest model-specific ranges.
</ParamField>

<ParamField path="quality" type="string" default="auto">
  Image quality level. Higher quality increases cost and latency.

  Allowed values: `low`, `medium`, `high`, `auto`
</ParamField>

<ParamField path="background" type="string" default="auto">
  Background behavior for the generated image.

  Allowed values: `opaque`, `auto`

  <Warning>`transparent` is not supported on gpt-image-2.</Warning>
</ParamField>

<ParamField path="output_compression" type="integer">
  Compression level (0–100). Only applies when `output_format` is `jpeg`.
</ParamField>

<ParamField path="stream" type="boolean" default={false}>
  Stream partial images as they are generated. Use with `--no-buffer` in curl.
</ParamField>

<ParamField path="partial_images" type="integer">
  Number of partial images to emit during streaming. Value between `0` and `3`. Only used when `stream` is `true`.
</ParamField>

<ParamField path="moderation" type="string" default="auto">
  Content moderation strictness.

  Allowed values: `auto`, `low`
</ParamField>

***

## Params to Avoid

| Param                       | Reason                                                                       |
| --------------------------- | ---------------------------------------------------------------------------- |
| `response_format: "url"`    | Returns empty response from Azure                                            |
| `background: "transparent"` | Not supported on Azure gpt-image-2                                           |
| `output_format: "webp"`     | Not supported on Azure gpt-image-2                                           |
| `style: "vivid"`            | dall-e-3 only                                                                |
| `spend-logs-metadata`       | This metadata must be passed as an HTTP header, not in the JSON request body |

<Warning>
  The generation endpoint only returns `b64_json`. Requesting a URL response format is not supported and returns an empty response.
</Warning>
