commit 7138dbd1bf95e2b4ab43a627fe9cf9b3546972f6 Author: Zhongwei Li Date: Sun Nov 30 08:50:54 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..253c731 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "replicate-cli", + "description": "Interacts with the Replicate CLI.", + "version": "0.0.0-2025.11.28", + "author": { + "name": "Tim Green", + "email": "rawveg@gmail.com" + }, + "skills": [ + "./skills/replicate-cli" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e427d73 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# replicate-cli + +Interacts with the Replicate CLI. diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..1eaca52 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,52 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:rawveg/skillsforge-marketplace:replicate-cli", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "7e4f3c3f94a0cdc6045215613b83c31585701ac5", + "treeHash": "c613654a1ef065c373bbbdd5344e5dbee8c9b8c2781e567854b296fa5fb329fe", + "generatedAt": "2025-11-28T10:27:53.611308Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "replicate-cli", + "description": "Interacts with the Replicate CLI." + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "a2e403e2e439cafbe51b115e38b6a9cbab89d7d1fb18fa2ef2c96e4ed851f576" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "afc47a36a8e2f54812260f206477148fc4bb326546165d0579065b235358c757" + }, + { + "path": "skills/replicate-cli/plugin.json", + "sha256": "09d52e66be8d509e9abe1a24705ab735ce13bbe9f7fef571568105e788c342c2" + }, + { + "path": "skills/replicate-cli/SKILL.md", + "sha256": "9010d38fb34d4d967f290a1dc9f49c41b654d79270b0b9779467d919dd947af1" + }, + { + "path": "skills/replicate-cli/references/hardware.md", + "sha256": "2121e4295189c4346ae73b4fa97086fe4464bba933fc29e3ac92d83b825ab51a" + } + ], + "dirSha256": "c613654a1ef065c373bbbdd5344e5dbee8c9b8c2781e567854b296fa5fb329fe" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/replicate-cli/SKILL.md b/skills/replicate-cli/SKILL.md new file mode 100644 index 0000000..f3d87ad --- /dev/null +++ b/skills/replicate-cli/SKILL.md @@ -0,0 +1,293 @@ +--- +name: replicate-cli +description: This skill provides comprehensive guidance for using the Replicate CLI to run AI models, create predictions, manage deployments, and fine-tune models. Use this skill when the user wants to interact with Replicate's AI model platform via command line, including running image generation models, language models, or any ML model hosted on Replicate. This skill should be used when users ask about running models on Replicate, creating predictions, managing deployments, fine-tuning models, or working with the Replicate API through the CLI. +--- + +# Replicate CLI + +The Replicate CLI is a command-line tool for interacting with Replicate's AI model platform. It enables running predictions, managing models, creating deployments, and fine-tuning models directly from the terminal. + +## Authentication + +Before using the Replicate CLI, set the API token: + +```bash +export REPLICATE_API_TOKEN= +``` + +Alternatively, authenticate interactively: + +```bash +replicate auth login +``` + +Verify authentication: + +```bash +replicate account current +``` + +## Core Commands + +### Running Predictions + +The primary use case is running predictions against hosted models. + +**Basic prediction:** +```bash +replicate run input_key=value +``` + +**Examples:** + +Image generation: +```bash +replicate run stability-ai/sdxl prompt="a studio photo of a rainbow colored corgi" +``` + +Text generation with streaming: +```bash +replicate run meta/llama-2-70b-chat --stream prompt="Tell me a joke" +``` + +**Prediction flags:** +- `--stream` - Stream output tokens in real-time (for text models) +- `--no-wait` - Submit prediction without waiting for completion +- `--web` - Open prediction in browser +- `--json` - Output result as JSON +- `--save` - Save outputs to local directory +- `--output-directory ` - Specify output directory (default: `./{prediction-id}`) + +### Input Handling + +**File uploads:** Prefix local file paths with `@`: +```bash +replicate run nightmareai/real-esrgan image=@photo.jpg +``` + +**Output chaining:** Use `{{.output}}` template syntax to chain predictions: +```bash +replicate run stability-ai/sdxl prompt="a corgi" | \ +replicate run nightmareai/real-esrgan image={{.output[0]}} +``` + +### Model Operations + +**View model schema** (see required inputs and outputs): +```bash +replicate model schema +replicate model schema stability-ai/sdxl --json +``` + +**List models:** +```bash +replicate model list +replicate model list --json +``` + +**Show model details:** +```bash +replicate model show +``` + +**Create a new model:** +```bash +replicate model create \ + --hardware gpu-a100-large \ + --private \ + --description "Model description" +``` + +Model creation flags: +- `--hardware ` - Hardware SKU (see `references/hardware.md`) +- `--private` / `--public` - Visibility setting +- `--description ` - Model description +- `--github-url ` - Link to source repository +- `--license-url ` - License information +- `--cover-image-url ` - Cover image for model page + +### Training (Fine-tuning) + +Fine-tune models using the training command: + +```bash +replicate train \ + --destination \ + input_key=value +``` + +**Example - Fine-tune SDXL with DreamBooth:** +```bash +replicate train stability-ai/sdxl \ + --destination myuser/custom-sdxl \ + --web \ + input_images=@training-images.zip \ + use_face_detection_instead=true +``` + +**List trainings:** +```bash +replicate training list +``` + +**Show training details:** +```bash +replicate training show +``` + +### Deployments + +Deployments provide dedicated, always-on inference endpoints with predictable performance. + +**Create deployment:** +```bash +replicate deployments create \ + --model \ + --hardware \ + --min-instances 1 \ + --max-instances 3 +``` + +**Example:** +```bash +replicate deployments create text-to-image \ + --model stability-ai/sdxl \ + --hardware gpu-a100-large \ + --min-instances 1 \ + --max-instances 5 +``` + +**Update deployment:** +```bash +replicate deployments update \ + --max-instances 10 \ + --version +``` + +**List deployments:** +```bash +replicate deployments list +``` + +**Show deployment details and schema:** +```bash +replicate deployments show +replicate deployments schema +``` + +### Hardware + +List available hardware options: +```bash +replicate hardware list +``` + +See `references/hardware.md` for detailed hardware information and selection guidelines. + +### Scaffolding + +Create a local development environment from an existing prediction: + +```bash +replicate scaffold --template= +``` + +This generates a project with the prediction's model and inputs pre-configured. + +## Command Aliases + +For convenience, these aliases are available: + +| Alias | Equivalent Command | +|-------|-------------------| +| `replicate run` | `replicate prediction create` | +| `replicate stream` | `replicate prediction create --stream` | +| `replicate train` | `replicate training create` | + +Short aliases for subcommands: +- `replicate m` = `replicate model` +- `replicate p` = `replicate prediction` +- `replicate t` = `replicate training` +- `replicate d` = `replicate deployments` +- `replicate hw` = `replicate hardware` +- `replicate a` = `replicate account` + +## Common Workflows + +### Image Generation Pipeline + +Generate an image and upscale it: +```bash +replicate run stability-ai/sdxl \ + prompt="professional photo of a sunset" \ + negative_prompt="blurry, low quality" | \ +replicate run nightmareai/real-esrgan \ + image={{.output[0]}} \ + --save +``` + +### Check Model Inputs Before Running + +Always check the model schema to understand required inputs: +```bash +replicate model schema owner/model-name +``` + +### Batch Processing + +Run predictions and save outputs: +```bash +for prompt in "cat" "dog" "bird"; do + replicate run stability-ai/sdxl prompt="$prompt" --save --output-directory "./outputs/$prompt" +done +``` + +### Monitor Long-Running Tasks + +Submit without waiting, then check status: +```bash +# Submit +replicate run owner/model input=value --no-wait --json > prediction.json + +# Check status later +replicate prediction show $(jq -r '.id' prediction.json) +``` + +## Best Practices + +1. **Always check schema first** - Run `replicate model schema ` to understand required and optional inputs before running predictions. + +2. **Use streaming for text models** - Add `--stream` flag when running language models to see output in real-time. + +3. **Save outputs explicitly** - Use `--save` and `--output-directory` to organize prediction outputs. + +4. **Use JSON output for automation** - Add `--json` flag when parsing outputs programmatically. + +5. **Open in web for debugging** - Add `--web` flag to view predictions in the Replicate dashboard for detailed logs. + +6. **Chain predictions efficiently** - Use the `{{.output}}` syntax to pass outputs between models without intermediate saves. + +## Troubleshooting + +**Authentication errors:** +- Verify `REPLICATE_API_TOKEN` is set correctly +- Run `replicate account current` to test authentication + +**Model not found:** +- Check model name format: `owner/model-name` +- Verify model exists at replicate.com + +**Input validation errors:** +- Run `replicate model schema ` to see required inputs +- Check input types (string, number, file) + +**File upload issues:** +- Ensure `@` prefix is used for local files +- Verify file path is correct and file exists + +## Additional Resources + +- Replicate documentation: https://replicate.com/docs +- Model explorer: https://replicate.com/explore +- API reference: https://replicate.com/docs/reference/http +- GitHub repository: https://github.com/replicate/cli diff --git a/skills/replicate-cli/plugin.json b/skills/replicate-cli/plugin.json new file mode 100644 index 0000000..988e223 --- /dev/null +++ b/skills/replicate-cli/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "replicate-cli", + "description": "This skill provides comprehensive guidance for using the Replicate CLI to run AI models, create predictions, manage deployments, and fine-tune models. Use this skill when the user wants to interact with Replicate's AI model platform via command line, including running image generation models, language models, or any ML model hosted on Replicate. This skill should be used when users ask about running models on Replicate, creating predictions, managing deployments, fine-tuning models, or working with the Replicate API through the CLI.", + "version": "1.0.0", + "author": { + "name": "Tim Green", + "email": "rawveg@gmail.com" + }, + "homepage": "https://github.com/rawveg/claude-skills-marketplace", + "repository": "https://github.com/rawveg/claude-skills-marketplace", + "license": "MIT", + "keywords": ["skills", "reusable", "components", "Replicate CLI", "Replicate API", "Claude Code"], + "category": "productivity", + "strict": false +} diff --git a/skills/replicate-cli/references/hardware.md b/skills/replicate-cli/references/hardware.md new file mode 100644 index 0000000..bf23d99 --- /dev/null +++ b/skills/replicate-cli/references/hardware.md @@ -0,0 +1,25 @@ +# Replicate Hardware Options + +Available hardware SKUs for model creation and deployments: + +| SKU | Name | Use Case | +|-----|------|----------| +| `cpu` | CPU | Lightweight models, text processing | +| `gpu-t4` | Nvidia T4 GPU | Cost-effective inference, smaller models | +| `gpu-l40s` | Nvidia L40S GPU | Balanced performance and cost | +| `gpu-l40s-2x` | 2x Nvidia L40S GPU | Larger models requiring more VRAM | +| `gpu-a100-large` | Nvidia A100 (80GB) GPU | High-performance inference, large models | +| `gpu-a100-large-2x` | 2x Nvidia A100 (80GB) GPU | Very large models, maximum VRAM | +| `gpu-h100` | Nvidia H100 GPU | Latest generation, highest performance | + +## Hardware Selection Guidelines + +- **Image generation models (SDXL, Flux)**: `gpu-a100-large` or `gpu-l40s` +- **Large language models**: `gpu-a100-large` or higher +- **Smaller inference tasks**: `gpu-t4` for cost efficiency +- **Fine-tuning/training**: `gpu-a100-large` or `gpu-h100` recommended + +To list current hardware options: +```bash +replicate hardware list +```