Skip to Content
API ReferenceImageImage Generation

Create image generation

Use this interface to generate images from text prompts. The interface format is compatible with the OpenAI generations  protocol.

Authorization

Authorization

  • Type: HTTP Bearer Auth, value type string
  • Required
  • Description: Used to verify account information. Go to API Console , click Create Token to obtain.
Authorization: Bearer <YOUR_API_KEY>

Request Headers

Content-Type

  • Type: enum<string>
  • Required, fixed value application/json
  • Description: The media type of the request body. Must be application/json.

Request Body

Overview

ParameterTypeRequiredDefaultDescription
modelstringYes—Image model ID
promptstringYes—Image description text
output_formatstringNopngOutput image format
response_formatstringNob64_jsonImage return format
sizestringNoautoOutput image size
watermarkbooleanNofalseWhether to add watermark

model

  • Type: string
  • Required
  • Description: The image model to use.
  • Options: Ming-Image-0.1-Design

prompt

  • Type: string
  • Required
  • Description: The prompt text used to describe the target image.

output_format

  • Type: string
  • Optional, default png
  • Description: The output format of the generated image.
  • Options: png, jpeg

response_format

  • Type: string
  • Optional, default b64_json
  • Description: The format of the returned image.
  • Options:
    • url — Returns an image URL. The URL is valid for 24 hours.
    • b64_json — Returns Base64-encoded image data.

size

  • Type: string
  • Optional, default auto
  • Description: The output image size. Set to auto to let the model choose automatically; or specify it using the {w}x{h} format, such as "1024x1024".

Ming-Image-0.1-Design supports image sizes of 1K and above, such as "1024x1024" and "2048x2048".


watermark

  • Type: boolean
  • Optional, default false
  • Description: Whether to add watermarks to AI-generated images.
  • Options:
    • true — Enable the explicit watermark and implicit digital watermark generated by AI to comply with policy requirements.
    • false — Disable all watermarks.

Unsupported Parameters

The following OpenAI images/generations parameters are not supported by this interface:

  • background
  • moderation
  • n
  • output_compression
  • partial_images
  • quality
  • style
  • stream

Response Body

created

  • Type: integer
  • Description: Unix timestamp in seconds representing when the response was generated.

id

  • Type: string
  • Description: The unique identifier of this request.

model

  • Type: string
  • Description: The model ID used for this request.

data

  • Type: object[]
  • Description: The generated image list.

data[].b64_json

  • Type: string
  • Description: Base64-encoded image data, returned when response_format is b64_json.

data[].url

  • Type: string
  • Description: Image URL, returned when response_format is url. The URL is valid for 24 hours.

output_format

  • Type: string
  • Description: The image format of this response, such as png or jpeg.

size

  • Type: string | null
  • Description: The output image size. A concrete value such as 1024x512 is returned when it is explicitly specified; null is returned when it is not specified.

usage

  • Type: object
  • Description: Token and image-count usage statistics for this request. When billing is based on image count, use input_image_count and output_image_count.

usage.input_tokens

  • Type: integer
  • Description: Number of input tokens consumed.

usage.input_tokens_details

  • Type: object
  • Description: Breakdown of input tokens.
  • Fields:
    • image_tokens — Number of tokens consumed by image input.
    • text_tokens — Number of tokens consumed by text input.

usage.output_tokens

  • Type: integer
  • Description: Number of output tokens generated.

usage.output_tokens_details

  • Type: object
  • Description: Breakdown of output tokens.
  • Fields:
    • image_tokens — Number of tokens consumed by image output.
    • text_tokens — Number of tokens consumed by text output.

usage.total_tokens

  • Type: integer
  • Description: Total number of tokens consumed.

usage.input_image_count

  • Type: integer
  • Description: Number of input images in this request. Image generation always returns 0.

usage.output_image_count

  • Type: integer
  • Description: Number of output images generated in this request. This value is used for image-count billing.

Example


Request Example

curl --location --request POST \ 'https://api.ant-ling.com/v1/images/generations' \ --header 'Authorization: Bearer <YOUR_API_KEY>' \ --header 'Content-Type: application/json' \ --data-raw '{ "model": "Ming-Image-0.1-Design", "prompt": "Generate an apple" }'

Response Example

{ "created": 1713833628, "id": "0b446a1717930916439978967edcf9", "model": "Ming-Image-0.1-Design", "data": [ { "b64_json": "..." } ], "output_format": "png", "size": null, "usage": { "input_tokens": 0, "input_tokens_details": { "image_tokens": 0, "text_tokens": 0 }, "output_tokens": 4096, "output_tokens_details": { "image_tokens": 4096, "text_tokens": 0 }, "total_tokens": 4096, "input_image_count": 0, "output_image_count": 1 } }
Was this page helpful?
Last updated on