Skill: lilei0311/siliconflow-image-gen (version 1.0.0)

--- name: siliconflow-image-gen description: Generate images using SiliconFlow API (FLUX.1, Stable Diffusion, etc.) env: - SILICONFLOW_API_KEY files: config: - ~/.openclaw/openclaw.json --- # SiliconFlow Image Generation Skill Generate images using SiliconFlow API with support for FLUX.1, Stable Diffusion, and more. ## Features - 🎨 **Multiple Models**: FLUX.1-schnell (free), FLUX.1-dev, Stable Diffusion 3.5 - 🔑 **Auto API Key Detection**: Reads from environment or OpenClaw config - 💾 **Auto Download**: Saves generated images locally - 📱 **OpenClaw Ready**: Designed for OpenClaw Agent integration ## Requirements - **Environment Variable**: `SILICONFLOW_API_KEY` - **Optional Config File**: `~/.openclaw/openclaw.json` (for auto-detect) ## Installation ```bash npx clawhub install siliconflow-image-gen ``` ## Configuration Set your SiliconFlow API key: ```bash export SILICONFLOW_API_KEY="your-api-key" ``` Or configure in OpenClaw: ```json { "models": { "providers": { "siliconflow": { "apiKey": "your-api-key" } } } } ``` ## Usage ### Command Line ```bash # Generate with default model (FLUX.1-schnell) python3 scripts/generate.py "A cup of coffee on wooden table" # Specify model python3 scripts/generate.py "Sunset over mountains" --model "black-forest-labs/FLUX.1-dev" # Save to file python3 scripts/generate.py "Cute cat" --output ~/Desktop/cat.png ``` ## Available Models | Model | Cost | Quality | Speed | |-------|------|---------|-------| | `black-forest-labs/FLUX.1-schnell` | Free | Good | Fast | | `black-forest-labs/FLUX.1-dev` | Paid | Excellent | Medium | | [REDACTED_SECRET] | Paid | Excellent | Medium | ## Security Notes - This skill requires an API key to call SiliconFlow services - The script reads `~/.openclaw/openclaw.json` only to auto-detect API keys - No sensitive data is transmitted except to `api.siliconflow.cn` - Review the code at `scripts/generate.py` before providing credentials ## Author MaxStorm Team ## License MIT

path: README.md
content: # SiliconFlow Image Generation Skill

Generate images using SiliconFlow API with support for FLUX.1, Stable Diffusion, and more.

## Features

- 🎨 **Multiple Models**: FLUX.1-schnell (free), FLUX.1-dev, Stable Diffusion 3.5
- 🔑 **Auto API Key Detection**: Reads from environment or OpenClaw config
- 💾 **Auto Download**: Saves generated images locally
- 📱 **OpenClaw Ready**: Designed for OpenClaw Agent integration

## Installation

```bash
# Via ClawHub
npx clawhub install siliconflow-image-gen

# Or manual
clone to ~/.openclaw/workspace/skills/siliconflow-image-gen
```

## Configuration

Set your SiliconFlow API key:

```bash
export SILICONFLOW_API_KEY="your-api-key"
```

Or the skill will auto-detect from `~/.openclaw/openclaw.json`

## Usage

### Command Line

```bash
# Generate with default model (FLUX.1-schnell)
python3 scripts/generate.py "A cup of coffee on wooden table"

# Specify model
python3 scripts/generate.py "Sunset over mountains" --model "black-forest-labs/FLUX.1-dev"

# Save to file
python3 scripts/generate.py "Cute cat" --output ~/Desktop/cat.png
```

### OpenClaw Agent

```
生成图片：一杯咖啡放在木质桌面上，温暖舒适的咖啡馆氛围
```

## Available Models

| Model | Cost | Quality | Speed |
|-------|------|---------|-------|
| `black-forest-labs/FLUX.1-schnell` | Free | Good | Fast |
| `black-forest-labs/FLUX.1-dev` | Paid | Excellent | Medium |
| [REDACTED_SECRET] | Paid | Excellent | Medium |

## Author

MaxStorm Team

## License

MIT


