Cursor Agent Skill
Create a Cursor agent skill that generates anime images with AnimeAPI
What is a Cursor Agent Skill?
Cursor Agent Skills are SKILL.md files that extend the AI agent's capabilities with specialized knowledge and workflows. By creating an AnimeAPI skill, Cursor can generate anime images directly during your coding sessions.
- Skills live in
~/.cursor/skills/or project.cursor/skills/ - Each skill is a folder containing a
SKILL.mdfile - Cursor automatically discovers and suggests skills when relevant
- Skills can include helper scripts and resources
Prerequisites
- Cursor IDE installed
- An AnimeAPI key from your dashboard
Option A: Global Skill (All Projects)
Create a global skill available in all your Cursor projects:
# macOS/Linux
mkdir -p ~/.cursor/skills/animeapi
# Windows (PowerShell)
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.cursor\skills\animeapi"Option B: Project Skill (Single Project)
Create a project-specific skill in your repository:
# From your project root
mkdir -p .cursor/skills/animeapiNote: Add .cursor/skills/ to your .gitignore if you don't want to commit the skill.
Step 2: Create the SKILL.md File
Create SKILL.md in your skill folder with the following content:
# AnimeAPI - Anime Image Generation
Generate high-quality anime images using the AnimeAPI service. Use this skill when users want to create anime-style images, illustrations, character art, or visual assets.
## When to Use
Activate this skill when the user:
- Asks to generate anime images, illustrations, or artwork
- Needs visual assets for a project (game, app, website, documentation)
- Wants to create character designs, concept art, or mockups
- Mentions "anime", "manga", "illustration" with image generation intent
- Needs placeholder images with anime aesthetics
## Environment Setup
The ANIMEAPI_KEY must be available as an environment variable. Guide users to set it:
```bash
# Add to shell profile (~/.bashrc, ~/.zshrc)
export ANIMEAPI_KEY="ank_your_api_key_here"
```
Get an API key at: https://animeapi.ai/dashboard/api-keys
## API Specification
### Endpoint
```
POST https://api.animeapi.com/api/generate
```
### Authentication
```
Authorization: Bearer <ANIMEAPI_KEY>
Content-Type: application/json
```
### Request Parameters
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| prompt | string | Yes | - | Image description (be descriptive!) |
| orientation | string | No | "portrait" | "portrait" (832x1280), "square" (1024x1024), "landscape" (1280x832) |
| allowNSFW | boolean | No | true | Allow mature content |
### Response Format
```json
{
"image_url": "https://cdn.runware.ai/images/...",
"balance_usd": 9.99,
"generation_time_ms": 4200
}
```
### Pricing
- **Cost per image**: $0.009 (less than 1 cent)
- Balance is prepaid at https://animeapi.ai/dashboard/billing
- Balance never expires
## Implementation Instructions
### Step 1: Generate the Image
Execute a curl command or use fetch/requests:
```bash
curl -X POST "https://api.animeapi.com/api/generate" \
-H "Authorization: Bearer $ANIMEAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "anime girl with blue hair in a magical forest, soft lighting, detailed eyes, high quality illustration",
"orientation": "portrait"
}'
```
### Step 2: Download and Save
Download the image from the returned URL:
```bash
curl -o "./public/images/generated-character.webp" "<image_url>"
```
### Step 3: Integrate into Project
- For web projects: Reference the image in HTML/JSX
- For games: Import as asset/sprite
- For documentation: Embed in markdown
## Prompt Engineering Tips
### Enhance User Prompts
Always improve basic prompts with these additions:
1. **Style keywords**: "anime style", "manga art", "high quality illustration"
2. **Lighting**: "soft lighting", "dramatic lighting", "golden hour"
3. **Quality boosters**: "detailed", "masterpiece", "professional"
4. **Specific details**: "detailed eyes", "flowing hair", "intricate outfit"
### Example Transformations
| User Request | Enhanced Prompt |
|--------------|-----------------|
| "a wizard" | "anime wizard with flowing robes and magical staff, glowing purple magic, detailed eyes, dramatic lighting, high quality illustration" |
| "cat girl" | "cute anime cat girl with fluffy ears and tail, pastel colors, soft lighting, detailed, adorable expression, high quality" |
| "battle scene" | "epic anime battle scene, dynamic poses, motion blur, intense lighting, dramatic atmosphere, detailed characters, professional illustration" |
## Orientation Guidelines
Choose orientation based on content:
| Content Type | Recommended | Reason |
|--------------|-------------|--------|
| Character portraits | portrait | Better composition for single characters |
| Full body characters | portrait | More vertical space for pose |
| Landscapes/scenes | landscape | Wider view for environments |
| Icons/avatars | square | Works best for profile pictures |
| UI mockups | square | Flexible for various placements |
## Error Handling
| HTTP Code | Error | Action |
|-----------|-------|--------|
| 401 | Unauthorized | API key invalid - check ANIMEAPI_KEY env var |
| 402 | Payment Required | Insufficient balance - add funds at dashboard |
| 429 | Rate Limited | Wait 60 seconds (10 req/min limit) |
| 500 | Server Error | Retry after a few seconds |
## Rate Limits
- **Per-minute**: 10 requests
- **Per-day**: 5000 requests
- Implement delays between batch generations
## Example Workflows
### Hero Image for Landing Page
1. Generate: "anime hero character, confident pose, dramatic lighting, detailed, professional quality"
2. Orientation: portrait or landscape based on layout
3. Save to: `public/images/hero.webp`
4. Use in Hero component
### Game Character Assets
1. Generate multiple orientations for each character
2. Save with consistent naming: `character-name-pose.webp`
3. Create sprite sheets if needed
### Documentation Illustrations
1. Generate contextual images for docs
2. Use square orientation for flexibility
3. Optimize and compress before committingStep 3: Set Your API Key
Add your API key to your environment. The agent will use this automatically:
# macOS/Linux - add to ~/.bashrc or ~/.zshrc
export ANIMEAPI_KEY="ank_your_api_key_here"
# Windows - add to PowerShell $PROFILE
$env:ANIMEAPI_KEY = "ank_your_api_key_here"
# Or create a .env file in your project root
ANIMEAPI_KEY=ank_your_api_key_hereStep 4: Use the Skill
Now you can ask Cursor to generate images naturally:
# Example prompts to try:
> Generate an anime hero image for my landing page and save it to public/images/
> Create a character portrait: silver-haired elf mage with mystical powers
> I need anime-style backgrounds for my game - generate a fantasy castle scene
> Make me a set of anime character avatars for the team pageCursor will automatically read the skill, generate images via the API, and save them to your project.
Complete Skill Package
For convenience, here's a complete skill package with helper scripts. Create these files in your skill folder:
generate.ts (TypeScript helper)
// AnimeAPI TypeScript Helper
// Usage: npx ts-node generate.ts "prompt" [orientation] [output]
const ANIMEAPI_KEY = process.env.ANIMEAPI_KEY;
interface GenerateOptions {
prompt: string;
orientation?: "portrait" | "square" | "landscape";
allowNSFW?: boolean;
}
interface GenerateResponse {
image_url: string;
balance_usd: number;
generation_time_ms: number;
}
export async function generateAnimeImage(
options: GenerateOptions
): Promise<GenerateResponse> {
if (!ANIMEAPI_KEY) {
throw new Error("ANIMEAPI_KEY environment variable not set");
}
const response = await fetch("https://api.animeapi.com/api/generate", {
method: "POST",
headers: {
Authorization: `Bearer ${ANIMEAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: options.prompt,
orientation: options.orientation ?? "portrait",
allowNSFW: options.allowNSFW ?? true,
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.message || "Generation failed");
}
return response.json();
}
export async function generateAndSave(
prompt: string,
outputPath: string,
orientation: "portrait" | "square" | "landscape" = "portrait"
): Promise<string> {
const result = await generateAnimeImage({ prompt, orientation });
const imageResponse = await fetch(result.image_url);
const buffer = await imageResponse.arrayBuffer();
const fs = await import("fs/promises");
await fs.writeFile(outputPath, Buffer.from(buffer));
console.log(`Saved to: ${outputPath}`);
console.log(`Balance: $${result.balance_usd.toFixed(2)}`);
console.log(`Generation time: ${result.generation_time_ms}ms`);
return outputPath;
}
// CLI usage
if (require.main === module) {
const [prompt, orientation, output] = process.argv.slice(2);
if (!prompt) {
console.log('Usage: npx ts-node generate.ts "prompt" [orientation] [output]');
process.exit(1);
}
generateAndSave(
prompt,
output || "anime-output.webp",
(orientation as "portrait" | "square" | "landscape") || "portrait"
).catch(console.error);
}generate.py (Python helper)
#!/usr/bin/env python3
"""AnimeAPI Python Helper
Usage: python generate.py "prompt" [orientation] [output]
"""
import os
import sys
import requests
ANIMEAPI_KEY = os.environ.get("ANIMEAPI_KEY")
API_URL = "https://api.animeapi.com/api/generate"
def generate_anime_image(
prompt: str,
orientation: str = "portrait",
allow_nsfw: bool = True
) -> dict:
"""Generate an anime image from a prompt."""
if not ANIMEAPI_KEY:
raise ValueError("ANIMEAPI_KEY environment variable not set")
response = requests.post(
API_URL,
headers={
"Authorization": f"Bearer {ANIMEAPI_KEY}",
"Content-Type": "application/json",
},
json={
"prompt": prompt,
"orientation": orientation,
"allowNSFW": allow_nsfw,
},
)
if not response.ok:
error = response.json()
raise Exception(error.get("message", "Generation failed"))
return response.json()
def generate_and_save(
prompt: str,
output_path: str = "anime-output.webp",
orientation: str = "portrait"
) -> str:
"""Generate an image and save it to a file."""
result = generate_anime_image(prompt, orientation)
image_response = requests.get(result["image_url"])
with open(output_path, "wb") as f:
f.write(image_response.content)
print(f"Saved to: {output_path}")
print(f"Balance: ${result['balance_usd']:.2f}")
print(f"Generation time: {result['generation_time_ms']}ms")
return output_path
if __name__ == "__main__":
if len(sys.argv) < 2:
print('Usage: python generate.py "prompt" [orientation] [output]')
sys.exit(1)
prompt = sys.argv[1]
orientation = sys.argv[2] if len(sys.argv) > 2 else "portrait"
output = sys.argv[3] if len(sys.argv) > 3 else "anime-output.webp"
generate_and_save(prompt, output, orientation)Tips
- The agent will automatically enhance basic prompts for better results
- Project skills override global skills of the same name
- Skills are read fresh each session - changes take effect immediately
- Each generation costs less than 1 cent - iterate freely
- Images are generated as WebP for optimal quality and file size
- Combine with other skills for complex creative workflows
Ready to supercharge Cursor?
Get your API key and start generating anime images with Cursor AI.