forked from farhoodlabs/skills
refactor: remove scripts from minimax-image-generation skill
Inline the API call example directly in SKILL.md instead of providing a separate generate.sh script. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,7 +58,5 @@ All three are standard Unix tools. No Python or Node required.
|
|||||||
```
|
```
|
||||||
minimax-image-generation/
|
minimax-image-generation/
|
||||||
├── SKILL.md # Skill definition + user-facing docs
|
├── SKILL.md # Skill definition + user-facing docs
|
||||||
├── scripts/
|
|
||||||
│ └── generate.sh # Generation script (CLI entry point)
|
|
||||||
└── CLAUDE.md # These implementation notes
|
└── CLAUDE.md # These implementation notes
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,25 +4,18 @@ Claude Code skill for generating images via the MiniMax API.
|
|||||||
Wraps the MiniMax `/v1/image_generation` endpoint as a `/minimax-image-generation` slash command.
|
Wraps the MiniMax `/v1/image_generation` endpoint as a `/minimax-image-generation` slash command.
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
- `SKILL.md` — skill definition (deployed to ~/.claude/skills/minimax-image-generation/)
|
- `SKILL.md` — skill definition + usage documentation
|
||||||
- `scripts/generate.sh` — image generation script
|
|
||||||
- `CLAUDE.md` — implementation notes
|
- `CLAUDE.md` — implementation notes
|
||||||
|
|
||||||
## Commands
|
|
||||||
```bash
|
|
||||||
bash scripts/generate.sh [options]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Rules
|
## Rules
|
||||||
- The generated image is written to disk as `output-0.jpeg` (and `output-1.jpeg`, etc. for multiple images)
|
|
||||||
- Set `MINIMAX_API_KEY` env var before use
|
- Set `MINIMAX_API_KEY` env var before use
|
||||||
- After edits: run `bash scripts/sync.sh` to deploy (if provided)
|
- Images are written to disk as `output-0.jpeg`, `output-1.jpeg`, etc.
|
||||||
|
|
||||||
---
|
---
|
||||||
name: minimax-image-generation
|
name: minimax-image-generation
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
description: "Generate images from MiniMax's image-01 model. Triggered by phrases like 'generate image', 'create picture', 'minimax image', 'text to image'."
|
description: "Generate images from MiniMax's image-01 model. Triggered by phrases like 'generate image', 'create picture', 'minimax image', 'text to image'."
|
||||||
argument-hint: '"a sunset over the ocean, cinematic" [--aspect-ratio=16:9] [--num-images=1] [--output=output.jpeg]'
|
argument-hint: '"a sunset over the ocean, cinematic" [--aspect-ratio=16:9]'
|
||||||
allowed-tools: Bash, Read, Write
|
allowed-tools: Bash, Read, Write
|
||||||
user-invocable: true
|
user-invocable: true
|
||||||
metadata:
|
metadata:
|
||||||
@@ -37,16 +30,14 @@ metadata:
|
|||||||
bins:
|
bins:
|
||||||
- curl
|
- curl
|
||||||
- jq
|
- jq
|
||||||
|
- base64
|
||||||
primaryEnv: MINIMAX_API_KEY
|
primaryEnv: MINIMAX_API_KEY
|
||||||
files:
|
|
||||||
- "scripts/*"
|
|
||||||
tags:
|
tags:
|
||||||
- image
|
- image
|
||||||
- image-generation
|
- image-generation
|
||||||
- generative-ai
|
- generative-ai
|
||||||
- minimax
|
- minimax
|
||||||
- text-to-image
|
- text-to-image
|
||||||
- AI
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# MiniMax Image Generation
|
# MiniMax Image Generation
|
||||||
@@ -56,14 +47,8 @@ metadata:
|
|||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Set your API key
|
|
||||||
export MINIMAX_API_KEY="your-minimax-api-key"
|
export MINIMAX_API_KEY="your-minimax-api-key"
|
||||||
|
|
||||||
# Generate an image
|
|
||||||
/minimax-image-generation "a cat wearing a spacesuit, cinematic photography"
|
/minimax-image-generation "a cat wearing a spacesuit, cinematic photography"
|
||||||
|
|
||||||
# With options
|
|
||||||
/minimax-image-generation "a sunset over the ocean" --aspect-ratio=16:9 --num-images=1 --output=sunset.jpeg
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -74,81 +59,45 @@ Extract from the user's input:
|
|||||||
|
|
||||||
1. **PROMPT**: The image description (required)
|
1. **PROMPT**: The image description (required)
|
||||||
2. **ASPECT_RATIO**: `16:9` (default), `1:1`, `9:16`, `4:3`, `3:4`
|
2. **ASPECT_RATIO**: `16:9` (default), `1:1`, `9:16`, `4:3`, `3:4`
|
||||||
3. **NUM_IMAGES**: Number of images to generate (1–4, default 1)
|
|
||||||
4. **OUTPUT**: Output filename (default `output-{index}.jpeg`)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Step 1: Verify Credentials
|
## API Call Example
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Verify credentials
|
||||||
if [ -z "${MINIMAX_API_KEY:-}" ]; then
|
if [ -z "${MINIMAX_API_KEY:-}" ]; then
|
||||||
echo "ERROR: MINIMAX_API_KEY is not set."
|
echo "ERROR: MINIMAX_API_KEY is not set."
|
||||||
echo "Set it with: export MINIMAX_API_KEY='your-api-key'"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
API_BASE_URL="${MINIMAX_API_BASE_URL:-https://api.minimax.io}"
|
API_BASE_URL="${MINIMAX_API_BASE_URL:-https://api.minimax.io}"
|
||||||
echo "Using API base: $API_BASE_URL"
|
PROMPT="<your prompt here>"
|
||||||
```
|
ASPECT_RATIO="16:9"
|
||||||
|
|
||||||
---
|
# Call the API
|
||||||
|
response=$(curl -s -X POST "${API_BASE_URL}/v1/image_generation" \
|
||||||
## Step 2: Call the MiniMax Image Generation API
|
|
||||||
|
|
||||||
```bash
|
|
||||||
PROMPT="a serene mountain landscape at dawn, cinematic, photorealistic"
|
|
||||||
ASPECT_RATIO="${ASPECT_RATIO:-16:9}"
|
|
||||||
NUM_IMAGES="${NUM_IMAGES:-1}"
|
|
||||||
OUTPUT="${OUTPUT:-}"
|
|
||||||
|
|
||||||
URL="${API_BASE_URL}/v1/image_generation"
|
|
||||||
|
|
||||||
response=$(curl -s -X POST "${URL}" \
|
|
||||||
-H "Authorization: Bearer ${MINIMAX_API_KEY}" \
|
-H "Authorization: Bearer ${MINIMAX_API_KEY}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{
|
-d "{
|
||||||
\"model\": \"image-01\",
|
\"model\": \"image-01\",
|
||||||
\"prompt\": \"${PROMPT}\",
|
\"prompt\": \"${PROMPT}\",
|
||||||
\"aspect_ratio\": \"${ASPECT_RATIO}\",
|
\"aspect_ratio\": \"${ASPECT_RATIO}\",
|
||||||
\"num_images\": ${NUM_IMAGES},
|
|
||||||
\"response_format\": \"base64\"
|
\"response_format\": \"base64\"
|
||||||
}")
|
}")
|
||||||
|
|
||||||
# Check for errors
|
# Decode and save
|
||||||
if echo "$response" | jq -e '.error' >/dev/null 2>&1; then
|
|
||||||
error_msg=$(echo "$response" | jq -r '.error.message // "Unknown error"')
|
|
||||||
echo "ERROR: $error_msg"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Step 3: Decode and Save Images
|
|
||||||
|
|
||||||
```bash
|
|
||||||
images=$(echo "$response" | jq -r '.data.image_base64[]')
|
images=$(echo "$response" | jq -r '.data.image_base64[]')
|
||||||
|
|
||||||
idx=0
|
idx=0
|
||||||
for image_b64 in $images; do
|
for image_b64 in $images; do
|
||||||
if [ -n "${OUTPUT}" ]; then
|
echo "$image_b64" | base64 -d > "output-${idx}.jpeg"
|
||||||
# Single output filename (use index if multiple images)
|
echo "Saved: output-${idx}.jpeg"
|
||||||
if [ "$NUM_IMAGES" -gt 1 ]; then
|
|
||||||
filename="${OUTPUT%.*}-${idx}.${OUTPUT##*.}"
|
|
||||||
else
|
|
||||||
filename="$OUTPUT"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
filename="output-${idx}.jpeg"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$image_b64" | base64 -d > "$filename"
|
|
||||||
echo "Saved: $filename"
|
|
||||||
idx=$((idx + 1))
|
idx=$((idx + 1))
|
||||||
done
|
done
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Replace `<your prompt here>` with the user's image description.**
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Aspect Ratio Guide
|
## Aspect Ratio Guide
|
||||||
@@ -179,7 +128,6 @@ done
|
|||||||
| `model` | string | `image-01` | Model to use |
|
| `model` | string | `image-01` | Model to use |
|
||||||
| `prompt` | string | required | Image description |
|
| `prompt` | string | required | Image description |
|
||||||
| `aspect_ratio` | string | `16:9` | Image aspect ratio |
|
| `aspect_ratio` | string | `16:9` | Image aspect ratio |
|
||||||
| `num_images` | integer | `1` | Number of images (1–4) |
|
|
||||||
| `response_format` | string | `base64` | Output format |
|
| `response_format` | string | `base64` | Output format |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -190,8 +138,7 @@ done
|
|||||||
🎨 MiniMax Image Generation
|
🎨 MiniMax Image Generation
|
||||||
├─ Prompt: "a cat wearing a spacesuit, cinematic photography"
|
├─ Prompt: "a cat wearing a spacesuit, cinematic photography"
|
||||||
├─ Aspect ratio: 16:9
|
├─ Aspect ratio: 16:9
|
||||||
├─ Model: image-01
|
└─ Model: image-01
|
||||||
└─ Generating...
|
|
||||||
|
|
||||||
Saved: output-0.jpeg
|
Saved: output-0.jpeg
|
||||||
Done.
|
Done.
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# generate.sh — Generate images via MiniMax API
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo "ERROR: $1" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
cat <<EOF
|
|
||||||
Usage: $(basename "$0") [options]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-p, --prompt <text> Image description (required)
|
|
||||||
-a, --aspect-ratio <ratio> Aspect ratio: 16:9 (default), 1:1, 9:16, 4:3, 3:4
|
|
||||||
-n, --num-images <n> Number of images (1-4, default 1)
|
|
||||||
-o, --output <filename> Output filename (default: output-{index}.jpeg)
|
|
||||||
-k, --api-key <key> MiniMax API key (or set MINIMAX_API_KEY env var)
|
|
||||||
-u, --base-url <url> API base URL (default: https://api.minimax.io)
|
|
||||||
-h, --help Show this help
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
$(basename "$0") -p "a sunset over the ocean, cinematic"
|
|
||||||
$(basename "$0") -p "a cat" -a 1:1 -n 2 -o mycat.jpeg
|
|
||||||
EOF
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse arguments
|
|
||||||
PROMPT=""
|
|
||||||
ASPECT_RATIO="16:9"
|
|
||||||
NUM_IMAGES=1
|
|
||||||
OUTPUT=""
|
|
||||||
API_KEY="${MINIMAX_API_KEY:-}"
|
|
||||||
BASE_URL="${MINIMAX_API_BASE_URL:-https://api.minimax.io}"
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
-p|--prompt) PROMPT="$2"; shift 2 ;;
|
|
||||||
-a|--aspect-ratio) ASPECT_RATIO="$2"; shift 2 ;;
|
|
||||||
-n|--num-images) NUM_IMAGES="$2"; shift 2 ;;
|
|
||||||
-o|--output) OUTPUT="$2"; shift 2 ;;
|
|
||||||
-k|--api-key) API_KEY="$2"; shift 2 ;;
|
|
||||||
-u|--base-url) BASE_URL="$2"; shift 2 ;;
|
|
||||||
-h|--help) usage ;;
|
|
||||||
*) die "Unknown option: $1" ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Validate required inputs
|
|
||||||
if [ -z "$PROMPT" ]; then
|
|
||||||
die "Prompt is required. Use -p 'description'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$API_KEY" ]; then
|
|
||||||
die "MINIMAX_API_KEY is not set. Pass -k or export MINIMAX_API_KEY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Validate aspect ratio
|
|
||||||
case "$ASPECT_RATIO" in
|
|
||||||
16:9|1:1|9:16|4:3|3:4) ;;
|
|
||||||
*) die "Invalid aspect ratio: $ASPECT_RATIO. Use 16:9, 1:1, 9:16, 4:3, or 3:4" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Validate num_images
|
|
||||||
if ! [[ "$NUM_IMAGES" =~ ^[1-4]$ ]]; then
|
|
||||||
die "num-images must be between 1 and 4"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make the API call
|
|
||||||
URL="${BASE_URL}/v1/image_generation"
|
|
||||||
|
|
||||||
echo "🎨 MiniMax Image Generation"
|
|
||||||
echo "├─ Prompt: $PROMPT"
|
|
||||||
echo "├─ Aspect ratio: $ASPECT_RATIO"
|
|
||||||
echo "├─ Num images: $NUM_IMAGES"
|
|
||||||
echo "└─ Model: image-01"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
response=$(curl -s -X POST "${URL}" \
|
|
||||||
-H "Authorization: Bearer ${API_KEY}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$(jq -n \
|
|
||||||
--arg prompt "$PROMPT" \
|
|
||||||
--arg ratio "$ASPECT_RATIO" \
|
|
||||||
--argjson num "$NUM_IMAGES" \
|
|
||||||
'{
|
|
||||||
model: "image-01",
|
|
||||||
prompt: $prompt,
|
|
||||||
aspect_ratio: $ratio,
|
|
||||||
num_images: $num,
|
|
||||||
response_format: "base64"
|
|
||||||
}')")
|
|
||||||
|
|
||||||
# Check for HTTP errors
|
|
||||||
if echo "$response" | jq -e '.error' >/dev/null 2>&1; then
|
|
||||||
error_msg=$(echo "$response" | jq -r '.error.message // "Unknown error"')
|
|
||||||
die "API error: $error_msg"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Decode and save images
|
|
||||||
images=$(echo "$response" | jq -r '.data.image_base64[]')
|
|
||||||
|
|
||||||
idx=0
|
|
||||||
for image_b64 in $images; do
|
|
||||||
if [ -n "$OUTPUT" ]; then
|
|
||||||
if [ "$NUM_IMAGES" -gt 1 ]; then
|
|
||||||
filename="${OUTPUT%.*}-${idx}.${OUTPUT##*.}"
|
|
||||||
else
|
|
||||||
filename="$OUTPUT"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
filename="output-${idx}.jpeg"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$image_b64" | base64 -d > "$filename"
|
|
||||||
echo "Saved: $filename"
|
|
||||||
idx=$((idx + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Done."
|
|
||||||
Reference in New Issue
Block a user