Loading...
Loading...
Use Google Gemini API for text generation, multimodal analysis, image generation (Nano Banana), function calling, and search grounding. Invoke when user wants to use Gemini, ask Gemini, generate images with Gemini, or analyze content with Gemini.
npx skill4agent add legacybridge-tech/claude-plugins geminiGOOGLE_API_KEYhttps://generativelanguage.googleapis.com/v1beta| Model | Use Case |
|---|---|
| Fast text generation (default) |
| High quality text generation |
| Latest flash model |
| Latest pro model |
| Image generation (Nano Banana) |
| Advanced image generation with thinking & search |
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [{"text": "Your prompt here"}]
}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [{"text": "Your prompt here"}]
}],
"generationConfig": {
"temperature": 0.9,
"maxOutputTokens": 2000,
"stopSequences": ["END"]
}
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [
{"role": "user", "parts": [{"text": "First message"}]},
{"role": "model", "parts": [{"text": "Model response"}]},
{"role": "user", "parts": [{"text": "Follow-up question"}]}
]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"system_instruction": {
"parts": [{"text": "You are a helpful assistant that speaks like a pirate."}]
},
"contents": [{
"parts": [{"text": "Hello!"}]
}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [{"text": "List 3 colors as JSON array"}]
}],
"generationConfig": {
"response_mime_type": "application/json"
}
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse&key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [{"text": "Write a long story"}]
}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [{"text": "Your prompt"}]
}],
"safetySettings": [
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_ONLY_HIGH"},
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_ONLY_HIGH"}
]
}'# First encode image to base64
BASE64_IMAGE=$(base64 -w0 image.jpg)
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [
{"text": "Describe this image in detail"},
{"inline_data": {"mime_type": "image/jpeg", "data": "'$BASE64_IMAGE'"}}
]
}]
}'# Get upload URL
UPLOAD_URL=$(curl -s "https://generativelanguage.googleapis.com/upload/v1beta/files?key=$GOOGLE_API_KEY" \
-H "X-Goog-Upload-Protocol: resumable" \
-H "X-Goog-Upload-Command: start" \
-H "X-Goog-Upload-Header-Content-Length: $(stat -f%z video.mp4)" \
-H "X-Goog-Upload-Header-Content-Type: video/mp4" \
-H "Content-Type: application/json" \
-d '{"file": {"display_name": "video.mp4"}}' \
-D - | grep -i "x-goog-upload-url" | cut -d' ' -f2 | tr -d '\r')
# Upload file
curl "$UPLOAD_URL" \
-H "X-Goog-Upload-Offset: 0" \
-H "X-Goog-Upload-Command: upload, finalize" \
-H "Content-Type: video/mp4" \
--data-binary @video.mp4curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [
{"text": "Describe what happens in this video"},
{"file_data": {"mime_type": "video/mp4", "file_uri": "FILE_URI_FROM_UPLOAD"}}
]
}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [
{"text": "Transcribe and summarize this audio"},
{"file_data": {"mime_type": "audio/mp3", "file_uri": "FILE_URI_FROM_UPLOAD"}}
]
}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{"parts": [{"text": "Create a photorealistic image of a cat wearing a hat"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}'1:12:33:23:44:34:55:49:1616:921:9curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{"parts": [{"text": "Create a landscape scene"}]}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {
"aspectRatio": "16:9"
}
}
}'BASE64_IMAGE=$(base64 -w0 original.jpg)
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [
{"text": "Put this character in a tropical forest"},
{"inline_data": {"mime_type": "image/jpeg", "data": "'$BASE64_IMAGE'"}}
]
}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{"parts": [{"text": "A photo of an oak tree in all four seasons"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "1:1",
"imageSize": "4K"
}
}
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{"parts": [{"text": "Visualize the current weather forecast for Tokyo as a chart"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "16:9"
}
},
"tools": [{"google_search": {}}]
}'BASE64_IMG1=$(base64 -w0 image1.jpg)
BASE64_IMG2=$(base64 -w0 image2.jpg)
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts": [
{"text": "Combine these two characters in a fantasy world"},
{"inline_data": {"mime_type": "image/jpeg", "data": "'$BASE64_IMG1'"}},
{"inline_data": {"mime_type": "image/jpeg", "data": "'$BASE64_IMG2'"}}
]
}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"role": "user",
"parts": [{"text": "What movies are playing in Mountain View?"}]
}],
"tools": [{
"function_declarations": [{
"name": "find_movies",
"description": "Find movies playing in theaters",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City and state"},
"genre": {"type": "string", "description": "Movie genre"}
},
"required": ["location"]
}
}]
}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [
{"role": "user", "parts": [{"text": "What movies are playing in Mountain View?"}]},
{"role": "model", "parts": [{"functionCall": {"name": "find_movies", "args": {"location": "Mountain View, CA"}}}]},
{"role": "function", "parts": [{"functionResponse": {"name": "find_movies", "response": {"movies": ["Barbie", "Oppenheimer"]}}}]}
],
"tools": [{
"function_declarations": [{
"name": "find_movies",
"description": "Find movies playing in theaters",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"genre": {"type": "string"}
},
"required": ["location"]
}
}]
}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{"parts": [{"text": "What is the current Google stock price?"}]}],
"tools": [{"google_search": {}}]
}'groundingMetadatacurl "https://generativelanguage.googleapis.com/v1beta/cachedContents?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"model": "models/gemini-2.5-flash",
"contents": [{"parts": [{"text": "LARGE_DOCUMENT_TEXT_HERE"}]}],
"ttl": "3600s"
}'curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"cachedContent": "cachedContents/CACHE_ID",
"contents": [{"parts": [{"text": "Summarize the document"}]}]
}'curl "https://generativelanguage.googleapis.com/v1beta/models?key=$GOOGLE_API_KEY"curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash?key=$GOOGLE_API_KEY"{
"candidates": [{
"content": {
"parts": [{"text": "Response text here"}],
"role": "model"
},
"finishReason": "STOP"
}],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 50,
"totalTokenCount": 60
}
}{
"candidates": [{
"content": {
"parts": [
{"text": "Here is your image:"},
{"inlineData": {"mimeType": "image/png", "data": "BASE64_IMAGE_DATA"}}
]
}
}]
}# Extract and decode image from response
echo "BASE64_DATA" | base64 -d > output.png| Error | Cause | Solution |
|---|---|---|
| 400 | Invalid request | Check JSON syntax |
| 401 | Invalid API key | Verify GOOGLE_API_KEY |
| 429 | Rate limit | Wait and retry |
| 500 | Server error | Retry with exponential backoff |
maxOutputTokensstreamGenerateContent