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

# Image generation and editing: /v1/images endpoints

> Generate images from text prompts or edit existing images using /v1/images/generations and /v1/images/edits. Works with OpenAI DALL·E-compatible clients.

Anyone exposes two image endpoints that are compatible with the OpenAI Images API. You can generate new images from a prompt, or supply a source image and a prompt to edit it. Both endpoints route your request to whichever upstream image channel you have configured — for example, DALL·E 3, Stable Diffusion, or other providers. Authenticate with a Bearer token in the `Authorization` header.

***

## POST /v1/images/generations

Generate one or more images from a text prompt.

### Request body

<ParamField body="model" type="string" required>
  The model to use for image generation. For example, `dall-e-3` or `dall-e-2`. The available values depend on which channels you have configured.
</ParamField>

<ParamField body="prompt" type="string" required>
  A text description of the image you want to generate. For DALL·E 3, the maximum length is 4,000 characters; for DALL·E 2 it is 1,000 characters.
</ParamField>

<ParamField body="n" type="integer">
  Number of images to generate. Defaults to `1`. DALL·E 3 only supports `n=1`.
</ParamField>

<ParamField body="size" type="string">
  The dimensions of the generated image. Accepted values vary by model:

  * DALL·E 2: `256x256`, `512x512`, `1024x1024`
  * DALL·E 3: `1024x1024`, `1024x1792`, `1792x1024`

  Defaults to `1024x1024`.
</ParamField>

<ParamField body="quality" type="string">
  Image quality. Set to `hd` for higher detail at higher cost (DALL·E 3 only). Defaults to `standard`.
</ParamField>

<ParamField body="response_format" type="string">
  Format for the returned image data. Either `url` (a temporary hosted URL) or `b64_json` (base64-encoded image bytes). Defaults to `url`.
</ParamField>

<ParamField body="style" type="string">
  Style of the generated image. `vivid` (hyper-real) or `natural` (more realistic). DALL·E 3 only.
</ParamField>

<ParamField body="background" type="string">
  Background style for the generated image, if supported by the upstream provider.
</ParamField>

<ParamField body="output_format" type="string">
  Output file format, if supported by the upstream provider (e.g., `png`, `webp`).
</ParamField>

<ParamField body="output_compression" type="integer">
  Compression level for the output image, if supported by the upstream provider. Range is `0`–`100`.
</ParamField>

<ParamField body="watermark" type="boolean">
  Whether to include a watermark, if supported by the upstream provider.
</ParamField>

### Response

<ResponseField name="created" type="integer">
  Unix timestamp for when the request was processed.
</ResponseField>

<ResponseField name="data" type="object[]">
  Array of generated image objects.

  <Expandable title="properties">
    <ResponseField name="url" type="string">
      A URL pointing to the generated image. Present when `response_format` is `url`.
    </ResponseField>

    <ResponseField name="b64_json" type="string">
      Base64-encoded image data. Present when `response_format` is `b64_json`.
    </ResponseField>

    <ResponseField name="revised_prompt" type="string">
      The prompt that was actually used by the model, after any provider-side rewrites. DALL·E 3 always returns this field.
    </ResponseField>
  </Expandable>
</ResponseField>

### Example

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.anyone.ai/v1/images/generations \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "dall-e-3",
      "prompt": "A photorealistic image of a red panda sitting on a mossy log in a misty forest",
      "n": 1,
      "size": "1024x1024",
      "response_format": "url"
    }'
  ```

  ```python python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_TOKEN",
      base_url="https://api.anyone.ai/v1",
  )

  response = client.images.generate(
      model="dall-e-3",
      prompt="A photorealistic image of a red panda sitting on a mossy log in a misty forest",
      n=1,
      size="1024x1024",
  )

  print(response.data[0].url)
  ```
</CodeGroup>

***

## POST /v1/images/edits

Edit an existing image using a text prompt. You upload the source image as a multipart form, optionally include a mask, and provide a prompt describing the desired change.

### Request body

This endpoint uses `multipart/form-data` encoding.

<ParamField body="model" type="string" required>
  The model to use for image editing. For example, `dall-e-2`. Not all image models support editing.
</ParamField>

<ParamField body="image" type="file" required>
  The source image to edit. Must be a valid PNG file, less than 4 MB, and square.
</ParamField>

<ParamField body="prompt" type="string" required>
  A description of the edits you want to apply.
</ParamField>

<ParamField body="mask" type="file">
  An optional mask image. Transparent areas of the mask indicate where the edit should be applied. Must be the same size as `image`.
</ParamField>

<ParamField body="n" type="integer">
  Number of edited images to generate. Defaults to `1`.
</ParamField>

<ParamField body="size" type="string">
  Size of the output image. Accepted values: `256x256`, `512x512`, `1024x1024`. Defaults to `1024x1024`.
</ParamField>

<ParamField body="response_format" type="string">
  Either `url` or `b64_json`. Defaults to `url`.
</ParamField>

### Response

Same structure as `/v1/images/generations`.

### Example

```bash curl theme={null}
curl https://api.anyone.ai/v1/images/edits \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F model="dall-e-2" \
  -F image="@source.png" \
  -F mask="@mask.png" \
  -F prompt="Replace the background with a snowy mountain scene" \
  -F n=1 \
  -F size="1024x1024"
```
