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

# Image Generation

> Generate images with Sudo SDKs (TypeScript and Python)

Use Sudo SDKs to generate images with models like DALL·E, GPT-Image, Imagen, and others. This page shows basic usage and common parameters.

<Note>
  Not all parameters are supported across providers. For example, `quality` may be supported by DALL·E 3 but not by Grok or Imagen. Always consult the respective provider’s model documentation to construct the request body correctly.
</Note>

## Basic Image Generation

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { Sudo } from "sudo-ai";

  const sudo = new Sudo({
    serverURL: "https://sudoapp.dev/api",
    apiKey: process.env.SUDO_API_KEY ?? "",
  });

  async function generateBasicImage() {
    const response = await sudo.router.generateImage({
      prompt: "A beautiful sunset over a mountain landscape",
      model: "dall-e-3",
      size: "1024x1024",
      quality: "standard",
    });

    // Response can include URLs or base64, depending on provider/params
    const first = response.data?.[0];
    if (first?.url) {
      console.log("Image URL:", first.url);
    } else if (first?.b64Json) {
      console.log("Image base64 length:", first.b64Json.length);
    }
  }

  generateBasicImage();
  ```

  ```python Python theme={null}
  import os
  from sudo import Sudo

  with Sudo(
      server_url="https://sudoapp.dev/api",
      api_key=os.getenv("SUDO_API_KEY"),
  ) as client:
      response = client.router.generate_image(
          model="gpt-image-1",
          prompt="A beautiful sunset over a mountain landscape",
          n=1,
          size="1024x1024"
      )

      first = response.data[0]
      if hasattr(first, 'url') and first.url:
          print("Image URL:", first.url)
      elif hasattr(first, 'b64_json') and first.b64_json:
          print("Image base64 length:", len(first.b64_json))
  ```
</CodeGroup>

## Response Formats

Request either a hosted URL or base64 data.

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { Sudo } from "sudo-ai";

  const sudo = new Sudo({
    serverURL: "https://sudoapp.dev/api",
    apiKey: process.env.SUDO_API_KEY ?? "",
  });

  async function generateWithFormats() {
    // URL format
    const urlResp = await sudo.router.generateImage({
      prompt: "A simple geometric pattern",
      model: "dall-e-2",
      n: 1,
      size: "512x512",
      responseFormat: "url",
    });
    console.log("URL:", urlResp.data?.[0]?.url);

    // Base64 format
    const b64Resp = await sudo.router.generateImage({
      prompt: "A simple geometric pattern",
      model: "dall-e-2",
      n: 1,
      size: "512x512",
      responseFormat: "b64_json",
    });
    console.log("b64 length:", b64Resp.data?.[0]?.b64Json?.length);
  }

  generateWithFormats();
  ```

  ```python Python theme={null}
  import os
  from sudo import Sudo

  with Sudo(
      server_url="https://sudoapp.dev/api",
      api_key=os.getenv("SUDO_API_KEY"),
  ) as client:
      # URL format
      url_response = client.router.generate_image(
          model="dall-e-3",
          prompt="A simple geometric pattern in blue and white",
          response_format="url",
          n=1,
          size="1024x1024"
      )
      print("URL:", url_response.data[0].url)

      # Base64 format
      b64_response = client.router.generate_image(
          model="dall-e-3",
          prompt="A simple geometric pattern",
          response_format="b64_json",
          n=1,
          size="512x512"
      )
      print("b64 length:", len(b64_response.data[0].b64_json))
  ```
</CodeGroup>

## Parameters

* **model**: The image model to use (e.g., `dall-e-3`, `gpt-image-1`, provider-specific models). See `Overview → Models` for availability.
* **prompt**: Text description of the image to generate.
* **n**: Number of images to generate.
* **size**: Output image size, e.g., `256x256`, `512x512`, `1024x1024` (availability varies by model/provider).
* **responseFormat / response\_format**: `url` or `b64_json`.
* **quality**: Optional quality preset (e.g., `standard`, `hd`) for providers that support it (often OpenAI/DALL·E only).

<Tip>
  If a parameter isn’t supported by your chosen model/provider, remove it or adjust to a supported value per provider documentation.
</Tip>

## Notes

* Image generation capabilities and parameters vary across providers and model versions.
* If a request fails due to unsupported options, check the error message and consult the provider’s docs.
