tensorslab-image
npx skills add https://github.com/bob5-tensorslab/skills --skill tensorslab-image
Agent 安装分布
Skill 文档
TensorsLab Image Generation
Overview
This skill enables AI-powered image generation through TensorsLab’s API, supporting both text-to-image and image-to-image workflows. The agent enhances user prompts with detailed visual descriptions before calling the API, ensuring high-quality outputs.
Authentication Check
Before any image generation, verify the API key is configured:
# Check if API key is set
echo $TENSORSLAB_API_KEY
If not set, display this friendly message:
æ¨å¥½ï¼è¦çæé«è´¨éçå
å®¹ï¼æ¨éè¦å
è¿è¡ç®åçé
ç½®ï¼
1. è®¿é® https://test.tensorai.tensorslab.com/ ç»å½å¹¶è®¢é
ã
2. 卿§å¶å°ä¸è·åæ¨çä¸å± API Keyã
3. å°å
¶ä¿å为ç¯å¢åéï¼
- Windows (PowerShell): $env:TENSORSLAB_API_KEY="æ¨çKey"
- Mac/Linux: export TENSORSLAB_API_KEY="æ¨çKey"
Models
| Model | Description | Best For |
|---|---|---|
| seedreamv45 | Latest enhanced model | General purpose, highest quality |
| seedreamv4 | Standard model | Fast generation, good quality |
| zimage | Alternative model | Specific artistic styles |
Default: seedreamv4
Workflow
For additional scenarios beyond basic generation (avatar generation, watermark removal, object erasure, face replacement), see references/scenarios.md.
1. Text-to-Image Generation
User request: “ç»ä¸ä¸ªå¨æçä¸åçççå®èªå”
Agent processing:
- Extract the core subject and action
- Enhance prompt with details (lighting, composition, style, atmosphere)
- Call API with enriched prompt
- Monitor progress with heartbeat updates
- Download to
./tensorslab_output/
Example enhanced prompt:
An astronaut sitting on the lunar surface, eating a hot dog with mustard,
cinematic lighting, Earth visible in the background, highly detailed,
photorealistic, 8k quality, dramatic shadows from the low sun angle
2. Image-to-Image Generation
User request: “æ cat.png çèæ¯æ¢æå¤ªç©º” or “åè sketch.png æ¸²ææ 3D 模å”
Agent processing:
- Extract image file paths (absolute or relative to current directory)
- Enhance prompt with transformation instructions
- Upload source images with prompt
- Monitor and download results
Parameters for image-to-image:
sourceImage: Array of image files (for local upload)imageUrl: URL of source imageprompt: Description of desired transformation
3. Image Editing (General Purpose)
General-purpose editing for any local image modifications.
User request examples:
- “æè¿å¼ å¾çå¤©ç©ºæ¹ææ¥è½è²”
- “ç»äººç©å ä¸å¢¨é”
- “æå¤´åé¢è²ææç²è²”
Agent processing:
- Extract image file path
- Parse the specific editing instruction (what to change, where)
- Build enhanced prompt with precise editing guidance
- Call API with source image and editing prompt
- Save result to
./tensorslab_output/
Example enhanced prompt:
Change the sky to sunset colors with warm orange and pink gradients,
matching the existing lighting conditions and atmospheric perspective,
seamless blend at the horizon line
For avatar generation, watermark removal, object erasure, and face replacement scenarios, see references/scenarios.md.
4. Resolution Options
Supported formats:
- Aspect ratios:
9:16,16:9,3:4,4:3,1:1,2:3,3:2 - Resolution levels:
2K,4K - Specific dimensions:
WxHformat (e.g.,2048x2048,1920x1080)- Constraint: Total pixels must be between 3,686,400 and 16,777,216
Using the Script
Execute the Python script directly:
# Text-to-image
python scripts/tensorslab_image.py "a cat on the moon"
# With specific resolution
python scripts/tensorslab_image.py "sunset over mountains" --resolution 16:9
# Image-to-image
python scripts/tensorslab_image.py "watercolor style" --source cat.png
# Specify model
python scripts/tensorslab_image.py "cyberpunk city" --model seedreamv45
Task Status Flow
| Status | Code | Meaning |
|---|---|---|
| Queued | 1 | Task waiting in queue |
| Processing | 2 | Currently generating |
| Completed | 3 | Done, images ready |
| Failed | 4 | Error occurred |
Error Handling
Translate API errors to user-friendly messages:
| Error Code | Meaning | User Message |
|---|---|---|
| 9000 | Insufficient credits | “亲ï¼ç§¯åç¨å®å¦ï¼è¯·åå¾ https://test.tensorai.tensorslab.com”/ å å¼” |
| 9999 | General error | Show the specific error message |
Output
All images are saved to ./tensorslab_output/ with naming pattern:
{task_id}_{index}.{ext}– e.g.,abcd_1234567890_0.png
After completion, inform user:
ð æ¨çå¾çå¤ç宿¯ï¼å·²åæ¾äº ./tensorslab_output/{filename}
Resources
- scripts/tensorslab_image.py: Main API client with full CLI support
- references/api_reference.md: Detailed API documentation
- references/scenarios.md: Advanced usage scenarios (avatar generation, watermark removal, object erasure, face replacement)