> ## 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.

# Generate Image



## OpenAPI

````yaml https://sudoapp.dev/api/openapi.json post /v1/images/generations
openapi: 3.1.0
info:
  title: sudo-api
  description: ''
  license:
    name: ''
  version: 0.1.0
servers: []
security:
  - api_key: []
  - privy_token: []
tags:
  - name: Sudo API
    description: 'Sudo: The Unified AI Developer Platform'
paths:
  /v1/images/generations:
    post:
      tags:
        - Router
      summary: Generate Image
      operationId: generate_image
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
        required: true
      responses:
        '200':
          description: Image generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGeneration'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Bad gateway error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - api_key: []
components:
  schemas:
    ImageGenerationRequest:
      type: object
      description: Request parameters for generating images using AI models
      required:
        - prompt
        - model
      properties:
        background:
          type:
            - string
            - 'null'
          description: >-
            The background color to use for transparency. Defaults to "auto".
            OpenAI only.
        model:
          type: string
          description: >-
            The model to use for image generation (e.g., "dall-e-2", "dall-e-3",
            "imagen-3.0-generate-001").
        moderation:
          type:
            - string
            - 'null'
          description: The moderation level to apply to the generated image. OpenAI only.
        'n':
          type:
            - integer
            - 'null'
          format: int32
          description: The number of images to generate.
          minimum: 0
        output_compression:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            The compression level for the output image, ranging from 0 to 100.
            Higher values mean more compression. OpenAI only.
          minimum: 0
        output_format:
          type:
            - string
            - 'null'
          description: The format of the output image (e.g., "png", "jpeg"). OpenAI only.
        prompt:
          type: string
          description: A text description of the desired image(s).
        quality:
          type:
            - string
            - 'null'
          description: >-
            The quality of the image that will be generated. "hd" creates images
            with finer details and greater consistency. Not supported for all
            models.
        response_format:
          type:
            - string
            - 'null'
          description: >-
            The format in which the generated images are returned. Must be one
            of "url" or "b64_json". URLs are only valid for 60 minutes after the
            image is generated.
        size:
          type:
            - string
            - 'null'
          description: The size of the generated images. Not supported for all models.
        style:
          type:
            - string
            - 'null'
          description: >-
            The style of the generated images. Must be one of "vivid" or
            "natural". Vivid causes the model to lean towards generating
            hyper-real and dramatic images. Natural causes the model to produce
            more natural, less hyper-real looking images. Not supported for all
            models.
    ImageGeneration:
      type: object
      description: Response from an image generation request
      required:
        - data
      properties:
        background:
          type:
            - string
            - 'null'
          description: The background color used for transparency. OpenAI only.
        created:
          type:
            - integer
            - 'null'
          format: int64
          description: The Unix timestamp (in seconds) of when the image was generated.
          minimum: 0
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImageData'
          description: Array containing the generated image(s).
        output_format:
          type:
            - string
            - 'null'
          description: The format of the output image. OpenAI only.
        quality:
          type:
            - string
            - 'null'
          description: The quality setting used for image generation. OpenAI only.
        size:
          type:
            - string
            - 'null'
          description: The size of the generated image. OpenAI only.
        usage:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ImageUsage'
              description: >-
                Token usage information for the image generation request. OpenAI
                only.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
    ImageData:
      type: object
      description: Individual image data from the generation response
      properties:
        b64_json:
          type:
            - string
            - 'null'
          description: >-
            The base64-encoded JSON of the generated image, if response_format
            is "b64_json".
        revised_prompt:
          type:
            - string
            - 'null'
          description: >-
            The prompt that was used to generate the image, if there was any
            revision to the prompt.
        url:
          type:
            - string
            - 'null'
          description: >-
            The URL of the generated image, if response_format is "url"
            (default).
    ImageUsage:
      type: object
      description: Token usage information for image generation (OpenAI only)
      required:
        - input_tokens
        - input_tokens_details
        - output_tokens
        - total_tokens
      properties:
        input_tokens:
          type: integer
          format: int32
          description: Number of tokens used in the input prompt.
          minimum: 0
        input_tokens_details:
          $ref: '#/components/schemas/ImageInputTokens'
          description: Breakdown of input tokens by type.
        output_tokens:
          type: integer
          format: int32
          description: Number of tokens used in the generated output.
          minimum: 0
        total_tokens:
          type: integer
          format: int32
          description: >-
            Total number of tokens used in the request (input_tokens +
            output_tokens).
          minimum: 0
    ErrorDetail:
      type: object
      required:
        - message
        - type
      properties:
        message:
          type: string
        type:
          type: string
    ImageInputTokens:
      type: object
      description: >-
        Detailed breakdown of input tokens used in image generation (OpenAI
        only)
      required:
        - image_tokens
        - text_tokens
      properties:
        image_tokens:
          type: integer
          format: int32
          description: Number of tokens from image inputs.
          minimum: 0
        text_tokens:
          type: integer
          format: int32
          description: Number of tokens from text (prompt) inputs.
          minimum: 0

````