skills/gemini-batch/SKILL.md
Process large volumes of requests using Gemini Batch API via scripts/. Use for batch processing, bulk text generation, processing JSONL files, async job execution, and cost-efficient high-volume AI tasks. Triggers on "batch processing", "bulk requests", "JSONL", "async job", "batch job".
npx skillsauth add akrindev/google-studio-skills gemini-batchInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Process large volumes of requests efficiently using Gemini Batch API through executable scripts for cost savings and high throughput.
Use this skill when you need to:
Purpose: Create a batch job from a JSONL file
When to use:
Key parameters:
| Parameter | Description | Example |
|-----------|-------------|---------|
| input_file | JSONL file path (required) | requests.jsonl |
| --model, -m | Model to use | gemini-3-flash-preview |
| --name, -n | Display name for job | "my-batch-job" |
Output: Job name/ID to track with check_status.js
Purpose: Monitor batch job progress and completion
When to use:
Key parameters:
| Parameter | Description | Example |
|-----------|-------------|---------|
| job_name | Batch job name/ID (required) | batches/abc123 |
| --wait, -w | Poll until completion | Flag |
Output: Job status and final state
Purpose: Retrieve completed batch job results
When to use:
Key parameters:
| Parameter | Description | Example |
|-----------|-------------|---------|
| job_name | Batch job name/ID (required) | batches/abc123 |
| --output, -o | Output file path | results.jsonl |
Output: Results content or file
# 1. Create JSONL file
echo '{"key": "req1", "request": {"contents": [{"parts": [{"text": "Explain photosynthesis"}]}]}}' > requests.jsonl
echo '{"key": "req2", "request": {"contents": [{"parts": [{"text": "What is gravity?"}]}}]}' >> requests.jsonl
# 2. Create batch job
node scripts/create_batch.js requests.jsonl --name "science-questions"
# 3. Check status
node scripts/check_status.js <job-name> --wait
# 4. Get results
node scripts/get_results.js <job-name> --output results.jsonl
# 1. Generate JSONL with content requests
python3 << 'EOF'
import json
topics = ["sustainable energy", "AI in healthcare", "space exploration"]
with open("content-requests.jsonl", "w") as f:
for i, topic in enumerate(topics):
req = {
"key": f"blog-{i}",
"request": {
"contents": [{
"parts": [{
"text": f"Write a 500-word blog post about {topic}"
}]
}]
}
}
f.write(json.dumps(req) + "\n")
EOF
# 2. Process batch
node scripts/create_batch.js content-requests.jsonl --name "blog-posts" --model gemini-3-flash-preview
node scripts/check_status.js <job-name> --wait
node scripts/get_results.js <job-name> --output blog-posts.jsonl
# 1. Load dataset and create batch requests
python3 << 'EOF'
import json
# Your dataset
data = [
{"product": "laptop", "features": ["fast", "lightweight"]},
{"product": "headphones", "features": ["wireless", "noise-cancelling"]},
]
with open("product-descriptions.jsonl", "w") as f:
for item in data:
features = ", ".join(item["features"])
prompt = f"Write a product description for {item['product']} with these features: {features}"
req = {
"key": item["product"],
"request": {
"contents": [{"parts": [{"text": prompt}]}]
}
}
f.write(json.dumps(req) + "\n")
EOF
# 2. Process
node scripts/create_batch.js product-descriptions.jsonl
node scripts/check_status.js <job-name> --wait
node scripts/get_results.js <job-name> --output results.jsonl
# 1. Create personalized email requests
python3 << 'EOF'
import json
customers = [
{"name": "Alice", "product": "premium plan"},
{"name": "Bob", "product": "basic plan"},
]
with open("emails.jsonl", "w") as f:
for cust in customers:
prompt = f"Write a personalized email to {cust['name']} about upgrading to our {cust['product']}"
req = {
"key": f"email-{cust['name'].lower()}",
"request": {
"contents": [{"parts": [{"text": prompt}]}]
}
}
f.write(json.dumps(req) + "\n")
EOF
# 2. Process batch
node scripts/create_batch.js emails.jsonl --name "email-campaign"
node scripts/check_status.js <job-name> --wait
node scripts/get_results.js <job-name> --output email-results.jsonl
# 1. Create job
node scripts/create_batch.js large-batch.jsonl --name "big-job"
# 2. Check status periodically (non-blocking)
while true; do
node scripts/check_status.js <job-name>
sleep 60 # Check every minute
done
# 3. Get results when done
node scripts/get_results.js <job-name> --output final-results.jsonl
# 1. Use flash model for cost efficiency
node scripts/create_batch.js requests.jsonl --model gemini-3-flash-preview --name "cost-optimized"
# 2. Monitor and retrieve
node scripts/check_status.js <job-name> --wait
node scripts/get_results.js <job-name>
# Stage 1: Generate content
node scripts/create_batch.js content-requests.jsonl --name "stage1-content"
node scripts/check_status.js <job1> --wait
# Stage 2: Summarize content
node scripts/create_batch.js summaries.jsonl --name "stage2-summaries"
node scripts/check_status.js <job2> --wait
# Stage 3: Convert to audio (gemini-tts)
# Process results from stage 2
Each line is a separate JSON object:
{
"key": "unique-identifier",
"request": {
"contents": [
{
"parts": [
{
"text": "Your prompt here"
}
]
}
]
}
}
| Model | Best For | Cost | Speed |
|-------|----------|------|-------|
| gemini-3-flash-preview | General bulk processing | Lowest | Fast |
| gemini-3-pro-preview | Complex reasoning tasks | Medium | Medium |
| gemini-2.5-flash | Stable, reliable | Low | Fast |
| gemini-2.5-pro | Code/math/STEM | Medium | Slow |
| State | Description |
|-------|-------------|
| JOB_STATE_PENDING | Job queued, waiting to start |
| JOB_STATE_RUNNING | Job actively processing |
| JOB_STATE_SUCCEEDED | Job completed successfully |
| JOB_STATE_FAILED | Job failed (check error message) |
| JOB_STATE_CANCELLED | Job was cancelled |
| JOB_STATE_EXPIRED | Job timed out |
| Method | Max Size | Best For | |--------|-----------|----------| | File upload | Unlimited | Large batches (recommended) | | Inline requests | <20MB | Small batches |
Each line contains:
{
"key": "your-identifier",
"response": {
"text": "Generated content here..."
}
}
error field in response--output to save to filenpm install @google/genai@latest dotenv@latest
.jsonl (not .json)JOB_STATE_SUCCEEDED--wait flag for automated polling--name)# Basic workflow
node scripts/create_batch.js requests.jsonl
node scripts/check_status.js <job-name> --wait
node scripts/get_results.js <job-name> --output results.jsonl
# With model and name
node scripts/create_batch.js requests.jsonl --model gemini-3-flash-preview --name "my-job"
# Create JSONL programmatically
echo '{"key":"1","request":{"contents":[{"parts":[{"text":"Prompt"}]}]}}' > batch.jsonl
development
Generate speech from text using Google Gemini TTS models via scripts/. Use for text-to-speech, audio generation, voice synthesis, multi-speaker conversations, and creating audio content. Supports multiple voices and streaming. Triggers on "text to speech", "TTS", "generate audio", "voice synthesis", "speak this text".
development
Generate text content using Google Gemini models via scripts/. Use for text generation, multimodal prompts with images, thinking mode for complex reasoning, JSON-formatted outputs, and Google Search grounding for real-time information. Triggers on "generate with gemini", "use gemini for text", "AI text generation", "multimodal prompt", "gemini thinking mode", "grounded response".
development
Generate images using Google Gemini and Imagen models via scripts/. Use for AI image generation, text-to-image, creating visuals from prompts, generating multiple images, custom aspect ratios, and high-resolution output up to 4K. Triggers on "generate image", "create image", "imagen", "text to image", "AI art", "nano banana".
development
Upload and manage files using Google Gemini File API via scripts/. Use for uploading images, audio, video, PDFs, and other files for use with Gemini models. Supports file upload, status checking, and file management. Triggers on "upload file", "file API", "upload image", "upload PDF", "upload video", "file management".