> ## Documentation Index
> Fetch the complete documentation index at: https://nusaai-edit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create image generation

> Generates one or more images from a text prompt.



## OpenAPI

````yaml post /images/generations
openapi: 3.0.3
info:
  title: Neosantara AI API
  description: API for Neosantara AI services.
  version: 1.0.0
servers:
  - url: https://api.neosantara.xyz/v1
    description: API Base URL
security:
  - apiKey: []
tags:
  - name: response
  - name: chat
  - name: completions
  - name: embeddings
  - name: models
  - name: moderations
  - name: reasoning
  - name: authentication
  - name: images
paths:
  /images/generations:
    post:
      tags:
        - images
      summary: Create image generation
      description: Generates one or more images from a text prompt.
      operationId: imageGenerations
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImagesGenerationsRequest'
            examples:
              simple_generation:
                summary: Simple image generation request
                value:
                  prompt: A beautiful sunset over the mountains in an anime art style.
                  'n': 1
                  size: 1024x1024
                  model: neosantara-gen-2045
      responses:
        '200':
          description: Image generation result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesGenerationsResponse'
              examples:
                success_response:
                  summary: Successful image generation response
                  value:
                    id: img-12345
                    object: image
                    created: 1717950000
                    model: neosantara-gen-2045
                    data:
                      - url: https://example.com/image.png
                        b64_json: null
                    usage:
                      prompt_tokens: 15
                      completion_tokens: 8
                      total_tokens: 23
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/AuthError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ImagesGenerationsRequest:
      type: object
      required:
        - prompt
        - model
      properties:
        model:
          type: string
          description: The model to use for image generation.
          default: neosantara-gen-2045
        prompt:
          type: string
          description: >-
            A text description of the desired image(s). The maximum length is
            1000 characters.
        'n':
          type: integer
          description: The number of images to generate.
          default: 1
          minimum: 1
          maximum: 4
        size:
          type: string
          description: The size of the generated images.
          default: 1024x1024
          enum:
            - 256x256
            - 512x512
            - 1024x1024
        response_format:
          type: string
          description: The format in which the generated images are returned.
          default: url
          enum:
            - url
            - b64_json
        steps:
          type: integer
          description: The number of inference steps to perform.
          default: 1
          minimum: 1
          maximum: 50
    ImagesGenerationsResponse:
      type: object
      properties:
        id:
          type: string
          description: A unique identifier for the image generation request.
        object:
          type: string
          example: image
          description: The type of object returned.
        created:
          type: integer
          description: The timestamp of when the image was created.
        model:
          type: string
          description: The model used for the image generation.
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImageGenerationData'
          description: A list of generated image objects.
        usage:
          $ref: '#/components/schemas/Usage'
          description: Token usage information for the request.
        _metadata:
          $ref: '#/components/schemas/Metadata'
    ImageGenerationData:
      type: object
      properties:
        url:
          type: string
          format: uri
          nullable: true
          description: >-
            The URL of the generated image. Will be null if `response_format` is
            `b64_json`.
        b64_json:
          type: string
          nullable: true
          description: >-
            The base64 encoded JSON of the generated image. Will be null if
            `response_format` is `url`.
      oneOf:
        - required:
            - url
        - required:
            - b64_json
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
    Metadata:
      type: object
      properties:
        creator:
          type: string
          example: noesantara.xyz
        status:
          type: boolean
        timestamp:
          type: string
          format: date-time
        request_id:
          type: string
          nullable: true
        processing_time:
          type: number
          nullable: true
        tier:
          type: string
          nullable: true
        user_total_usage:
          $ref: '#/components/schemas/UsageInfo'
          nullable: true
    BadRequestError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              example: invalid_request_error
            code:
              type: string
              enum:
                - invalid_parameter
                - missing_parameter
                - invalid_format
                - invalid_messages
              example: invalid_parameter
            param:
              type: string
              nullable: true
            details:
              type: object
              nullable: true
              additionalProperties: true
          required:
            - message
            - type
            - code
        info_metadata:
          $ref: '#/components/schemas/Metadata'
    AuthError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              example: auth_error
            code:
              type: string
              enum:
                - missing_api_key
                - invalid_api_key
                - token_expired
                - session_expired
                - invalid_token
              example: invalid_api_key
            details:
              type: object
              nullable: true
              additionalProperties: true
          required:
            - message
            - type
            - code
        info_metadata:
          $ref: '#/components/schemas/Metadata'
    RateLimitError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              example: rate_limit_exceeded
            code:
              type: string
              enum:
                - rpm_exceeded
                - tpm_exceeded
                - user_total_daily_limit_exceeded
                - user_total_monthly_limit_exceeded
              example: rpm_exceeded
            details:
              $ref: '#/components/schemas/RateLimitDetails'
              nullable: true
          required:
            - message
            - type
            - code
        info_metadata:
          $ref: '#/components/schemas/Metadata'
    ServerError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              example: server_error
            code:
              type: string
              enum:
                - internal_error
                - service_unavailable
                - timeout
              example: internal_error
            details:
              type: object
              nullable: true
              additionalProperties: true
          required:
            - message
            - type
            - code
        info_metadata:
          $ref: '#/components/schemas/Metadata'
    UsageInfo:
      type: object
      properties:
        used:
          type: integer
        limit:
          type: integer
        remaining:
          type: integer
        reset_at:
          type: string
          format: date-time
      required:
        - used
        - limit
        - remaining
        - reset_at
    RateLimitDetails:
      type: object
      properties:
        limit:
          type: integer
        remaining:
          type: integer
        reset:
          type: string
          format: date-time
        retry_after:
          type: integer
          nullable: true
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BadRequestError'
    AuthError:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthError'
    RateLimitError:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
    ServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ServerError'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: Your NeosantaraAI API Key.

````