ai-image-generation
Create images, photos, art with Google Imagen 4. Use for: generate image, make picture, AI art
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Create images, photos, art with Google Imagen 4. Use for: generate image, make picture, AI art
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | ai-image-generation |
| description | Create images, photos, art with Google Imagen 4. Use for: generate image, make picture, AI art |
| allowed-tools | Bash(curl *) |
| disable-model-invocation | true |
Generate an image using the Google Imagen 4 API (imagen-4.0-generate-001).
Ask the user for:
Then run the following steps:
Step 1 — Check API key:
if [ -z "$GOOGLE_API_KEY" ]; then
echo "ERROR: GOOGLE_API_KEY not set."
echo "Run /pocket-knife:setup to configure your API keys."
exit 1
fi
Step 2 — Generate the image:
PROMPT="[USER_PROMPT_HERE]"
ASPECT_RATIO="${ASPECT_RATIO:-1:1}"
OUTPUT_FILE="${OUTPUT_FILE:-$HOME/Downloads/imagen_output.png}"
RESPONSE_FILE="/tmp/imagen_response_$$.json"
RESPONSE=$(curl --fail-with-body -s \
-X POST "https://generativelanguage.googleapis.com/v1beta/models/imagen-4.0-generate-001:predict" \
-H "x-goog-api-key: $GOOGLE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"instances\": [{\"prompt\": \"$PROMPT\"}], \"parameters\": {\"sampleCount\": 1, \"aspectRatio\": \"$ASPECT_RATIO\"}}" \
2>&1)
EXIT_CODE=$?
case $EXIT_CODE in
0)
echo "$RESPONSE" > "$RESPONSE_FILE"
;;
22)
if echo "$RESPONSE" | grep -qi "unauthorized\|invalid.*key\|api key"; then
echo "ERROR: Invalid GOOGLE_API_KEY. Check your key in ~/.claude/.env"
elif echo "$RESPONSE" | grep -qi "rate.limit\|quota"; then
echo "ERROR: API quota exceeded. Check your Google AI account billing."
elif echo "$RESPONSE" | grep -qi "not found\|404"; then
echo "ERROR: Model not found. The model imagen-4.0-generate-001 may not be available in your region or API tier."
else
echo "ERROR: API returned HTTP error."
echo "$RESPONSE"
fi
exit 1
;;
6)
echo "ERROR: Could not resolve generativelanguage.googleapis.com. Check internet connection."
exit 1
;;
7)
echo "ERROR: Failed to connect to Google AI API. Check internet connection."
exit 1
;;
*)
echo "ERROR: curl failed with code $EXIT_CODE"
echo "$RESPONSE"
exit 1
;;
esac
Step 3 — Decode and save the image:
python3 - "$RESPONSE_FILE" "$OUTPUT_FILE" << 'PYEOF'
import sys, json, base64
response_file = sys.argv[1]
output_file = sys.argv[2]
with open(response_file, 'r') as f:
data = json.load(f)
predictions = data.get('predictions', [])
if not predictions:
print("ERROR: No image data in response. Check the prompt or try again.")
sys.exit(1)
img_b64 = predictions[0].get('bytesBase64Encoded', '')
if not img_b64:
print("ERROR: Empty image data in response.")
sys.exit(1)
with open(output_file, 'wb') as f:
f.write(base64.b64decode(img_b64))
print(f"Image saved: {output_file}")
PYEOF
rm -f "$RESPONSE_FILE"
Report to the user:
Create multi-speaker dialogue audio. Use for: podcasts, conversations, audiobook scenes
Translate and dub audio/video to another language. Use for: localization, multilingual
Generate music from text description. Use for: background music, jingles, soundtracks
Generate sound effects from description. Use for: SFX, game audio, video soundscape
Transcribe audio to text, speech recognition. Use for: transcription, subtitles, dictation
Convert text to speech, narrate, voiceover. 32 languages, 22+ voices. Use for: TTS, audio