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

# Azure OpenAI Image Generation

> AzureImageGenServiceREST generates images with Azure OpenAI's image API from text prompts in Pipecat pipelines.

## Overview

`AzureImageGenServiceREST` provides image generation capabilities using Azure's OpenAI service via REST API. It supports asynchronous image generation with automatic polling for completion and image downloading.

> [card] [Azure Image Gen API Reference](https://reference-server.pipecat.ai/en/latest/api/pipecat.services.azure.image.html)
>
> Pipecat's API methods for Azure OpenAI image generation integration

> [card] [Azure OpenAI Documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/dall-e-quickstart)
>
> Official Azure OpenAI DALL-E documentation and guides

## Installation

To use Azure OpenAI image generation services, install the required dependencies:

```bash theme={null}
uv add "pipecat-ai[azure]"
```

## Prerequisites

### Azure Account Setup

Before using Azure OpenAI image generation services, you need:

1. **Azure Account**: Sign up at [Azure Portal](https://portal.azure.com/)
2. **Azure OpenAI Resource**: Create an Azure OpenAI resource
3. **API Key**: Get your API key from the Azure OpenAI resource
4. **Endpoint**: Note your resource endpoint URL
5. **HTTP Session**: Configure aiohttp session for image downloading

### Required Environment Variables

* `AZURE_DALLE_API_KEY`: Your Azure OpenAI API key for authentication
* `AZURE_DALLE_ENDPOINT`: Your Azure OpenAI endpoint URL

## Configuration

**api\_key** `str` *required*

Azure OpenAI API key for authentication.

**endpoint** `str` *required*

Azure OpenAI endpoint URL, including the trailing slash (for example,
`https://my-resource.openai.azure.com/`).

**aiohttp\_session** `aiohttp.ClientSession` *required*

HTTP session for API requests and downloading generated images. You must
create and manage this yourself.

**image\_size** `str` *deprecated*

Target size for generated images (e.g., `"1024x1024"`). *Deprecated in
v0.0.105. Use `settings=AzureImageGenServiceREST.Settings(image_size=...)`
instead.*

**model** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=AzureImageGenServiceREST.Settings(model=...)` instead.

**api\_version** `str` (default: 2023-06-01-preview)

Azure API version string.

**settings** `AzureImageGenServiceREST.Settings` (default: None)

Runtime-configurable generation settings. See [Settings](#settings) below.

### Settings

Runtime-configurable settings passed via the `settings` constructor argument using `AzureImageGenServiceREST.Settings(...)`. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `None` | Image generation model identifier. *(Inherited from base settings.)* |
| `image_size` | `str \| None` | `None` | Target size for generated images (e.g., `"1024x1024"`). `None` leaves Azure's default in place. |

## Usage

### Basic Setup

```python theme={null}
import os

import aiohttp
from pipecat.services.azure.image import AzureImageGenServiceREST

async with aiohttp.ClientSession() as session:
    image_gen = AzureImageGenServiceREST(
        api_key=os.getenv("AZURE_DALLE_API_KEY"),
        endpoint=os.getenv("AZURE_DALLE_ENDPOINT"),
        aiohttp_session=session,
        settings=AzureImageGenServiceREST.Settings(
            image_size="1024x1024",
        ),
    )
```

> [!TIP]
>
> The deprecated `model` and `image_size` constructor parameters are replaced by
> `Settings` as of v0.0.105. Use `Settings` / `settings=` instead. See the
> [Service Settings guide](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for migration
> details.

## Notes

* **HTTP session required**: You must provide an `aiohttp.ClientSession` for both API requests and downloading the generated images.
* **Asynchronous generation**: Azure uses an asynchronous pattern where image generation is submitted and then polled for completion, with a timeout of 120 seconds.
* **REST API**: This service uses Azure's REST API directly (not the OpenAI SDK), requiring an explicit endpoint URL.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.