Todos los productos
Search
Centro de documentos

Alibaba Cloud Model Studio:Integrar modelos de generación multimodal

Última actualización: Oct 12, 2026

Los modelos de generación de imágenes, generación de video y síntesis de voz en Token Plan deben integrarse mediante el mecanismo de extensión de cada herramienta (Skill, Slash Command o Agent).

Ejemplo: Integrar un modelo de generación de imágenes en Claude Code

Este ejemplo muestra cómo integrar un modelo de generación de imágenes en Claude Code mediante un Slash Command. El proceso es similar para otras herramientas, con diferencias en el mecanismo de extensión y la ruta del archivo de configuración.

Paso 1: Crear un Slash Command

Configure la clave API específica del plan (con prefijo sk-sp-) como la variable de entorno $ANTHROPIC_AUTH_TOKEN para la autenticación curl en los pasos siguientes.

Cree el archivo .claude/commands/text-to-image.md en el directorio raíz de su proyecto con el siguiente contenido:

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 (e.g., "model=wan2.7-image" or "use wan2.7-image to draw"), 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, and wan2.7-image-pro; 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.

Paso 2: Generar una imagen

En Claude Code, escriba /text-to-image draw a cat. Para utilizar un modelo de generación de imágenes distinto al predeterminado, incluya el nombre del modelo en el comando, por ejemplo /text-to-image draw a cat using wan2.7-image.

Ejemplo: Integrar un modelo de generación de video en Claude Code

Este ejemplo muestra cómo integrar un modelo de generación de video en Claude Code mediante un Slash Command. La generación de video utiliza una API asíncrona con el flujo de trabajo: enviar tarea, consultar estado y descargar video.

Paso 1: Crear un Slash Command

Configure la clave API específica del plan (con prefijo sk-sp-) como la variable de entorno $ANTHROPIC_AUTH_TOKEN para la autenticación curl en los pasos siguientes.

Cree el archivo .claude/commands/text-to-video.md en el directorio raíz de su proyecto con el siguiente contenido:

Call the Token Plan text-to-video API to generate a video based on a description and automatically download it locally.

User request: $ARGUMENTS

## Steps

1. Extract prompt (video description), model (default happyhorse-1.1-t2v), resolution (default 720P), ratio (default 16:9), and duration (default 5 seconds) from the user request. If the user explicitly specifies a model (e.g., "model=happyhorse-1.1-r2v"), you must use exactly that model name.

2. Use the Bash tool to run the following script, which submits the task, waits for completion, and downloads the video in one go:

```bash
#!/bin/bash
set -e

TASK_RESPONSE=$(curl -s -X POST "https://token-plan.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis" \
  -H "X-DashScope-Async: enable" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model>",
    "input": {"prompt": "<prompt>"},
    "parameters": {"resolution": "<resolution>", "ratio": "<ratio>", "duration": <duration>}
  }')

TASK_ID=$(echo "$TASK_RESPONSE" | grep -o '"task_id":"[^"]*"' | head -1 | cut -d'"' -f4)
if [ -z "$TASK_ID" ]; then echo "Submission failed: $TASK_RESPONSE"; exit 1; fi
echo "Task submitted, ID: $TASK_ID. Waiting for generation..."

while true; do
  sleep 15
  STATUS_RESPONSE=$(curl -s "https://token-plan.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/$TASK_ID" \
    -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN")
  STATUS=$(echo "$STATUS_RESPONSE" | grep -o '"task_status":"[^"]*"' | cut -d'"' -f4)
  if [ "$STATUS" = "SUCCEEDED" ]; then
    VIDEO_URL=$(echo "$STATUS_RESPONSE" | grep -o '"video_url":"[^"]*"' | cut -d'"' -f4)
    OUTPUT="generated_$(date +%Y%m%d_%H%M%S).mp4"
    curl -s -o "$OUTPUT" "$VIDEO_URL"
    echo "Video downloaded: $(pwd)/$OUTPUT"
    exit 0
  elif [ "$STATUS" = "FAILED" ]; then
    echo "Generation failed: $STATUS_RESPONSE"; exit 1
  fi
  echo "Generating..."
done
```

3. Display the generated video file path to the user.

Paso 2: Generar un video

En Claude Code, escriba /text-to-video a white cat sunbathing on a balcony. Para utilizar un modelo de generación de video diferente, incluya el nombre del modelo en el comando, por ejemplo /text-to-video generate a video of a cat jumping using happyhorse-1.1-r2v.

Ejemplo: Integrar un modelo de síntesis de voz en Claude Code

Este ejemplo muestra cómo integrar un modelo de síntesis de voz en Claude Code mediante un Slash Command. La síntesis de voz utiliza una API síncrona y admite modos sin streaming y con streaming.

Paso 1: Crear un Slash Command

Configure la clave API específica del plan (con prefijo sk-sp-) como la variable de entorno $ANTHROPIC_AUTH_TOKEN para la autenticación curl en los pasos siguientes.

Cree el archivo .claude/commands/text-to-speech.md en el directorio raíz de su proyecto con el siguiente contenido:

Call the Token Plan speech synthesis API to convert text to an audio file.

User request: $ARGUMENTS

## Steps

1. Extract text (the text to synthesize), voice (voice style, default longanhuan_v3.6), format (audio format, default mp3), and sample_rate (sample rate, default 24000) from the user request. If the user explicitly specifies a model, use that model name; otherwise default to qwen-audio-3.0-tts-plus.

2. Call the API to synthesize speech (use the Bash tool to run curl):

```
curl -s -X POST "https://token-plan.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/tts/SpeechSynthesizer" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -o "speech_$(date +%Y%m%d_%H%M%S).<format>" \
  -d '{
    "model": "<model>",
    "input": {
      "text": "<text>",
      "voice": "<voice>",
      "format": "<format>",
      "sample_rate": <sample_rate>
    }
  }'
```

3. Display the generated audio file path to the user.

Paso 2: Sintetizar voz

En Claude Code, escriba /text-to-speech Hello, welcome to Model Studio.

Otras herramientas

La siguiente tabla enumera el mecanismo de extensión y la ruta del archivo de configuración para las principales herramientas de codificación con IA que admiten extensiones. Guarde el mismo contenido del ejemplo de Claude Code anterior en la ruta correspondiente.

Herramienta

Mecanismo de extensión

Ruta del archivo de configuración

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

Qoder

Skill

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

NotaLas herramientas basadas en Skill (Codex, Qwen Code, OpenClaw, Hermes Agent, Qoder) requieren YAML front matter al principio del archivo de configuración:

---
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 requiere un formato de front matter diferente:

---
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 ...)