← Docs

Image Model Guide

Call image models through the TokenHub inference gateway. Request body follows the standard synchronous HTTP shape: model + input [+ parameters]。

1. Basic Calling Information

ItemDescription
Base URL https://tokenhub.link
Endpoint POST https://tokenhub.link/v1/images/generations
Authentication Authorization: Bearer <TokenHub API Key>. Create the key in API Keys in console. It is shown only once when created.
Model Identifier Use model in request body. For supported models, check Model Catalog. You can call with model name or provider/model format, for example deepseek-v3.2 and alibaba/deepseek-v3.2.
Content-Type Must be application/json.

2. cURL Example (passthrough)

Text-to-image example using a single-turn input.messages payload:

curl -sS "https://tokenhub.link/v1/images/generations" \
  -H "Authorization: Bearer $TOKENHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.6-t2i",
    "input": {
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "text": "A flower shop with elegant windows, a beautiful wooden door, and fresh flowers on display."
            }
          ]
        }
      ]
    },
    "parameters": {
      "prompt_extend": true,
      "watermark": false,
      "n": 1,
      "negative_prompt": "",
      "size": "1280*1280"
    }
  }'

On success, returns HTTP 200 with upstream JSON fields. Example response structure:

{
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "content": [
            {
              "image": "https://dashscope-xxxx.oss-accelerate.aliyuncs.com/...png",
              "type": "image"
            }
          ],
          "role": "assistant"
        }
      }
    ],
    "finished": true
  },
  "usage": {
    "image_count": 1,
    "input_tokens": 0,
    "output_tokens": 0,
    "size": "1280*1280",
    "total_tokens": 0
  },
  "request_id": "815505c6-7c3d-49d7-b197-xxxxx"
}

Image URLs are usually temporary (commonly around 24 hours). Save files to your own storage in time.

3. Parameter Reference

3.1 Top-level Request Body

FieldTypeRequiredDescription
modelstringYesModel name, for example wan2.7-image-pro.
inputobjectYesMultimodal input object. Core field is input.messages.
parametersobjectNoGeneration control parameters. See the table below.

3.2 Detailed Fields for input.messages / content

FieldTypeRequiredDescription
input.messagesarrayYesMessage array. Typical examples use a single user message.
messages[].rolestringYesRole. Typical value is user.
messages[].contentarrayYesMultimodal content list; can combine text and image items.
content[].textstringConditionalText prompt. In pure text-to-image scenarios, at least one text item is required.
content[].imagestring(URL)ConditionalReference/edit image URL. Image editing and interactive editing commonly pass one or two images.

3.3 Detailed Fields for parameters

FieldTypeRequiredDescription
negative_promptstringNoNegative prompt to constrain unwanted elements.
sizestringNoOutput size, for example 2K. Must use size tiers supported by the model.
nintegerNoNumber of generated images. Group-image scenarios may use values such as 4.
prompt_extendbooleanNoWhether to enable prompt expansion.
watermarkbooleanNoWhether to add watermark.
thinking_modebooleanNoWhether to enable thinking mode (depending on model support).
bbox_listarrayNoBounding-box coordinate list for interactive editing.
enable_sequentialbooleanNoEnable sequence consistency for grouped image generation.

4. Official Scenario Examples (updated with TokenHub endpoints)

4.1 Text-to-Image

curl --location 'https://tokenhub.link/v1/images/generations' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TOKENHUB_API_KEY" \
--data '{
    "model": "wan2.7-image-pro",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {"text": "A flower shop with elegant windows, a beautiful wooden door, and fresh flowers on display."}
                ]
            }
        ]
    },
    "parameters": {
        "size": "2K",
        "n": 1,
        "watermark": false,
        "thinking_mode": true
    }
}'

4.2 Image Editing

curl --location 'https://tokenhub.link/v1/images/generations' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TOKENHUB_API_KEY" \
--data '{
    "model": "wan2.7-image-pro",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251229/pjeqdf/car.webp"},
                    {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251229/xsunlm/paint.webp"},
                    {"text": "Apply the graffiti style from image 2 onto the car in image 1."}
                ]
            }
        ]
    },
    "parameters": {
        "size": "2K",
        "n": 1,
        "watermark": false
    }
}'

4.3 Interactive Editing

curl --location 'https://tokenhub.link/v1/images/generations' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TOKENHUB_API_KEY" \
--data '{
    "model": "wan2.7-image-pro",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {"image": "https://img.alicdn.com/imgextra/i3/O1CN0157XGE51l6iL9441yX_!!6000000004770-49-tps-1104-1472.webp"},
                    {"image": "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"},
                    {"text": "Place the alarm clock from image 1 into the selected box in image 2, keeping scene and lighting naturally blended."}
                ]
            }
        ]
    },
    "parameters": {
        "bbox_list": [[],[[989, 515, 1138, 681]]],
        "size": "2K",
        "n": 1,
        "watermark": false
    }
}'

4.4 Group Image Generation

curl --location 'https://tokenhub.link/v1/images/generations' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TOKENHUB_API_KEY" \
--data '{
    "model": "wan2.7-image-pro",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {"text": "A cinematic four-image sequence featuring the same stray orange cat with consistent appearance: Image 1 (spring): the cat walks under blooming cherry blossoms; Image 2 (summer): the cat rests in the shade on an old street; Image 3 (autumn): the cat steps on golden fallen leaves; Image 4 (winter): the cat leaves footprints in the snow."}
                ]
            }
        ]
    },
    "parameters": {
        "enable_sequential": true,
        "n": 4,
        "size": "2K"
    }
}'

5. Reference Links