### Install Dependencies Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-image/SKILL.md Installs necessary Node.js dependencies, specifically 'google-genai' and 'pillow', required for image generation scripts. ```bash cd scripts && npm install ``` -------------------------------- ### Configure Gemini API Environment Source: https://context7.com/akrindev/google-studio-skills/llms.txt Sets up the necessary environment variables and installs the required Node.js dependencies to interact with the Gemini API. ```bash export GEMINI_API_KEY="your-api-key" echo "GEMINI_API_KEY=your-api-key" > .env npm install @google/genai@latest dotenv@latest ``` -------------------------------- ### Install Google GenAI Node.js Dependencies Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Provides the command to install the necessary npm packages for using the Google GenAI library in a Node.js project. ```bash npm install @google/genai@latest dotenv@latest ``` -------------------------------- ### Bash/Node.js: Content Creation Pipeline Source: https://context7.com/akrindev/google-studio-skills/llms.txt This example demonstrates a multi-step content creation pipeline using bash and Node.js scripts. It covers generating blog content with a text model, creating a featured image with an image model, generating podcast audio from the text, and setting up a batch job for multiple articles. It utilizes various skills like gemini-text, gemini-image, gemini-tts, and gemini-batch. ```bash # Step 1: Generate blog content (gemini-text) node skills/gemini-text/scripts/generate.js "Write a 500-word blog post about sustainable energy" --model gemini-3-flash-preview > blog-content.txt # Step 2: Generate featured image (gemini-image) node skills/gemini-image/scripts/generate_image.js "Serene solar panels and wind turbines at sunrise, digital art style" --aspect 16:9 --size 2K --name blog-featured # Step 3: Generate podcast audio (gemini-tts) node skills/gemini-tts/scripts/tts.js "$(cat blog-content.txt)" --voice Fenrir --output blog-podcast # Step 4: Create batch job for multiple articles cat > articles.jsonl << 'EOF' {"key": "article-1", "request": {"contents": [{"parts": [{"text": "Write about electric vehicles"}]}]}} {"key": "article-2", "request": {"contents": [{"parts": [{"text": "Write about renewable energy"}]}]}} {"key": "article-3", "request": {"contents": [{"parts": [{"text": "Write about carbon capture"}]}]}} EOF node skills/gemini-batch/scripts/create_batch.js articles.jsonl --name "blog-series" ``` -------------------------------- ### Model Selection Guide Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-text/references/models.md A guide to help select the appropriate Gemini model based on use case, from most intelligent to cost-sensitive options. ```APIDOC ## Model Selection Guide This guide helps you choose the best Gemini model for your specific needs: | Use Case | |---|---| | Most intelligent | `gemini-3-pro-preview` | | Fast responses | `gemini-2.5-flash` | | Complex reasoning | `gemini-2.5-pro` | | Cost-sensitive | `gemini-2.5-flash-lite` | | 4K images | `gemini-3-pro-image-preview` | | Fast images | `gemini-2.5-flash-image` | | Text-to-speech | `gemini-2.5-flash-preview-tts` | | Embeddings | `gemini-embedding-001` | ``` -------------------------------- ### Gemini Embedding API - Quick Reference Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-embeddings/SKILL.md A quick reference guide for common commands and usage patterns of the Gemini Embedding API, including examples for basic embedding, search, and similarity comparison. ```APIDOC ## Quick Reference ```bash # Basic embedding node scripts/embed.js "Your text here" # Semantic search node scripts/embed.js "Query" --task RETRIEVAL_QUERY # Document embedding node scripts/embed.js "Document text" --task RETRIEVAL_DOCUMENT # Similarity comparison node scripts/embed.js "Text 1" "Text 2" "Text 3" --similarity # Dimensionality reduction node scripts/embed.js "Text" --dim 768 # JSON output node scripts/embed.js "Text" --json ``` ``` -------------------------------- ### Programmatic JSONL Creation (Bash) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md This example shows how to programmatically create a JSON Lines (JSONL) file suitable for batch processing by echoing a single request object. This is useful for scripting or generating small test files. ```bash # Create JSONL programmatically echo '{"key":"1","request":{"contents":[{"parts":[{"text":"Prompt"}]}]}}' > batch.jsonl ``` -------------------------------- ### Common Issues Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Troubleshooting guide for common issues encountered when using the Batch API, including installation problems, file format errors, job failures, and missing results. ```APIDOC ## Common Issues ### "google-genai not installed" Ensure the necessary packages are installed: ```bash npm install @google/genai@latest dotenv@latest ``` ### "JSONL file not found" - Verify the file path is correct. - Confirm the file extension is `.jsonl` (not `.json`). - Use absolute paths if relative paths are causing issues. ### "Invalid JSONL format" - Each line must be a valid JSON object. - Avoid trailing commas between JSON objects on different lines. - Check for general JSON syntax errors. - Use a JSON validator to confirm format. ### "Job failed" - Examine the error message provided in the job status. - Validate that the request format adheres to the expected structure. - Ensure the requested model is available and not subject to quotas. - Review your API quota limits. ### "No results found" - Confirm the job status is `JOB_STATE_SUCCEEDED`. - Ensure the job has fully completed before attempting to retrieve results. - Check the job status using `check_status.js` prior to retrieving results. ``` -------------------------------- ### GET /files Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md List all files associated with the authenticated account. ```APIDOC ## GET /files ### Description Retrieves a list of all files uploaded to the Google GenAI service. ### Method GET ### Endpoint /files ### Response #### Success Response (200) - **files** (array) - A list of file objects containing name, displayName, and state. #### Response Example { "files": [ { "name": "files/abc123", "displayName": "photo.png", "state": "ACTIVE" } ] } ``` -------------------------------- ### Install NumPy for Similarity Calculations Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-embeddings/SKILL.md This command installs the NumPy library, which is often required for performing mathematical operations, including similarity calculations, when working with embeddings in Python. ```bash pip install numpy ``` -------------------------------- ### Gemini Embedding API - Common Issues Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-embeddings/SKILL.md Troubleshooting guide for common issues encountered when using the Gemini Embedding API, including installation problems and invalid parameter errors. ```APIDOC ## Common Issues ### "google-genai not installed" ```bash npm install @google/genai@latest dotenv@latest ``` ### "numpy not installed" (for similarity) ```bash pip install numpy ``` ### "Invalid task type" - Use available tasks: SEMANTIC_SIMILARITY, RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY, CLASSIFICATION, CLUSTERING - Check spelling (case-sensitive) - Use correct task for your use case ### "Invalid dimension" - Options: 768, 1536, or 3072 only - Check model supports requested dimension - Default to 3072 if unsure ### "No similarity calculated" - Need multiple texts for similarity comparison - Use `--similarity` flag - Check that at least 2 texts provided ### "Embedding size mismatch" - All embeddings must have same dimensionality - Use consistent `--dim` parameter - Recompute if dimensions differ ``` -------------------------------- ### List Available Gemini Models Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-text/references/models.md This snippet demonstrates how to use the Google GenAI client library to retrieve and print a list of all available models. It requires the google-genai package to be installed and configured. ```python from google import genai client = genai.Client() for model in client.models.list(): print(model.name) ``` -------------------------------- ### Analyze Image with Gemini Text Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Example of using the gemini-text tool to analyze an uploaded image, referencing the file path in the command. ```bash # With gemini-text node skills/gemini-text/scripts/generate.js "Analyze" --image ``` -------------------------------- ### GET /files/{name} Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Retrieve detailed information about a specific file by its name. ```APIDOC ## GET /files/{name} ### Description Fetches the metadata and current processing state of a specific file. ### Method GET ### Endpoint /files/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The unique identifier of the file (e.g., files/abc123). ### Response #### Success Response (200) - **name** (string) - The file identifier. - **state** (string) - The current state (PROCESSING, ACTIVE, or FAILED). #### Response Example { "name": "files/abc123", "state": "ACTIVE" } ``` -------------------------------- ### Analyze Video with Gemini API (JavaScript) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Provides an example of uploading a video file and then using the gemini-text skill for content analysis. This is suitable for video summarization and content processing, noting potential long processing times. ```bash # 1. Upload video (may take time) node scripts/upload.js product-demo.mp4 --name "demo-video" --wait # 2. Analyze with gemini-text node skills/gemini-text/scripts/generate.js "Analyze this product demo video" --image product-demo.mp4 ``` -------------------------------- ### Workflow 7: Multi-Stage Pipeline Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md This workflow outlines how to construct complex, multi-stage processing pipelines using the Batch API. It shows an example of chaining jobs, where the output of one stage serves as the input for the next, enabling sophisticated data processing workflows. ```APIDOC ## Workflow 7: Multi-Stage Pipeline ### Description This workflow enables the creation of complex, multi-stage processing pipelines by chaining multiple batch jobs together, where the output of one stage feeds into the next. ### Steps 1. **Stage 1: Generate content**: Create a batch job for content generation using `create_batch.js` and monitor its completion. 2. **Stage 2: Summarize content**: Create a second batch job for summarizing the content generated in Stage 1, again monitoring its completion. 3. **Stage 3: Convert to audio (gemini-tts)**: Process the results from Stage 2, potentially using text-to-speech models. ### Commands ```bash # Stage 1: Generate content node scripts/create_batch.js content-requests.jsonl --name "stage1-content" node scripts/check_status.js --wait # Stage 2: Summarize content node scripts/create_batch.js summaries.jsonl --name "stage2-summaries" node scripts/check_status.js --wait # Stage 3: Convert to audio (gemini-tts) # Process results from stage 2 ``` ### Best For Complex workflows, multi-step processing. ### Combines With Other Gemini skills for complete pipelines. ``` -------------------------------- ### Generate Text Embeddings with embed.js Source: https://context7.com/akrindev/google-studio-skills/llms.txt Provides examples for creating text embeddings, performing semantic similarity comparisons, and configuring tasks for RAG or clustering applications. ```bash node skills/gemini-embeddings/scripts/embed.js "What is the meaning of life?" node skills/gemini-embeddings/scripts/embed.js "What is the meaning of life?" "What is the purpose of existence?" "How do I bake a cake?" --similarity node skills/gemini-embeddings/scripts/embed.js "best practices for coding" --task RETRIEVAL_QUERY node skills/gemini-embeddings/scripts/embed.js "Coding best practices include version control" "Clean code is essential" --task RETRIEVAL_DOCUMENT node skills/gemini-embeddings/scripts/embed.js "Text to embed" --dim 768 node skills/gemini-embeddings/scripts/embed.js "Machine learning is AI" "Deep learning is a subset" "Neural networks power AI" --task CLUSTERING node skills/gemini-embeddings/scripts/embed.js "Text to process" --json node skills/gemini-embeddings/scripts/embed.js "Document content here" --task RETRIEVAL_DOCUMENT --dim 1536 node skills/gemini-embeddings/scripts/embed.js "User query here" --task RETRIEVAL_QUERY --dim 1536 ``` -------------------------------- ### Basic Batch Job Workflow (Bash) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md This snippet demonstrates the fundamental command-line workflow for creating, checking the status of, and retrieving results for a batch job using Google Studio Skills scripts. It includes options for automated polling. ```bash # Basic workflow node scripts/create_batch.js requests.jsonl node scripts/check_status.js --wait node scripts/get_results.js --output results.jsonl ``` ```bash # With model and name node scripts/create_batch.js requests.jsonl --model gemini-3-flash-preview --name "my-job" ``` -------------------------------- ### Integrating Gemini TTS with Text Generation for Content Creation Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-tts/SKILL.md Demonstrates a pipeline where text is first generated using another skill (e.g., gemini-text) and then converted to speech using Gemini TTS. This workflow is useful for creating podcast intros, audiobooks, or video narration. ```bash # 1. Generate script (gemini-text skill) node skills/gemini-text/scripts/generate.js "Write a 2-minute podcast intro about sustainable energy" # 2. Generate audio (this skill) node scripts/tts.js "[Paste generated script]" --voice Fenrir --output podcast-intro # 3. Use in video or podcast ``` -------------------------------- ### Manage Multimodal Files with upload.js Source: https://context7.com/akrindev/google-studio-skills/llms.txt Demonstrates uploading various file types for use with Gemini models. Includes options for custom naming, waiting for processing, and integrating with generation scripts. ```bash node skills/gemini-files/scripts/upload.js image.jpg node skills/gemini-files/scripts/upload.js document.pdf --name "Quarterly Report Q4 2026" node skills/gemini-files/scripts/upload.js video.mp4 --wait node skills/gemini-files/scripts/upload.js photo.png --name "product-shot" node skills/gemini-text/scripts/generate.js "Describe this image" --image photo.png node skills/gemini-files/scripts/upload.js research-paper.pdf --name "AI-Research-Paper" --wait node skills/gemini-text/scripts/generate.js "Extract key findings from this document" --image research-paper.pdf for file in *.jpg; do node skills/gemini-files/scripts/upload.js "$file" done ``` -------------------------------- ### Upload File with Node.js Script Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Demonstrates how to upload a file using a Node.js script. Supports basic uploads, custom naming, and waiting for processing. ```bash # Basic upload node scripts/upload.js image.jpg # With custom name node scripts/upload.js document.pdf --name "My Document" # Wait for processing node scripts/upload.js video.mp4 --wait # Multiple files for file in *.jpg; do node scripts/upload.js "$file"; done ``` -------------------------------- ### Execute Batch Processing with Gemini API Source: https://context7.com/akrindev/google-studio-skills/llms.txt Demonstrates how to process large volumes of requests using the Gemini Batch API. Includes steps for creating JSONL request files, initiating jobs, monitoring status, and retrieving results. ```bash cat > requests.jsonl << 'EOF' {"key": "req1", "request": {"contents": [{"parts": [{"text": "Explain photosynthesis"}]}]}} {"key": "req2", "request": {"contents": [{"parts": [{"text": "What is gravity?"}]}]}} {"key": "req3", "request": {"contents": [{"parts": [{"text": "Define machine learning"}]}]}} EOF node skills/gemini-batch/scripts/create_batch.js requests.jsonl --name "science-questions" --model gemini-3-flash-preview node skills/gemini-batch/scripts/check_status.js batches/abc123 --wait node skills/gemini-batch/scripts/get_results.js batches/abc123 --output results.jsonl ``` ```python 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") ``` -------------------------------- ### Prepare Dataset for Batch Processing Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Demonstrates how to transform a structured dataset into a JSONL format suitable for batch processing with Gemini. ```python import json 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") ``` -------------------------------- ### Transcribe Audio with Gemini API (JavaScript) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Illustrates uploading an audio file and processing it with the gemini-text skill, assuming transcription capabilities are available. Useful for audio analysis and summarization. ```bash # 1. Upload audio node scripts/upload.js interview.mp3 --name "interview-001" --wait # 2. Process with gemini-text (if transcription available) node skills/gemini-text/scripts/generate.js "Transcribe and summarize this audio" --image interview.mp3 ``` -------------------------------- ### Execute Image Generation via Node.js Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-image/SKILL.md Demonstrates how to invoke the image generation script using various configurations such as aspect ratios, resolutions, and output directories. These commands are executed via the Node.js runtime. ```bash node scripts/generate_image.js "A futuristic city at sunset with flying cars" ``` ```bash node scripts/generate_image.js "Minimalist coffee shop interior" --aspect 1:1 --size 2K --name coffee-shop ``` ```bash node scripts/generate_image.js "Tech gadget review thumbnail with vibrant colors" --aspect 16:9 --size 2K --name thumbnail ``` ```bash node scripts/generate_image.js "Abstract geometric patterns in blue and gold" --num 4 --name abstract ``` ```bash node scripts/generate_image.js "Detailed architectural rendering of modern museum" --aspect 16:9 --size 4K --output-dir ./professional/ --name museum ``` ```bash node scripts/generate_image.js "Robot holding a red skateboard in urban setting" --model imagen-4.0-generate-001 --aspect 16:9 --size 2K --num 2 --name robot-skate ``` ```bash node scripts/generate_image.js "Serene mountain lake at sunrise with reflections" --aspect 16:9 --size 2K --output-dir ./blog-images/ --name featured-image ``` ```bash node skills/gemini-text/scripts/generate.js "Write a product description for smart home device" node scripts/generate_image.js "Sleek modern smart home device on white background" --aspect 4:3 --size 2K --name product ``` -------------------------------- ### Execute Batch Processing Workflow Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Demonstrates the end-to-end process of creating a batch job, monitoring its status, and retrieving results using the provided Node.js scripts. ```bash echo '{"key": "req1", "request": {"contents": [{"parts": [{"text": "Explain photosynthesis"}]}]}}' > requests.jsonl echo '{"key": "req2", "request": {"contents": [{"parts": [{"text": "What is gravity?"}]}}]}' >> requests.jsonl node scripts/create_batch.js requests.jsonl --name "science-questions" node scripts/check_status.js --wait node scripts/get_results.js --output results.jsonl ``` -------------------------------- ### Implement Semantic Search and RAG Workflows Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-embeddings/SKILL.md Shows how to generate embeddings for queries and documents to perform retrieval tasks, which are essential for building RAG applications or semantic search engines. ```bash # Generate query and document embeddings node scripts/embed.js "best practices for coding" --task RETRIEVAL_QUERY > query.json node scripts/embed.js "Coding best practices include version control" "Clean code is essential" --task RETRIEVAL_DOCUMENT > docs.json # RAG implementation example node scripts/embed.js "Document 1 content" --task RETRIEVAL_DOCUMENT --dim 1536 node scripts/embed.js "User query here" --task RETRIEVAL_QUERY ``` -------------------------------- ### Execute Google Studio Scripts Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-text/SKILL.md Provides common command-line interface patterns for interacting with the Google Studio scripts, including support for personas, thinking mode, JSON output, and multimodal inputs. ```bash # Basic node scripts/generate.js "Your prompt" # Persona node scripts/generate.js "Prompt" --system "You are X" # Thinking node scripts/generate.js "Complex task" --thinking # JSON node scripts/generate.js "Generate JSON" --json # Search node scripts/generate.js "Current event" --grounding # Multimodal node scripts/generate.js "Describe this" --image photo.png ``` -------------------------------- ### Configure API Environment Variables Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-text/SKILL.md Sets the required API key as an environment variable to authenticate requests to the Gemini API. ```bash export GOOGLE_API_KEY="your-key-here" # or export GEMINI_API_KEY="your-key-here" ``` -------------------------------- ### Batch Upload Files for Gemini API (Bash Script) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md A bash script demonstrating how to upload multiple files, typically images, in a loop using the upload script. This prepares files for batch processing with other Gemini skills. ```bash # 1. Upload multiple files for file in *.jpg; do node scripts/upload.js "$file" done # 2. Create batch job using uploaded files (gemini-batch skill) ``` -------------------------------- ### Execute TTS script via CLI Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-tts/SKILL.md Demonstrates various ways to invoke the tts.js script, including basic text-to-speech, custom voice selection, multi-speaker configurations, and streaming audio output. ```bash # Basic node scripts/tts.js "Your text here" # Custom voice node scripts/tts.js "Your text" --voice Puck --output audio.wav # Multi-speaker node scripts/tts.js "Joe: Hi. Jane: Hello!" --speakers "Joe:Kore,Jane:Puck" # Streaming node scripts/tts.js "Long text..." --stream --output long.wav # Professional node scripts/tts.js "Corporate announcement" --voice Charon ``` -------------------------------- ### Generate Image with Node.js Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-image/SKILL.md This script generates image content using a provided prompt. It supports various customization options such as aspect ratio, image size, custom naming, output directory, specific models, and disabling timestamps. Dependencies include Node.js and the necessary Google Studio Skills libraries. ```bash node scripts/generate_image.js "Your prompt" ``` ```bash node scripts/generate_image.js "Prompt" --aspect 1:1 --size 2K --name social-post ``` ```bash node scripts/generate_image.js "Prompt" --aspect 16:9 --size 2K --name thumbnail ``` ```bash node scripts/generate_image.js "Prompt" --aspect 16:9 --size 4K --name high-res ``` ```bash node scripts/generate_image.js "Prompt" --num 4 --name variations ``` ```bash node scripts/generate_image.js "Prompt" --output-dir ./my-images/ --name custom ``` ```bash node scripts/generate_image.js "Prompt" --model imagen-4.0-generate-001 --aspect 16:9 --size 2K --name photo ``` ```bash node scripts/generate_image.js "Prompt" --name fixed-name --no-timestamp ``` -------------------------------- ### Async Job Monitoring Loop Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Demonstrates a non-blocking approach to monitoring long-running batch jobs using a shell loop. ```bash while true; do node scripts/check_status.js sleep 60 done ``` -------------------------------- ### JavaScript: Manage Google AI Files Source: https://context7.com/akrindev/google-studio-skills/llms.txt This snippet demonstrates how to manage files using the Google GenAI JavaScript client. It includes listing all files associated with the API key and deleting a specific file by its resource name. Ensure the GEMINI_API_KEY environment variable is set. ```javascript import { GoogleGenAI } from "@google/genai"; const client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); // List all files for await (const file of client.files.list()) { console.log(`${file.name}: ${file.displayName} (${file.state})`); } // Delete file await client.files.delete({ name: "files/abc123..." }); ``` -------------------------------- ### Workflow 6: Cost-Optimized Bulk Processing Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md This workflow focuses on optimizing costs for high-volume processing by utilizing the `gemini-3-flash-preview` model. It details the steps for creating a batch job with a cost-efficient model and then monitoring and retrieving the results. ```APIDOC ## Workflow 6: Cost-Optimized Bulk Processing ### Description This workflow demonstrates how to perform cost-optimized bulk processing by leveraging specific models designed for efficiency, such as `gemini-3-flash-preview`. ### Steps 1. **Use flash model for cost efficiency**: Create a batch job using `create_batch.js`, specifying the `--model` flag with a cost-effective model like `gemini-3-flash-preview`. 2. **Monitor and retrieve**: Use `check_status.js` with the `--wait` flag to monitor the job until completion, and then use `get_results.js` to fetch the output. ### Commands ```bash # 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 --wait node scripts/get_results.js ``` ### Best For High-volume, cost-sensitive applications. ### Savings Batch API typically 50%+ cheaper than real-time. ``` -------------------------------- ### Extract Content from PDF with Gemini API (JavaScript) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Shows how to upload a PDF file, wait for its processing, and then use the gemini-text skill to extract content. Ideal for document analysis and information retrieval. ```bash # 1. Upload PDF node scripts/upload.js research-paper.pdf --name "AI-Research-Paper" --wait # 2. Extract content with gemini-text node skills/gemini-text/scripts/generate.js "Extract key findings from this document" --image research-paper.pdf ``` -------------------------------- ### Analyze Image with Gemini API (JavaScript) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Demonstrates uploading an image and then using it with the gemini-text skill for analysis. This workflow is suitable for image captioning and visual question answering. ```bash # 1. Upload image node scripts/upload.js photo.png --name "product-shot" # 2. Use with gemini-text for analysis node skills/gemini-text/scripts/generate.js "Describe this image" --image photo.png ``` -------------------------------- ### Batch Job Lifecycle Management Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Standard workflow for creating, monitoring, and retrieving results for batch AI processing jobs. ```bash node scripts/create_batch.js product-descriptions.jsonl node scripts/check_status.js --wait node scripts/get_results.js --output results.jsonl ``` -------------------------------- ### Generate Text Embeddings and Similarity Scores Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-embeddings/SKILL.md Demonstrates how to generate vector embeddings for single or multiple texts, calculate pairwise similarity, and adjust output dimensionality for performance optimization. ```bash node scripts/embed.js "What is the meaning of life?" node scripts/embed.js "What is the meaning of life?" "What is the purpose of existence?" "How do I bake a cake?" --similarity node scripts/embed.js "Text to embed" --dim 768 ``` -------------------------------- ### Generate Educational TTS Audio with Zephyr Voice Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-tts/SKILL.md This workflow demonstrates generating educational audio content using the `tts.js` script with the 'Zephyr' voice. It's ideal for tutorials and e-learning materials. The output is saved to a file named 'chapter1'. ```bash node scripts/tts.js "Chapter 1: Introduction to Quantum Computing. Let's explore the fundamental principles..." --voice Zephyr --output chapter1 ``` -------------------------------- ### Workflow 4: Email Campaign Generation Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md This workflow demonstrates how to generate personalized email content for a marketing campaign using the Batch API. It involves creating a JSONL file with customer data, generating prompts, and then processing these prompts as a batch job. ```APIDOC ## Workflow 4: Email Campaign Generation ### Description This workflow generates personalized email content for marketing campaigns by creating a batch of email requests. ### Steps 1. **Create personalized email requests**: A Python script generates a `emails.jsonl` file where each line is a JSON object containing a unique key and a request to draft a personalized email. 2. **Process batch**: The `create_batch.js` script processes the `emails.jsonl` file, creating a batch job. The `check_status.js` script monitors the job until completion, and `get_results.js` retrieves the generated email content. ### Request Body Example (emails.jsonl) ```json { "key": "email-alice", "request": { "contents": [ { "parts": [ { "text": "Write a personalized email to Alice about upgrading to our premium plan" } ] } ] } } ``` ### Commands ```bash # 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 --wait node scripts/get_results.js --output email-results.jsonl ``` ### Best For Marketing campaigns, personalized outreach. ``` -------------------------------- ### Customizing Output Directory for Gemini TTS Audio Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-tts/SKILL.md Saves generated audio files to a specified directory (e.g., './my-projects/podcasts/'). This feature helps in organizing audio assets within project structures, automatically creating the directory if it does not exist. ```bash node scripts/tts.js "Save to specific folder." --output-dir ./my-projects/podcasts/ --output episode1 ``` -------------------------------- ### Python: List Available Google AI Models Source: https://context7.com/akrindev/google-studio-skills/llms.txt This Python script lists all available models provided by the Google GenAI client. It iterates through the models and prints their names to the console. This is useful for understanding which AI capabilities are accessible. ```python from google import genai client = genai.Client() for model in client.models.list(): print(model.name) ``` -------------------------------- ### Parameters Reference Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Reference for parameters used in the Batch API, including the JSONL format for requests, available model selections, job states, and size limits for input data. ```APIDOC ## Parameters Reference ### JSONL Format Each line in a JSONL file represents a separate JSON object for a request. ```json { "key": "unique-identifier", "request": { "contents": [ { "parts": [ { "text": "Your prompt here" } ] } ] } } ``` ### Model Selection | 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 | ### Job States | 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 | ### Size Limits | Method | Max Size | Best For | |-------------|-----------|------------------| | File upload | Unlimited | Large batches (recommended) | | Inline requests | <20MB | Small batches | ``` -------------------------------- ### Generate Images with Imagen Source: https://context7.com/akrindev/google-studio-skills/llms.txt Creates images from text prompts using the generate_image.js script. Supports various aspect ratios, resolutions, batch processing, and model selection. ```bash node skills/gemini-image/scripts/generate_image.js "A futuristic city at sunset with flying cars" node skills/gemini-image/scripts/generate_image.js "Minimalist coffee shop interior" --aspect 1:1 --size 2K --name coffee-shop node skills/gemini-image/scripts/generate_image.js "Tech gadget review thumbnail with vibrant colors" --aspect 16:9 --size 2K --name thumbnail node skills/gemini-image/scripts/generate_image.js "Abstract geometric patterns in blue and gold" --num 4 --name abstract node skills/gemini-image/scripts/generate_image.js "Detailed architectural rendering of modern museum" --aspect 16:9 --size 4K --output-dir ./professional/ --name museum node skills/gemini-image/scripts/generate_image.js "Robot holding a red skateboard in urban setting" --model imagen-4.0-generate-001 --aspect 16:9 --size 2K --name robot node skills/gemini-image/scripts/generate_image.js "Product shot" --name product-image --no-timestamp ``` -------------------------------- ### Workflow 5: Async Job Monitoring Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md This workflow illustrates how to handle long-running or background processing tasks using the Batch API. It covers creating a job, periodically checking its status without blocking, and retrieving results once the job is complete. ```APIDOC ## Workflow 5: Async Job Monitoring ### Description This workflow is designed for managing long-running jobs and background processing tasks, allowing for periodic status checks without blocking the main execution flow. ### Steps 1. **Create job**: Submit a large batch of requests using `create_batch.js`. 2. **Check status periodically**: An infinite loop continuously checks the job status using `check_status.js` at specified intervals (e.g., every minute). 3. **Get results when done**: Once the job is completed, `get_results.js` is used to retrieve the final output. ### Commands ```bash # 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 sleep 60 # Check every minute done # 3. Get results when done node scripts/get_results.js --output final-results.jsonl ``` ### Best For Long-running jobs, background processing. ### Use When You don't need immediate results. ``` -------------------------------- ### Create Social Media Post Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-image/SKILL.md This section describes the process of creating social media posts, highlighting its suitability for e-commerce and marketing campaigns, and its integration with other Gemini models. ```APIDOC ## Create Social Media Post ### Description This endpoint is designed for creating social media posts, particularly effective for e-commerce and marketing campaigns. It can be combined with `gemini-text` and `gemini-batch` for comprehensive content production. ### Method POST ### Endpoint /api/social-media-posts ### Parameters #### Request Body - **prompt** (string) - Required - The text prompt describing the desired social media post content. - **model** (string) - Optional - The AI model to use for generation (e.g., `gemini-3.1-flash-image-preview`). Defaults to a recommended model. - **aspect_ratio** (string) - Optional - The desired aspect ratio (e.g., '16:9', '1:1'). Defaults to '1:1'. - **size** (string) - Optional - The desired image size (e.g., '1K', '2K', '4K'). Defaults to '2K'. - **person_policy** (string) - Optional - Policy for person generation ('dont_allow', 'allow_adult', 'allow_all'). Defaults to 'allow_adult'. ### Request Example ```json { "prompt": "Create an engaging Instagram post about our new summer collection, featuring vibrant beachwear.", "model": "gemini-3.1-flash-image-preview", "aspect_ratio": "1:1", "size": "2K", "person_policy": "allow_adult" } ``` ### Response #### Success Response (200) - **image_url** (string) - URL to the generated social media post image. - **post_text** (string) - Generated text content for the social media post. #### Response Example ```json { "image_url": "https://example.com/images/social_post_123.png", "post_text": "Dive into summer with our stunning new collection! ☀️ Shop now and make a splash! #SummerFashion #BeachVibes" } ``` ``` -------------------------------- ### Basic Text Generation with Gemini Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-text/SKILL.md Generates text content using the Gemini API with a simple prompt. This is the most basic usage for straightforward content creation. ```bash node scripts/generate.js "Explain quantum computing in simple terms" ``` -------------------------------- ### Generate JSONL for Bulk Content Generation Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Uses Python to generate a JSONL file containing multiple content generation requests, which can then be processed by the Gemini Batch API. ```python 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") ``` -------------------------------- ### Personalized Email Campaign Generation Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Generates a JSONL file of personalized email prompts using Python, then processes them as a batch job. ```python 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") ``` -------------------------------- ### Manage Files with Google GenAI JavaScript API Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-files/SKILL.md Shows how to interact with the file management API using JavaScript, including listing, retrieving, and deleting files. ```javascript import { GoogleGenAI } from "@google/genai"; const client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); // List all files for await (const file of client.files.list()) { console.log(`${file.name}: ${file.displayName} (${file.state})`); } // Get file info const file = await client.files.get({ name: "files/abc123..." }); console.log(`State: ${file.state}`); // Delete file await client.files.delete({ name: "files/abc123..." }); ``` -------------------------------- ### Generate Text with Gemini API Source: https://context7.com/akrindev/google-studio-skills/llms.txt Executes text generation tasks using the generate.js script. Supports system instructions, thinking mode, JSON output, Google Search grounding, and multimodal image analysis. ```bash node skills/gemini-text/scripts/generate.js "Explain quantum computing in simple terms" node skills/gemini-text/scripts/generate.js "How do I read a file in Python?" --system "You are a helpful coding assistant" node skills/gemini-text/scripts/generate.js "Analyze the ethical implications of AI in healthcare" --thinking node skills/gemini-text/scripts/generate.js "Generate a user profile object with name, email, and preferences" --json node skills/gemini-text/scripts/grounding.js "Who won the latest Super Bowl?" --grounding node skills/gemini-text/scripts/generate.js "Describe what's in this image in detail" --image photo.png node skills/gemini-text/scripts/generate.js "Write a creative story" --model gemini-3-pro-preview --temperature 0.8 --max-tokens 2000 ``` -------------------------------- ### Gemini Text Generation with System Instruction (Persona) Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-text/SKILL.md Generates text content while applying a specific persona or behavior defined by a system instruction. Useful for domain-specific tasks or maintaining a consistent tone. ```bash node scripts/generate.js "How do I read a file in Python?" --system "You are a helpful coding assistant" ``` -------------------------------- ### POST /tts/generate Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-tts/SKILL.md Generates an audio file from input text using specified voice models and configuration options. ```APIDOC ## POST /tts/generate ### Description Generates audio content from provided text. Supports multiple voices, streaming, and custom output naming. ### Method POST ### Endpoint node scripts/tts.js ### Parameters #### Query Parameters - **text** (string) - Required - The text content to convert to speech. - **--voice** (string) - Optional - The voice profile to use (Kore, Puck, Charon, Fenrir, Aoede, Zephyr, Sulafat). - **--output** (string) - Required - The filename for the generated audio. - **--no-timestamp** (boolean) - Optional - If set, prevents adding a timestamp to the output filename. - **--speakers** (string) - Optional - Mapping for multi-speaker audio (e.g., "Joe:Kore,Jane:Puck"). ### Request Example node scripts/tts.js "Hello world" --voice Zephyr --output welcome ### Response #### Success Response (200) - **file** (string) - The path to the generated .wav file. #### Response Example { "status": "success", "file": "audio/welcome.wav" } ``` -------------------------------- ### Basic Text-to-Speech Generation with Gemini TTS Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-tts/SKILL.md Converts a given text string into speech using the default 'Kore' voice. This is suitable for simple audio generation and quick messages. The output is a WAV file with an automatic timestamp. ```bash node scripts/tts.js "Hello, world! Have a wonderful day." ``` -------------------------------- ### Customizing Voice and Output Filename in Gemini TTS Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-tts/SKILL.md Generates speech from text using a specified voice (e.g., 'Puck') and sets a custom base name for the output audio file (e.g., 'welcome'). This allows for more tailored audio content, such as friendly or conversational messages. ```bash node scripts/tts.js "Welcome to our podcast about technology trends" --voice Puck --output welcome ``` -------------------------------- ### Gemini 3 Pro Preview Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-text/references/models.md Gemini 3 Pro Preview offers the most intelligent multimodal capabilities, suitable for complex reasoning and advanced coding tasks. It also supports a large context window. ```APIDOC ## Gemini 3 Pro Preview ### Description Gemini 3 Pro Preview is the most intelligent model, excelling in multimodal understanding and complex reasoning. It's particularly suited for advanced coding challenges and tasks requiring deep comprehension of various data types. ### Model ID `gemini-3-pro-preview` ### Best for Most intelligent multimodal, complex reasoning, vibe-coding ### Context 1,048,576 tokens input / 65,536 tokens output ### Inputs Text, images, video, audio, PDF ### Output Text ### Features Advanced multimodal understanding, agentic capabilities ### Latest update November 2025 ### Knowledge cutoff January 2025 ``` -------------------------------- ### Output Interpretation Source: https://github.com/akrindev/google-studio-skills/blob/main/skills/gemini-batch/SKILL.md Guidance on interpreting the output from the Batch API, including the format of the results JSONL file, error handling, and how to access the results. ```APIDOC ## Output Interpretation ### Results JSONL Each line in the results JSONL file contains the key and the corresponding response. ```json { "key": "your-identifier", "response": { "text": "Generated content here..." } } ``` ### Error Handling - Failed requests will include an `error` field in their response object. - Partial failures within a batch do not halt the processing of other requests. ### Result Access - Use the `--output` flag with `get_results.js` to save results to a file. - The script provides a preview of results to the console. - For programmatic processing, parse the JSONL output line by line. ```