一键导入
generate-image
Generate images using the Gemini API. Creates illustrations, thumbnails, icons, diagrams, photos, and visual assets from text prompts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate images using the Gemini API. Creates illustrations, thumbnails, icons, diagrams, photos, and visual assets from text prompts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Analyze data by writing and running Python scripts. Can generate sample data, process CSVs, compute statistics, and create charts.
Create a daily briefing on a topic by searching for the latest news and developments.
Research a topic using web search and browsing. Gathers current information, synthesizes findings, and writes a report.
Deploy and orchestrate hosted AI agents with Ash. Covers: creating an Ash client, deploying agents, managing sessions (create, pause, resume, end), sending messages, streaming SSE responses, sandbox isolation, multi-turn conversations, real-time text deltas, error handling, and working with files in agent workspaces. Works with TypeScript (@ash-ai/sdk) and Python (ash-ai-sdk) SDKs.
| name | generate-image |
| description | Generate images using the Gemini API. Creates illustrations, thumbnails, icons, diagrams, photos, and visual assets from text prompts. |
| use_when | User asks to create, generate, make, draw, design, or edit any image or visual content |
| allowed-tools | Bash(curl:*), Bash(python3:*), Read |
Generate professional images via the Gemini API's native image generation models.
ALWAYS use this skill when the user:
Do NOT attempt to generate images through any other method.
Verify API key is set:
[ -n "$GEMINI_API_KEY" ] && echo "API key configured" || echo "Missing GEMINI_API_KEY"
If missing, ask the user to set it:
export GEMINI_API_KEY="your-key-from-aistudio.google.com/apikey"
| Model | Best For | Max Resolution | Speed |
|---|---|---|---|
gemini-2.5-flash-image | Fast generation, high-volume, general use | 1024px | Fast |
gemini-3-pro-image-preview | Professional assets, complex prompts, text rendering, 4K | Up to 4K | Slower (thinking model) |
Default model: gemini-2.5-flash-image for most requests.
Use gemini-3-pro-image-preview when user needs: 4K resolution, accurate text in images, complex multi-element compositions, professional asset production, or Google Search grounding.
curl -s "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"contents": [{"parts": [{"text": "YOUR PROMPT HERE"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}' | python3 -c "
import json, sys, base64
data = json.load(sys.stdin)
if 'error' in data:
print('API Error:', data['error'].get('message', str(data['error'])))
sys.exit(1)
candidates = data.get('candidates', [])
if not candidates:
print('No candidates returned')
sys.exit(1)
parts = candidates[0].get('content', {}).get('parts', [])
for part in parts:
if 'inlineData' in part:
img_data = base64.b64decode(part['inlineData']['data'])
mime = part['inlineData'].get('mimeType', 'image/png')
ext = 'png' if 'png' in mime else 'jpg'
outpath = 'OUTPUT_PATH_HERE.' + ext
with open(outpath, 'wb') as f:
f.write(img_data)
print(f'Image saved to: {outpath} ({len(img_data)} bytes)')
elif 'text' in part and not part.get('thought'):
print('Model notes:', part['text'][:300])
"
Add imageConfig to control aspect ratio:
curl -s "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"contents": [{"parts": [{"text": "YOUR PROMPT HERE"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "16:9"
}
}
}' | python3 -c "SAME_DECODER_SCRIPT"
To edit an existing image, base64-encode it and include it as an inlineData part:
python3 -c "
import base64, json, subprocess, sys
with open('INPUT_IMAGE_PATH', 'rb') as f:
b64 = base64.b64encode(f.read()).decode()
payload = {
'contents': [{'parts': [
{'inlineData': {'mimeType': 'image/png', 'data': b64}},
{'text': 'YOUR EDIT INSTRUCTION HERE'}
]}],
'generationConfig': {
'responseModalities': ['TEXT', 'IMAGE']
}
}
result = subprocess.run(
['curl', '-s',
'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key=' + '$GEMINI_API_KEY_VALUE',
'-H', 'Content-Type: application/json',
'-d', json.dumps(payload)],
capture_output=True, text=True
)
data = json.loads(result.stdout)
if 'error' in data:
print('API Error:', data['error'].get('message', str(data['error'])))
sys.exit(1)
for part in data.get('candidates', [{}])[0].get('content', {}).get('parts', []):
if 'inlineData' in part:
img_data = base64.b64decode(part['inlineData']['data'])
with open('OUTPUT_PATH', 'wb') as f:
f.write(img_data)
print(f'Image saved ({len(img_data)} bytes)')
elif 'text' in part and not part.get('thought'):
print('Model notes:', part['text'][:300])
"
| Ratio | Use Case |
|---|---|
| 1:1 | Square social (IG, LinkedIn) |
| 16:9 | Blog featured, YouTube thumbnail |
| 9:16 | Vertical story |
| 3:2 | Landscape photo |
| 21:9 | Twitter/X header |
After generation: