# OpenAI Image Tools (https://www.librechat.ai/docs/configuration/tools/openai_image_gen)

OpenAI Image Tools is the agent toolkit behind [image generation and editing](/docs/features/image_gen) with OpenAI image models. Adding it to an agent gives the agent two tools: one that generates from text and one that edits uploaded or earlier images.

## Setup

1. Create or reuse an OpenAI API key and add it to `.env`:

```bash filename=".env"
IMAGE_GEN_OAI_API_KEY=sk-...
```

2. Restart LibreChat.
3. In the Agent Builder, select **Add** next to **Tools**, choose **OpenAI Image Tools**, and save the agent.

If you leave `IMAGE_GEN_OAI_API_KEY` unset, each user is asked for their own key when they add the tool.

<OptionTable
  options={[
    [
      'IMAGE_GEN_OAI_API_KEY',
      'string',
      'OpenAI (or Azure OpenAI) API key for both image tools. Unset lets users enter their own key.',
      'IMAGE_GEN_OAI_API_KEY=sk-...',
    ],
    [
      'IMAGE_GEN_OAI_MODEL',
      'string',
      'Image model to use, or the deployment name on Azure. Default: gpt-image-2.5-flare.',
      '# IMAGE_GEN_OAI_MODEL=gpt-image-2.5-flare',
    ],
    [
      'IMAGE_GEN_OAI_BASEURL',
      'string',
      'Custom base URL, for a proxy, an OpenAI-compatible service, or an Azure deployment.',
      '# IMAGE_GEN_OAI_BASEURL=https://...',
    ],
    [
      'IMAGE_GEN_OAI_AZURE_API_VERSION',
      'string',
      'Azure OpenAI API version. Setting it together with IMAGE_GEN_OAI_BASEURL switches the tools to Azure mode, which sends the key as an api-key header.',
      '# IMAGE_GEN_OAI_AZURE_API_VERSION=2025-04-01-preview',
    ],
  ]}
/>

The image size an agent can request depends on the model: `auto`, `1024x1024`, `1536x1024`, and `1024x1536` work everywhere, and models that support custom dimensions, such as `gpt-image-2.5-flare`, accept others like `2048x1152` or `3840x2160`. The API rejects sizes the configured model does not support.

OpenAI retired `gpt-image-1` on October 23, 2026. If you set it in `IMAGE_GEN_OAI_MODEL`, remove it or switch to a current model.

LibreChat also recognizes `gpt-image-2.6-sunburst` and `gpt-image-2.6-flare`. Select either explicitly with `IMAGE_GEN_OAI_MODEL`; adding support does not change the default from `gpt-image-2.5-flare`. The recognized 2.6 models expose `xhigh` and `max` quality options in addition to the baseline choices. Size may be `auto` or a positive `WIDTHxHEIGHT` value, with supported dimensions validated by the provider.

## Keeping large images

LibreChat resizes saved images so the shorter side is at most 768 pixels, so a `3840x2160` result is stored at 1365x768. To keep the size the model returned, set [`fileConfig.imageGeneration`](/docs/configuration/librechat_yaml/object_structure/file_config#imagegeneration) to `percentage: 100`.

## Azure OpenAI

Point the base URL at your image deployment and set the API version:

```bash filename=".env"
IMAGE_GEN_OAI_API_KEY=your-azure-api-key
IMAGE_GEN_OAI_BASEURL=https://your-resource.openai.azure.com/openai/deployments/your-image-deployment/
IMAGE_GEN_OAI_AZURE_API_VERSION=2025-04-01-preview
IMAGE_GEN_OAI_MODEL=your-image-deployment
```

## Tool descriptions

The model decides when and how to call each tool from its description. You can replace the built-in text if you want to steer that, for example to enforce a house style:

<OptionTable
  options={[
    ['IMAGE_GEN_OAI_DESCRIPTION', 'string', 'Description of the generation tool.', '# IMAGE_GEN_OAI_DESCRIPTION='],
    ['IMAGE_GEN_OAI_PROMPT_DESCRIPTION', 'string', 'Description of the generation tool prompt parameter.', '# IMAGE_GEN_OAI_PROMPT_DESCRIPTION='],
    ['IMAGE_EDIT_OAI_DESCRIPTION', 'string', 'Description of the editing tool.', '# IMAGE_EDIT_OAI_DESCRIPTION='],
    ['IMAGE_EDIT_OAI_PROMPT_DESCRIPTION', 'string', 'Description of the editing tool prompt parameter.', '# IMAGE_EDIT_OAI_PROMPT_DESCRIPTION='],
  ]}
/>

## Proxy

Requests honor the global `PROXY` variable. When `PROXY` is unset, `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` apply.

## Pricing

OpenAI bills image generation per image, based on model, size, and quality. See OpenAI's [image generation guide](https://platform.openai.com/docs/guides/image-generation) for current costs.
