Generate images using AI APIs (Google Gemini and OpenAI GPT). This skill teaches the prompting patterns and API mechanics for producing professional images directly from Claude Code.
Confirm successful installation by checking the skill directory location:
.cursor/skills/ai-image-generator
Restart Cursor to activate ai-image-generator. Access via /ai-image-generator in your agent's command palette.
โ
Security Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Generate images using AI APIs (Google Gemini and OpenAI GPT). This skill teaches the prompting patterns and API mechanics for producing professional images directly from Claude Code.
Managed alternative: If you don't want to manage API keys, ImageBot provides a managed image generation service with album templates and brand kit support.
Verify model IDs before use โ they change frequently:
curl-s"https://generativelanguage.googleapis.com/v1beta/models?key=$GEMINI_API_KEY"| python3 -c"import sys,json; [print(m['name']) for m in json.load(sys.stdin)['models'] if 'image' in m['name'].lower()]"
The 5-Part Prompting Framework
Build prompts in this order for consistent results:
1. Image Type
Set the genre: "A photorealistic photograph", "An isometric illustration", "A flat vector icon"
2. Subject
Who or what, with specific details: "of a warm, approachable Australian woman in her early 30s, smiling naturally"
3. Environment
Setting and spatial relationships: "in a bright modern home with terracotta decor on wooden shelves behind her"
4. Technical Specs
Camera and lighting: "Shot at 85mm f/2.0, natural window light, head and shoulders framing"
5. Constraints
What to exclude: "Photorealistic, no text, no watermarks, no logos"
Example (Good vs Bad)
BAD โ keyword soup:
"professional woman, spa, warm lighting, high quality, 4K"
GOOD โ narrative direction:
"A professional skin treatment scene in a warm clinical setting.
A practitioner wearing blue medical gloves uses a microneedling pen
on the client's forehead. The client lies on a white treatment bed,
eyes closed, relaxed. Warm golden-hour light from a window to the
left. Terracotta-toned wall visible in the background. Shot at
85mm f/2.0, shallow depth of field. No text, no watermarks."
Workflow
1. Determine Image Need
Purpose
Aspect Ratio
Model
Hero banner
16:9 or 21:9
Gemini
Service card
4:3 or 3:4
Gemini
Profile / avatar
1:1
Gemini
Icon / badge
1:1
GPT (transparent)
OG / social share
1.91:1
Gemini
Instagram post
1:1 or 4:5
Gemini
Mobile hero
9:16
Gemini
2. Build the Prompt
Use the 5-part framework. Refer to references/prompting-guide.md for detailed photography parameters.
python3 <<'PYEOF'import json, base64, urllib.request, os, sys
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")ifnot GEMINI_API_KEY:print("Set GEMINI_API_KEY environment variable"); sys.exit(1)model ="gemini-3.1-flash-image-preview"url =f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={GEMINI_API_KEY}"prompt ="""A professional photograph of a modern co-working space in
Newcastle, Australia. Natural light floods through floor-to-ceiling
windows. Three people collaborate at a standing desk โ one pointing
at a laptop screen. Exposed brick wall, potted fiddle-leaf fig,
coffee cups on the desk. Shot at 35mm f/4.0, environmental portrait
style. No text, no watermarks, no logos."""payload = json.dumps({"contents":[{"parts":[{"text": prompt}]}],"generationConfig":{"responseModalities":["TEXT","IMAGE"],"temperature":0.8}}).encode()req = urllib.request.Request(url, data=payload, headers={"Content-Type":"application/json","User-Agent":"ImageGen/1.0"})resp = urllib.request.urlopen(req, timeout=120)result = json.loads(resp.read())# Extract image from responsefor part in result["candidates"][0]["content"]["parts"]:if"inlineData"in part: img_data = base64.b64decode(part["inlineData"]["data"]) output_path ="hero-image.png"withopen(output_path,"wb")as f: f.write(img_data)print(f"Saved: {output_path} ({len(img_data):,} bytes)")breakPYEOF
Save generated images to .jez/artifacts/ or the user's specified path.
Post-processing (optional):
# Convert to WebP for web usepython3 -c"
from PIL import Image
img = Image.open('hero-image.png')
img.save('hero-image.webp', 'WEBP', quality=85)
print(f'WebP: {img.size[0]}x{img.size[1]}')
"# Trim whitespace from transparent iconspython3 -c"
from PIL import Image
img = Image.open('icon.png')
trimmed = img.crop(img.getbbox())
trimmed.save('icon-trimmed.png')
"
5. Quality Check (Optional)
Send the generated image back to a vision model for QA:
Implementation Guide
Prerequisites
โบClaude Desktop or compatible AI client with skill support
โบClear understanding of task or problem to solve
โบWillingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Steps
1Install skill using provided installation command
2Test with simple use case relevant to your work
3Evaluate output quality and relevance
4Iterate on prompts to improve results
5Integrate into regular workflow if valuable
Common Pitfalls
โ Expecting perfect results without iteration
โ Not providing enough context in prompts
โ Using skill for tasks outside its intended scope
โ Accepting outputs without review and validation
Best Practices
โ Do
+Start with clear, specific prompts
+Provide relevant context and constraints
+Review and refine all outputs before using
+Iterate to improve output quality
+Document successful prompt patterns
โ Don't
โDon't use without understanding skill limitations
โDon't skip validation of outputs
โDon't share sensitive information in prompts
โDon't expect skill to replace human judgment
๐ก Pro Tips
โ Be specific about desired format and style
โ Ask for multiple options to choose from
โ Request explanations to understand reasoning
โ Combine AI efficiency with human expertise
When to Use This
โ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
โ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path
1Familiarize yourself with skill capabilities and limitations
2Start with low-risk, non-critical tasks
3Progress to more complex and valuable use cases
4Build expertise through regular use and experimentation