Call a Token Plan image generation model from an Agent tool, generate an image from a text description, and download it 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.
Interface
POST https://token-plan.maas.qwencloudapi.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 in the command, for example /text-to-image use wan2.7-image to draw a cat.
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 a size automatically. |
Response
- Image URL:
output.choices[0].message.content[0].image. - Usage:
usage.image_count,usage.width,usage.height. - Image URLs expire. Download the image promptly.
Limits
- Image sizes and supported models depend on each model's documentation.
- Billing is based on the number of output images. Actual Credits consumption is shown in Usage in the console.