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

# Text-to-image

> Generate an image from a text prompt. 
### Using SDXL 1.0
Use `stable-diffusion-xl-1024-v1-0` as the `engine_id` of your request and pass in `height` & `width` as one of the following combinations:
- 1024x1024
- 1152x896
- 896x1152
- 1216x832
- 1344x768
- 768x1344
- 1536x640
- 640x1536. 

### Using SD 1.6
Pass in `stable-diffusion-v1-6` as the `engine_id` of your request and ensure the `height` & `width` you pass in adhere to the following restrictions:
- No dimension can be less than 320 pixels
- No dimension can be greater than 1536 pixels

### Using SD Beta
Pass in `stable-diffusion-xl-beta-v2-2-2` as the `engine_id` of your request and ensure the `height` & `width` you pass in adhere to the following restrictions:
- dimensions must be between 128x128 and 512x896 (or 896x512)
- only one dimension can be greater than 512, but not both 

> NOTE: Only **Version 1** engines will work with this endpoint.



## OpenAPI

````yaml /en/api-reference/openapi.json post /sd/v1/generation/{engine_id}/text-to-image
openapi: 3.0.1
info:
  title: MaxAPI Model API
  description: >-
    APIs for text, image, video, audio, and music models available through
    MaxAPI.
  version: 1.0.0
servers:
  - url: https://api.maxapi.ai
    description: MaxAPI production
