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

# Create Image

> Generate images from text prompts

```
POST /v1/images/generations
```

Creates an image given a text prompt. Supports multiple image generation models including DALL-E, Stable Diffusion, and others.

## Request Body

<ParamField body="model" type="string" required>
  The model to use for image generation (e.g., `dall-e-3`, `dall-e-2`, `stable-diffusion-xl`)
</ParamField>

<ParamField body="prompt" type="string" required>
  A text description of the desired image. Maximum length varies by model.
</ParamField>

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

<ParamField body="size" type="string" default="1024x1024">
  The size of the generated images. Supported sizes:

  * `256x256`
  * `512x512`
  * `1024x1024`
  * `1536x1024` (landscape)
  * `1024x1536` (portrait)
  * `2048x2048`
  * `4096x4096`
  * `auto`
</ParamField>

<ParamField body="response_format" type="string" default="url">
  The format of the generated images. Either `url` or `b64_json`.
</ParamField>

<ParamField body="quality" type="string" default="standard">
  The quality of the image. Either `standard` or `hd`.
</ParamField>

<ParamField body="style" type="string" default="vivid">
  The style of the generated images (DALL-E 3 only). Either `vivid` or `natural`.
</ParamField>

## Response

<ResponseField name="created" type="integer">
  Unix timestamp of when the images were created.
</ResponseField>

<ResponseField name="data" type="array">
  Array of generated images.

  <Expandable title="Image object">
    <ResponseField name="url" type="string">
      The URL of the generated image (when `response_format` is `url`).
    </ResponseField>

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

    <ResponseField name="revised_prompt" type="string">
      The revised prompt used by the model (if applicable).
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

### Basic Image Generation

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="sk-voidai-your_key_here",
      base_url="https://api.voidai.app/v1"
  )

  response = client.images.generate(
      model="dall-e-3",
      prompt="A serene mountain landscape at sunset with a crystal clear lake",
      size="1024x1024",
      n=1
  )

  print(response.data[0].url)
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: 'sk-voidai-your_key_here',
    baseURL: 'https://api.voidai.app/v1'
  });

  const response = await client.images.generate({
    model: 'dall-e-3',
    prompt: 'A serene mountain landscape at sunset with a crystal clear lake',
    size: '1024x1024',
    n: 1
  });

  console.log(response.data[0].url);
  ```

  ```bash cURL theme={null}
  curl https://api.voidai.app/v1/images/generations \
    -H "Authorization: Bearer sk-voidai-your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "dall-e-3",
      "prompt": "A serene mountain landscape at sunset with a crystal clear lake",
      "size": "1024x1024",
      "n": 1
    }'
  ```
</CodeGroup>

### HD Quality with Natural Style

<CodeGroup>
  ```python Python theme={null}
  response = client.images.generate(
      model="dall-e-3",
      prompt="A professional photograph of a coffee cup on a wooden table",
      size="1024x1024",
      quality="hd",
      style="natural",
      n=1
  )
  ```

  ```typescript TypeScript theme={null}
  const response = await client.images.generate({
    model: 'dall-e-3',
    prompt: 'A professional photograph of a coffee cup on a wooden table',
    size: '1024x1024',
    quality: 'hd',
    style: 'natural',
    n: 1
  });
  ```
</CodeGroup>

### Base64 Response

<CodeGroup>
  ```python Python theme={null}
  import base64

  response = client.images.generate(
      model="dall-e-3",
      prompt="An abstract geometric pattern",
      size="512x512",
      response_format="b64_json",
      n=1
  )

  # Decode and save the image
  image_data = base64.b64decode(response.data[0].b64_json)
  with open("image.png", "wb") as f:
      f.write(image_data)
  ```

  ```typescript TypeScript theme={null}
  const response = await client.images.generate({
    model: 'dall-e-3',
    prompt: 'An abstract geometric pattern',
    size: '512x512',
    response_format: 'b64_json',
    n: 1
  });

  // Decode and save the image
  const imageBuffer = Buffer.from(response.data[0].b64_json, 'base64');
  fs.writeFileSync('image.png', imageBuffer);
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "created": 1701691200,
  "data": [
    {
      "url": "https://storage.voidai.app/images/abc123.png",
      "revised_prompt": "A serene mountain landscape at sunset featuring snow-capped peaks reflecting in a crystal clear alpine lake, with warm orange and pink hues in the sky"
    }
  ]
}
```

## Tips for Better Results

<AccordionGroup>
  <Accordion title="Be specific and detailed">
    More descriptive prompts typically produce better results. Include details about style, lighting, composition, and mood.
  </Accordion>

  <Accordion title="Specify art style">
    Include art style references like "oil painting", "digital art", "photograph", "watercolor", etc.
  </Accordion>

  <Accordion title="Use quality modifiers">
    Add terms like "high quality", "4k", "detailed", "professional" to improve output quality.
  </Accordion>

  <Accordion title="Consider aspect ratio">
    Use landscape (`1536x1024`) for wide scenes and portrait (`1024x1536`) for tall subjects.
  </Accordion>
</AccordionGroup>
