All Products
Search
Document Center

Alibaba Cloud Model Studio:Integrate multimodal generation models

Last Updated:Jul 14, 2026

Image generation models must be integrated through each tool's extension mechanism (Skill, Slash Command, or Agent).

Example: Integrate an image generation model in Claude Code

This example shows how to integrate an image generation model in Claude Code using a Slash Command. The process is similar for other tools, with differences in extension mechanism and configuration file path.

Step 1: Create a Slash Command

Create the file .claude/commands/text-to-image.md in your project root directory with the following content:

Call the Token Plan text-to-image API to generate an image based on a description.

User request: $ARGUMENTS

## Steps

1. Extract prompt (image description), model, and size (default: 1024*1024) from the user request. If the user explicitly specifies a model (for example "model=wan2.7-image" or "use wan2.7-image"), you must use exactly that model name and must not fall back to the default; use the default qwen-image-2.0 only when no model is specified. Common image generation models include qwen-image-2.0, qwen-image-2.0-pro, wan2.7-image, wan2.7-image-pro, and z-image-turbo; see the Model Studio model list for the full set.

2. Call the API to generate an image (use the Bash tool to run curl):

```
curl -s -X POST "https://token-plan.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model>",
    "input": {
      "messages": [{"role":"user","content":[{"text":"<prompt>"}]}]
    },
    "parameters": {"size":"<size>"}
  }'
```

3. Extract the image URL from output.choices[*].message.content[*].image in the response JSON.

4. Download the image to the current directory with curl -s -o "generated_$(date +%Y%m%d_%H%M%S).png" "<URL>".

5. Display the generated image file path to the user.

Step 2: Generate an image

In Claude Code, type /text-to-image draw a cat. To use a model other than the default, include the model name in the request, for example /text-to-image draw a cat using wan2.7-image.

Other tools

The following table lists the extension mechanism and configuration file path for each tool. Save the same content from the Claude Code example to the corresponding path.

Tool

Extension mechanism

Configuration file path

Claude Code

Slash Command

.claude/commands/text-to-image.md

Codex

Skill

~/.codex/skills/token-plan-image/SKILL.md

Qwen Code

Skill

~/.qwen/skills/text-to-image/SKILL.md

OpenCode

Agent

.opencode/agents/text-to-image.md

OpenClaw

Skill

~/.openclaw/workspace/skills/token-plan-image/SKILL.md

Hermes Agent

Skill

~/.hermes/skills/media/text-to-image/SKILL.md

Note

Skill-based tools (Codex, Qwen Code, OpenClaw, Hermes Agent) require YAML front matter at the beginning of the file:

---
name: "token-plan-image"
description: "Call the Token Plan text-to-image model to generate images from text descriptions. Activates when the user asks to draw or generate images."
---

(... same content as the Claude Code example above ...)

OpenCode Agent requires a different front matter format:

---
description: "Call the Token Plan text-to-image model to generate images from text descriptions."
mode: subagent
tools:
  bash: true
  write: false
  edit: false
---

(... same content as the Claude Code example above ...)