security: []
tags:
  - name: 模型接口
  - name: 模型接口/绘图模型
  - name: 模型接口/绘图模型/OpenAI Dall-e 格式
  - name: 模型接口/绘图模型/Flux系列
  - name: 模型接口/绘图模型/Flux系列/OpenAI Dalle 格式
  - name: 模型接口/绘图模型/Z-image
  - name: 模型接口/绘图模型/Banana生图异步格式(未来可能兼容其他模型)
  - name: 模型接口/聊天接口（Chat）
  - name: 模型接口/视频模型
  - name: 模型接口/视频模型/谷歌veo
  - name: 模型接口/视频模型/谷歌veo/VertexAI-VEO官方格式
  - name: 模型接口/视频模型/谷歌veo/VertexAI-VEO官方格式/视频生成
  - name: 模型接口/视频模型/谷歌veo/VertexAI-VEO官方格式/任务查询
  - name: 模型接口/视频模型/谷歌veo/AIStudio-VEO官方格式
  - name: 模型接口/视频模型/谷歌veo/AIStudio-VEO官方格式/视频生成
  - name: 模型接口/视频模型/谷歌veo/AIStudio-VEO官方格式/任务查询
  - name: 模型接口/视频模型/谷歌veo/AIStudio-VEO官方格式/下载视频(只有aistudio有这个动作)
  - name: 模型接口/视频模型/谷歌veo/GCP异步任务接口
  - name: 模型接口/视频模型/谷歌veo/官网逆向接口格式
  - name: 模型接口/视频模型/谷歌veo/官网逆向接口格式/视频生成
  - name: 模型接口/视频模型/谷歌veo/官网逆向接口格式/OpenAI官方视频格式(适配 newapi)
  - name: 模型接口/视频模型/Wan阿里万象(官方格式)
  - name: 模型接口/视频模型/豆包seedance(官方格式)
  - name: 模型接口/视频模型/Vidu官方格式
  - name: 模型接口/视频模型/Vidu官方格式/视频生成
  - name: 模型接口/视频模型/Vidu官方格式/图像生成
  - name: 模型接口/视频模型/Vidu官方格式/音频生成
  - name: 模型接口/视频模型/Vidu官方格式/其他功能
  - name: 模型接口/视频模型/Vidu官方格式/任务管理
  - name: 模型接口/视频模型/MiniMax-Hailuo官方格式
  - name: 模型接口/视频模型/MiniMax-Hailuo官方格式/视频生成
  - name: 模型接口/视频模型/MiniMax-Hailuo官方格式/任务管理
  - name: 模型接口/视频模型/MiniMax-Hailuo-OpenAI-Sora兼容格式
  - name: 模型接口/视频模型/MiniMax-Hailuo-OpenAI-Sora兼容格式/视频生成
  - name: 模型接口/视频模型/Sora-2-官方格式
  - name: 模型接口/视频模型/Sora-2-官方格式/创建角色接口
  - name: 模型接口/视频模型/Sora-2026-01-07新格式
  - name: 模型接口/自动补全接口（Completions）
  - name: 模型接口/图像接口（Images）
  - name: 模型接口/向量生成接口（Embeddings）
  - name: 模型接口/音频接口（Audio）
  - name: 模型接口/MJ图像(视频)接口
  - name: 模型接口/MJ图像(视频)接口/InsightFace任务提交
  - name: 模型接口/MJ图像(视频)接口/任务提交
  - name: 模型接口/MJ图像(视频)接口/任务查询
  - name: 模型接口/MJ图像(视频)接口/MJ视频相关
  - name: 模型接口/Suno音乐接口
  - name: 模型接口/Suno音乐接口/GoAmzAI格式
  - name: 模型接口/Suno音乐接口/GoAmzAI格式/v3.5
  - name: 模型接口/Suno音乐接口/GoAmzAI格式/v3.0
  - name: 模型接口/Suno音乐接口/官网原生格式(v2)
  - name: 模型接口/Suno音乐接口/官网原生格式(v2)/所有接口
  - name: 模型接口/Suno音乐接口/官网原生格式(v2)/场景1 生成自定义音乐(带歌词)
  - name: 模型接口/Suno音乐接口/官网原生格式(v2)/场景 2 通过提示词直接生成音乐(带歌词)
  - name: 模型接口/Suno音乐接口/官网原生格式(v2)/场景 4 通过提示词直接生成音乐(纯音乐)
  - name: 模型接口/Suno音乐接口/官网原生格式(v2)/场景3 生成自定义音乐(纯音乐)
  - name: 模型接口/Suno音乐接口/官网原生格式(v2)/场景 5 上传自定义音频并续写
  - name: 模型接口/Suno音乐接口/生成歌词
  - name: 模型接口/Suno音乐接口/NewAPI兼容格式
  - name: 模型接口/Luma视频接口
  - name: 模型接口/Luma视频接口/GoAmzAI格式
  - name: 模型接口/Luma视频接口/GoAmzAI格式/付费版
  - name: 模型接口/Luma视频接口/GoAmzAI格式/免费版
  - name: 模型接口/Luma视频接口/官网原生格式(v2)
  - name: 模型接口/SD图像接口
  - name: 模型接口/SD图像接口/SD3
  - name: 模型接口/SD图像接口/SDXL
  - name: 模型接口/Fish Audio
  - name: 模型接口/统一视频接口
  - name: 模型接口/统一视频接口/阿里Wan(万相视频
  - name: 模型接口/统一视频接口/Sora2视频
  - name: 模型接口/统一视频接口/Seedance(即梦视频
  - name: 模型接口/统一视频接口/Google-Veo
  - name: 历史接口
  - name: 历史接口/PPT类接入
  - name: 历史接口/请求示例
  - name: 历史接口/原始接口（参数需要定义后才能发送请求）
  - name: 佐糖API
  - name: MewXAI星月熊开放API
  - name: MewXAI星月熊开放API/开放API接口
  - name: MewXAI星月熊开放API/示例
  - name: Ideogram（绘画）
  - name: 可灵API
  - name: RunWay官方API
  - name: 视频生成
  - name: 任务查询
  - name: Wan官方格式
  - name: 图像生成
  - name: 音频生成
  - name: 其他功能
  - name: 任务管理
  - name: InsightFace任务提交
  - name: 任务提交
  - name: Generate
  - name: SDXL & SD1.6
paths:
  /sd/v1/generation/{engine_id}/text-to-image:
    post:
      tags:
        - MaxAPI endpoints
      summary: Text-to-image
      description: >-
        Generate an image from a text prompt. 

        ### Using SDXL 1.0

        Use `stable-diffusion-xl-1024-v1-0` as the `engine_id` of your request
        and pass in `height` & `width` as one of the following combinations:

        - 1024x1024

        - 1152x896

        - 896x1152

        - 1216x832

        - 1344x768

        - 768x1344

        - 1536x640

        - 640x1536. 


        ### Using SD 1.6

        Pass in `stable-diffusion-v1-6` as the `engine_id` of your request and
        ensure the `height` & `width` you pass in adhere to the following
        restrictions:

        - No dimension can be less than 320 pixels

        - No dimension can be greater than 1536 pixels


        ### Using SD Beta

        Pass in `stable-diffusion-xl-beta-v2-2-2` as the `engine_id` of your
        request and ensure the `height` & `width` you pass in adhere to the
        following restrictions:

        - dimensions must be between 128x128 and 512x896 (or 896x512)

        - only one dimension can be greater than 512, but not both 


        > NOTE: Only **Version 1** engines will work with this endpoint.
      operationId: textToImage
      parameters:
        - name: engine_id
          in: path
          description: ''
          required: true
          example: stable-diffusion-v1-6
          schema:
            type: string
        - name: Accept
          in: header
          description: >-
            The format of the response.  Leave blank for JSON, or set to
            'image/png' for a PNG image.
          required: false
          example: ''
          schema:
            default: application/json
            enum:
              - application/json
              - image/png
            type: string
        - name: Organization
          in: header
          description: >-
            Allows for requests to be scoped to an organization other than the
            user's default.  If not provided, the user's default organization
            will be used.
          required: false
          example: org-123456
          schema:
            type: string
        - name: Stability-Client-ID
          in: header
          description: >-
            Used to identify the source of requests, such as the client
            application or sub-organization. Optional, but recommended for
            organizational clarity.
          required: false
          example: my-great-plugin
          schema:
            type: string
        - name: Stability-Client-Version
          in: header
          description: >-
            Used to identify the version of the application or service making
            the requests. Optional, but recommended for organizational clarity.
          required: false
          example: 1.2.1
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToImageRequestBody'
            example:
              cfg_scale: 7
              height: 512
              width: 512
              sampler: K_DPM_2_ANCESTRAL
              samples: 1
              steps: 30
              text_prompts:
                - text: A lighthouse on a cliff
                  weight: 1
      responses:
        '200':
          description: Request succeeded.
          content:
            application/json:
              schema:
                description: >-
                  An array of results from the generation request, where each
                  image is a base64 encoded PNG.
                type: object
                properties:
                  artifacts:
                    type: array
                    x-go-type-skip-optional-pointer: true
                    items:
                      $ref: '#/components/schemas/Image'
        '400':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: 296a972f-666a-44a1-a3df-c9c28a1f56c0
                name: bad_request
                message: 'init_image: is required'
        '401':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: 9160aa70-222f-4a36-9eb7-475e2668362a
                name: unauthorized
                message: missing authorization header
        '403':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: 5cf19777-d17f-49fe-9bd9-39ff0ec6bb50
                name: permission_denied
                message: You do not have permission to access this resource
        '404':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: 92b19e7f-22a2-4e71-a821-90edda229293
                name: not_found
                message: The specified engine (ID some-fake-engine) was not found.
        '500':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                id: f81964d6-619b-453e-97bc-9fd7ac3f04e7
                name: server_error
                message: An unexpected server error occurred, please try again.
      deprecated: false
      security: []
components:
  schemas:
    TextToImageRequestBody:
      allOf:
        - type: object
          properties:
            height:
              $ref: '#/components/schemas/DiffuseImageHeight'
            width:
              $ref: '#/components/schemas/DiffuseImageWidth'
            text_prompts:
              $ref: '#/components/schemas/TextPromptsForTextToImage'
          required:
            - text_prompts
        - $ref: '#/components/schemas/GenerationRequestOptionalParams'
      example:
        cfg_scale: 7
        height: 512
        width: 512
        sampler: K_DPM_2_ANCESTRAL
        samples: 1
        seed: 0
        steps: 30
        text_prompts:
          - text: A lighthouse on a cliff
            weight: 1
    Image:
      type: object
      properties:
        base64:
          type: string
          x-go-type-skip-optional-pointer: true
          description: Image encoded in base64
        finishReason:
          type: string
          x-go-type-skip-optional-pointer: true
          enum:
            - CONTENT_FILTERED
            - ERROR
            - SUCCESS
          example: CONTENT_FILTERED
        seed:
          type: number
          x-go-type-skip-optional-pointer: true
          description: The seed associated with this image
          example: 1229191277
      example:
        - base64: ...very long string...
          finishReason: SUCCESS
          seed: 1050625087
        - base64: ...very long string...
          finishReason: CONTENT_FILTERED
          seed: 1229191277
    Error:
      type: object
      x-go-name: RESTError
      properties:
        id:
          x-go-name: ID
          type: string
          description: A unique identifier for this particular occurrence of the problem.
          example: 296a972f-666a-44a1-a3df-c9c28a1f56c0
        name:
          type: string
          description: The short-name of this class of errors e.g. `bad_request`.
          example: bad_request
        message:
          type: string
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          example: Header parameter Authorization is required, but not found
      required:
        - name
        - id
        - message
    DiffuseImageHeight:
      x-go-type: uint64
      type: integer
      description: >-
        Height of the image to generate, in pixels, in an increment divisible by
        64.
      multipleOf: 64
      default: 512
      minimum: 128
      example: 512
    DiffuseImageWidth:
      x-go-type: uint64
      type: integer
      description: >-
        Width of the image to generate, in pixels, in an increment divisible by
        64.
      multipleOf: 64
      default: 512
      minimum: 128
      example: 512
    TextPromptsForTextToImage:
      title: TextPrompts
      type: array
      items:
        $ref: '#/components/schemas/TextPrompt'
      minItems: 1
      description: >-
        An array of text prompts to use for generation.


        Given a text prompt with the text `A lighthouse on a cliff` and a weight
        of `0.5`, it would be represented as:


        ```

        "text_prompts": [
          {
            "text": "A lighthouse on a cliff",
            "weight": 0.5
          }
        ]

        ```
    GenerationRequestOptionalParams:
      type: object
      description: >-
        Represents the optional parameters that can be passed to any generation
        request.
      properties:
        cfg_scale:
          $ref: '#/components/schemas/CfgScale'
        clip_guidance_preset:
          $ref: '#/components/schemas/ClipGuidancePreset'
        sampler:
          $ref: '#/components/schemas/Sampler'
        samples:
          $ref: '#/components/schemas/Samples'
        seed:
          $ref: '#/components/schemas/Seed'
        steps:
          $ref: '#/components/schemas/Steps'
        style_preset:
          $ref: '#/components/schemas/StylePreset'
        extras:
          $ref: '#/components/schemas/Extras'
    TextPrompt:
      type: object
      properties:
        text:
          type: string
          description: The prompt itself
          maxLength: 2000
          example: A lighthouse on a cliff
        weight:
          type: number
          description: Weight of the prompt (use negative numbers for negative prompts)
          format: float
          example: 0.8167237
      description: Text prompt for image generation
      required:
        - text
    CfgScale:
      type: number
      description: >-
        How strictly the diffusion process adheres to the prompt text (higher
        values keep your image closer to your prompt)
      default: 7
      minimum: 0
      maximum: 35
      example: 7
    ClipGuidancePreset:
      type: string
      default: NONE
      enum:
        - FAST_BLUE
        - FAST_GREEN
        - NONE
        - SIMPLE
        - SLOW
        - SLOWER
        - SLOWEST
      example: FAST_BLUE
    Sampler:
      type: string
      description: >-
        Which sampler to use for the diffusion process. If this value is omitted
        we'll automatically select an appropriate sampler for you.
      enum:
        - DDIM
        - DDPM
        - K_DPMPP_2M
        - K_DPMPP_2S_ANCESTRAL
        - K_DPM_2
        - K_DPM_2_ANCESTRAL
        - K_EULER
        - K_EULER_ANCESTRAL
        - K_HEUN
        - K_LMS
      example: K_DPM_2_ANCESTRAL
    Samples:
      x-go-type: uint64
      type: integer
      description: Number of images to generate
      default: 1
      minimum: 1
      maximum: 10
      example: 1
    Seed:
      type: integer
      x-go-type: uint32
      description: Random noise seed (omit this option or use `0` for a random seed)
      default: 0
      minimum: 0
      maximum: 4294967295
      example: 0
    Steps:
      x-go-type: uint64
      type: integer
      description: Number of diffusion steps to run.
      default: 30
      minimum: 10
      maximum: 50
      example: 50
    StylePreset:
      type: string
      enum:
        - 3d-model
        - analog-film
        - anime
        - cinematic
        - comic-book
        - digital-art
        - enhance
        - fantasy-art
        - isometric
        - line-art
        - low-poly
        - modeling-compound
        - neon-punk
        - origami
        - photographic
        - pixel-art
        - tile-texture
      description: >-
        Pass in a style preset to guide the image model towards a particular
        style.

        This list of style presets is subject to change.
    Extras:
      type: object
      description: >-
        Extra parameters passed to the engine.

        These parameters are used for in-development or experimental features
        and may change

        without warning, so please use with caution.
      properties: {}

````