Call Token Plan image generation models in Agent tools to generate images from text descriptions and download them locally.
Supported models
| Model | Description |
|---|---|
qwen-image-3.0-pro | Qwen Image Generation and Editing 3.0 Pro, supports text-to-image and image-to-image |
qwen-image-2.0-pro | Qwen Image Generation 2.0 Pro (Team Edition only) |
qwen-image-2.0 | Qwen Image Generation 2.0 (Team Edition only) |
wan2.7-image | Wan image generation |
wan2.7-image-pro | Wan image generation Pro |
Prerequisites
- A Token Plan subscription and an API key that starts with
sk-sp-. For details, see Integration overview. - Your AI coding tool supports Slash Commands. For configuration paths of other tools, see Other tools.
Endpoint
POST https://token-plan.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
Use Authorization: Bearer $ANTHROPIC_AUTH_TOKEN in the request header. For the request body and response fields, see the sections below.
Step 1: Create a Slash Command
Configure the Token Plan API key as the environment variable $ANTHROPIC_AUTH_TOKEN.
Create .claude/commands/text-to-image.md in the project root and add the following content:
Step 2: Generate an image
In Claude Code, enter /text-to-image Draw a cat. To use another model, specify the model name in the instruction, for example /text-to-image Draw a cat with wan2.7-image.
Request parameters
| Parameter | Required | Description |
|---|---|---|
model | Yes | Image generation model ID. |
input.messages[0].content[0].text | Yes | Image description. |
parameters.size | No | Image size, for example 1024*1024. If omitted, the model selects the size. |
Response
- Image URL:
output.choices[0].message.content[0].image. - Usage:
usage.image_count,usage.width,usage.height. - Image URLs expire. Download them promptly.
Limits
- Supported image sizes and models depend on each model's documentation.
- Billing is based on the number of output images. Actual consumption is shown in the console usage statistics.