---
name: image-generation
description: Generate images using MiniMax API with support for custom prompts, aspect ratios, subject references, and multiple image generation.
metadata: {"clawdbot":{"emoji":"🎨","os":["linux","darwin","win32"]}}
---

# MiniMax Image Generation SKILL

## Description

Generate images using MiniMax API. Supports custom prompts, aspect ratios, generation count, and image-to-image generation.

## Quick Start (MCP Server)

### Setup

1. Set the environment variable:
   ```bash
   export MINIMAX_API_KEY=your-api-key
   ```

2. Add to your MCP client config (e.g., Claude Desktop, Cursor, etc.):
   
   ```json
   {
     "mcpServers": {
       "minimax-image": {
         "command": "python",
         "args": ["path/to/minimax_image_mcp.py"]
       }
     }
   }
   ```

3. Use the `generate_image` tool:
   
   ```
   generate_image({
     prompt: "A beautiful mountain landscape at sunset",
     aspect_ratio: "16:9"
   })
   ```

## MCP Tool: generate_image

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `prompt` | string | true | - | Image generation prompt |
| `model` | string | false | `image-01` | Image generation model |
| `aspect_ratio` | string | false | `1:1` | Image aspect ratio |
| `n` | integer | false | `1` | Number of images (1-3) |
| `prompt_optimizer` | boolean | false | `false` | Enable prompt optimizer |
| `subject_reference` | string | false | - | Reference image URL or local file path |
| `subject_type` | string | false | `character` | Subject type (character, product, logo, video_subject, other) |
| `seed` | integer | false | - | Random seed for reproducible generation |
| `output_path` | string | false | - | Local path to save image |

### Aspect Ratio Options

| Ratio | Description |
|-------|-------------|
| `1:1` | Square (default) |
| `16:9` | Landscape |
| `9:16` | Portrait |
| `4:3` | Standard landscape |
| `3:4` | Standard portrait |

### Example Usage

```javascript
// Text-to-Image (t2i) - Pure text generation
{
  "prompt": "A man in a white t-shirt, full-body, standing front view, outdoors, fashion photography"
}

// Multiple images with custom aspect ratio
{
  "prompt": "A realistic portrait",
  "aspect_ratio": "16:9",
  "n": 3
}

// With subject reference (image-to-image)
{
  "prompt": "Transform to anime style",
  "subject_reference": "https://example.com/photo.jpg",
  "subject_type": "character"
}

// With seed for reproducibility
{
  "prompt": "A forest",
  "seed": 12345
}

// Save to local path
{
  "prompt": "A sunset over the ocean",
  "output_path": "./output/sunset"
}
```

## CLI Usage

```bash
python scripts/run.py --api-key "your-api-key" --prompt "your-prompt" [options]
```

### CLI Arguments

| Argument | Type | Required | Description |
|----------|------|----------|-------------|
| `--api-key` | string | true | MiniMax API key |
| `--prompt` | string | true | Generation prompt |
| `--model` | string | false | Image generation model (default: image-01) |
| `--aspect-ratio` | string | false | Image aspect ratio (default: 1:1) |
| `--response-format` | string | false | Response format (`url` or `base64`) |
| `--n` | integer | false | Number of images (default: 1, max: 3) |
| `--prompt-optimizer` | boolean | false | Enable prompt optimizer (default: false) |
| `--subject-reference` | string | false | Reference image URL or local file path |
| `--subject-type` | string | false | Subject type (default: character) |
| `--seed` | integer | false | Random seed for reproducible generation |
| `--output-dir` | string | false | Output directory (default: ./output) |

## API Reference

- **Endpoint**: `POST https://api.minimaxi.com/v1/image_generation`
- **Auth**: Bearer Token
- **Env Var**: `MINIMAX_API_KEY`

## Examples

### MCP Server Examples

```
generate_image({ prompt: "A sunset over the ocean" })

generate_image({ 
  prompt: "A realistic portrait",
  aspect_ratio: "16:9",
  n: 3
})

generate_image({
  prompt: "Transform into anime style",
  subject_reference: "https://example.com/photo.jpg",
  subject_type: "character"
})

generate_image({
  prompt: "A forest",
  seed: 12345
})
```

### CLI Examples

```bash
# Text-to-Image (t2i) - Pure text generation
python scripts/run.py --api-key "sk-xxx" --prompt "A man in a white t-shirt, full-body, fashion photography in 90s documentary style"

# Multiple images with custom aspect ratio
python scripts/run.py --api-key "sk-xxx" --prompt "A portrait" --aspect-ratio "16:9" --n 3

# With subject reference (image-to-image)
python scripts/run.py --api-key "sk-xxx" --prompt "Transform to anime style" --subject-reference "https://example.com/photo.jpg" --subject-type "character"

# With local subject reference
python scripts/run.py --api-key "sk-xxx" --prompt "A beautiful scene" --subject-reference "./my_character.jpg" --subject-type "character"

# With seed for reproducibility
python scripts/run.py --api-key "sk-xxx" --prompt "A forest" --seed 42

# With custom output directory
python scripts/run.py --api-key "sk-xxx" --prompt "A mountain" --output-dir "./my-images"
```
