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

# GPT-Image Generation [Unofficial]

> Generate images based on text prompts and image resources



## OpenAPI

````yaml openapi/en/openai.json POST /openai/gpt/generations
openapi: 3.1.0
info:
  title: Open AI API DOCS
  version: 1.0.0
  description: TTAPI OpenAI API service
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /openai/gpt/generations:
    post:
      description: Generate images based on text prompts and image resources
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GptgenerationsRequest'
      responses:
        '200':
          $ref: '#/components/responses/SuccessResponse'
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    GptgenerationsRequest:
      type: object
      properties:
        model:
          type: string
          description: Supported models
          enum:
            - gpt-image-1.5
            - gpt-image-2
            - gpt-image-2-plus
          default: gpt-image-2
        prompt:
          type: string
          description: >-
            Text prompt for image generation. Since this is a reverse-engineered
            model, it's recommended to include keywords in your prompt such as:
            **"draw a xxx", "generate a", 'draw a xxx'**, Language is not
            restricted; OpenAI itself supports multilingual models with
            excellent Chinese support.
        referImages:
          type: array
          description: Reference image array
          items:
            type: string
          example:
            - https://cdn.ttapi.io/xxx1.png
            - https://cdn.ttapi.io/xxx2.png
        aspect_ratio:
          type: string
          description: 'Support model: `gpt-image-2`'
          enum:
            - '1:1'
            - '3:4'
            - '4:3'
            - '16:9'
            - '9:16'
          example: '1:1'
        size:
          type: string
          description: |-
            Image Size (width × height), support model: `gpt-image-2-plus` 

            must meet the following constraints:

            Both width and height must be multiples of 16
            Maximum edge ≤ 3840
            Aspect ratio ≤ 3:1
            Total pixels: 655,360 ~ 8,294,400

             If the input size is invalid, it will be automatically adjusted to a valid range
          example: 1024x1024
        hookUrl:
          type: string
          description: >-
            Callback notification URL. When task completes or fails, this URL
            will be notified. <a href="gpt-fetch" target="_self">Notification
            data structure</a> is consistent with fetch structure. If not set,
            you need to request the <a href="gpt-fetch" target="_self">fetch
            endpoint</a> for query
      required:
        - prompt
  responses:
    SuccessResponse:
      description: Request successful
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: SUCCESS
              message:
                type: string
                example: success
              data:
                type: object
                example:
                  jobId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            required:
              - status
              - message
              - data
    400Response:
      description: Parameter error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: Authorization failed
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        You can obtain your API key from the <a
        href='https://dashboard.ttapi.io' target='_blank'>TTAPI Dashboard</a>.

````