path: skill.json
content: {
  "name": "siliconflow-image-gen",
  "version": "1.0.0",
  "description": "Generate images using SiliconFlow API (FLUX.1, Stable Diffusion, etc.)",
  "author": "MaxStorm Team",
  "license": "MIT",
  "homepage": "https://github.com/maxstorm/siliconflow-image-gen",
  "keywords": ["image", "generation", "siliconflow", "flux", "stable-diffusion", "ai"],
  "trigger": {
    "patterns": [
      "生成图片",
      "生成图像",
      "文生图",
      "画一张",
      "create image",
      "generate image",
      "text to image"
    ]
  },
  "tools": ["exec"],
  "env": {
    "SILICONFLOW_API_KEY": {
      "description": "SiliconFlow API Key for image generation",
      "required": true
    }
  },
  "config": {
    "apiKey": {
      "description": "SiliconFlow API Key",
      "required": true,
      "env": "SILICONFLOW_API_KEY"
    },
    "defaultModel": {
      "description": "Default image generation model",
      "default": "black-forest-labs/FLUX.1-schnell"
    }
  },
  "files": {
    "config": ["~/.openclaw/openclaw.json"]
  },
  "models": [
    {
      "id": "black-forest-labs/FLUX.1-schnell",
      "name": "FLUX.1 Schnell",
      "description": "Fast and free image generation (recommended)"
    },
    {
      "id": "black-forest-labs/FLUX.1-dev",
      "name": "FLUX.1 Dev",
      "description": "High quality image generation"
    },
    {
      "id": "stabilityai/stable-diffusion-3-5-large",
      "name": "Stable Diffusion 3.5",
      "description": "Stable Diffusion latest version"
    }
  ]
}


path: scripts/generate.py
content: #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
SiliconFlow Image Generation Script
Compatible with OpenClaw Agent Skills
"""

import os
import sys
import json
import argparse
import subprocess

# API Configuration
API_BASE_URL = "https://api.siliconflow.cn/v1"
DEFAULT_MODEL = "black-forest-labs/FLUX.1-schnell"
DEFAULT_SIZE = "1024x1024"

def get_api_key():
    """Get API key from environment or OpenClaw config"""
    # Try environment first
    [REDACTED_SECRET]"SILICONFLOW_API_KEY")
    if [REDACTED_SECRET] api_key
    
    # Try OpenClaw config
    try:
        config_path = os.path.expanduser("~/.openclaw/openclaw.json")
        with open(config_path, 'r', encoding='utf-8') as f:
            config = json.load(f)
        providers = config.get("models", {}).get("providers", {})
        siliconflow = providers.get("siliconflow", {})
        [REDACTED_SECRET]"apiKey")
        if api_key and api_key != "ollama":  # Skip placeholder
            return api_key
    except Exception:
        pass
    
    return None

def generate_image(prompt, model=None, size=None, output_path=None):
    """Generate image using SiliconFlow API via curl"""
    [REDACTED_SECRET])
    if not [REDACTED_SECRET]
            "success": False,
            "error": "SILICONFLOW_API_KEY not found. Please set SILICONFLOW_API_KEY environment variable."
        }))
        sys.exit(1)
    
    model = model or DEFAULT_MODEL
    size = size or DEFAULT_SIZE
    
    # Prepare request data
    data = {
        "model": model,
        "prompt": prompt,
        "size": size
    }
    
    # Use curl to avoid Python encoding issues
    curl_cmd = [
        "curl", "-s", "-X", "POST",
        f"{API_BASE_URL}/images/generations",
        "-H", f"Authorization: Bearer {api_key}",
        "-H", "Content-Type: application/json",
        "-d", json.dumps(data),
        "--max-time", "120"
    ]
    
    try:
        # Make API request
        result = subprocess.run(curl_cmd, capture_output=True, text=True)
        if result.returncode != 0:
            print(json.dumps({
                "success": False,
                "error": f"API request failed: {result.stderr}"
            }))
            sys.exit(1)
        
        response = json.loads(result.stdout)
        
        # Extract image URL
        image_url = response.get("data", [{}])[0].get("url")
        if not image_url:
            print(json.dumps({
                "success": False,
                "error": "No image URL in response",
                "response": response
            }))
            sys.exit(1)
        
        # Download image if output path specified
        if output_path:
            download_cmd = ["curl", "-s", "-L", "--max-time", "60", "-o", output_path, image_url]
            download_result = subprocess.run(download_cmd, capture_output=True)
            if download_result.returncode != 0:
                print(json.dumps({
                    "success": False,
                    "error": "Failed to download image"
                }))
                sys.exit(1)
        
        # Output result as JSON
        output = {
            "success": True,
            "prompt": prompt,
            "model": model,
            "image_url": image_url,
            "local_path": output_path if output_path else None
        }
        print(json.dumps(output, indent=2, ensure_ascii=False))
        
    except Exception as e:
        print(json.dumps({
            "success": False,
            "error": str(e)
        }))
        sys.exit(1)

def main():
    parser = argparse.ArgumentParser(description="Generate images using SiliconFlow API")
    parser.add_argument("prompt", help="Image generation prompt")
    parser.add_argument("--model", "-m", help="Model to use", default=DEFAULT_MODEL)
    parser.add_argument("--size", "-s", help="Image size (e.g., 1024x1024)", default=DEFAULT_SIZE)
    parser.add_argument("--output", "-o", help="Output file path")
    
    args = parser.parse_args()
    generate_image(args.prompt, args.model, args.size, args.output)

if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)