Generate high-quality images using Google Gemini 3 Pro Image Preview model. Use when asked to create AI images, logos, mockups, illustrations, or visual content.
Generate high-quality images using Google's Gemini 3 Pro Image Preview model directly from Claude Code.
Use this skill when the user asks to generate, create, or produce images using AI — including logos, mockups, hero images, illustrations, product photos, or any visual content.
GOOGLE_API_KEY or GEMINI_API_KEY environment variable setcurl and jq available on the system/gemini-3-pro-image-generator [prompt] [--count N] [--output DIR]
When invoked, parse arguments and run the generation loop:
#!/bin/bash
PROMPT="${1:-A beautiful landscape}"
COUNT="${2:-1}"
OUTPUT_DIR="${3:-./gemini-images}"
API_KEY="${GOOGLE_API_KEY:-$GEMINI_API_KEY}"
if [ -z "$API_KEY" ]; then
echo "Error: Set GOOGLE_API_KEY or GEMINI_API_KEY"
exit 1
fi
mkdir -p "$OUTPUT_DIR"
TS=$(date +%Y%m%d_%H%M%S)
OK=0; FAIL=0
for i in $(seq 1 $COUNT); do
echo "[$i/$COUNT] Generating..."
RESP=$(curl -s -X POST \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
-H "x-goog-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"contents\":[{\"parts\":[{\"text\":\"$PROMPT. Unique variation $i of $COUNT. High quality, professional.\"}]}],
\"generationConfig\":{\"responseModalities\":[\"IMAGE\",\"TEXT\"]}
}")
ERR=$(echo "$RESP" | jq -r '.error.message // empty')
if [ -n "$ERR" ]; then
echo " Error: $ERR"
((FAIL++)); continue
fi
DATA=$(echo "$RESP" | jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data // empty')
MIME=$(echo "$RESP" | jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.mimeType // "image/png"')
if [ -n "$DATA" ] && [ "$DATA" != "null" ]; then
EXT="png"; [[ "$MIME" == *"jpeg"* ]] && EXT="jpg"; [[ "$MIME" == *"webp"* ]] && EXT="webp"
FILE="${OUTPUT_DIR}/gemini_${TS}_$(printf '%02d' $i).${EXT}"
echo "$DATA" | base64 -d > "$FILE"
((OK++))
SIZE=$(ls -lh "$FILE" | awk '{print $5}')
echo " Saved: $FILE ($SIZE)"
else
((FAIL++))
echo " Failed: $(echo "$RESP" | jq -r '.candidates[0].content.parts[0].text // "Unknown"')"
fi
[ $i -lt $COUNT ] && sleep 2
done
echo ""
echo "Done: $OK success, $FAIL failed"
[ $OK -gt 0 ] && ls -lh "$OUTPUT_DIR"/gemini_${TS}_*.*
gemini-3-pro-image-previewPOST https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContentx-goog-api-key (URL query param does NOT work for this model)["IMAGE", "TEXT"]| Issue | Solution |
|---|---|
API_KEY not set | export GOOGLE_API_KEY="..." |
403 Permission denied | Use header auth, not ?key= in URL |
404 Model not found | Model name may have changed |
| Empty response | Prompt may violate content policy |
| Rate limited | Increase delay between requests |