skills/gemini-embeddings/SKILL.md
Generate text embeddings using Gemini Embedding API via scripts/. Use for creating vector representations of text, semantic search, similarity matching, clustering, and RAG applications. Triggers on "embeddings", "semantic search", "vector search", "text similarity", "RAG", "retrieval".
npx skillsauth add akrindev/google-studio-skills gemini-embeddingsInstall 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.
Generate high-quality text embeddings for semantic search, similarity analysis, clustering, and RAG (Retrieval Augmented Generation) applications through executable scripts.
Use this skill when you need to:
Purpose: Generate embeddings and calculate similarity
When to use:
Key parameters:
| Parameter | Description | Example |
|-----------|-------------|---------|
| texts | Text(s) to embed (required) | "Your text here" |
| --model, -m | Embedding model | gemini-embedding-001 |
| --task, -t | Task type | SEMANTIC_SIMILARITY |
| --dim, -d | Output dimensionality | 768, 1536, 3072 |
| --similarity, -s | Calculate pairwise similarity | Flag |
| --json, -j | Output as JSON | Flag |
Output: Embedding vectors or similarity scores
node scripts/embed.js "What is the meaning of life?"
# 1. Generate embedding for query
node scripts/embed.js "best practices for coding" --task RETRIEVAL_QUERY > query.json
# 2. Generate embeddings for documents (batch)
node scripts/embed.js "Coding best practices include version control" "Clean code is essential" --task RETRIEVAL_DOCUMENT > docs.json
# 3. Compare and find most similar (calculate similarity separately)
RETRIEVAL_QUERY, RETRIEVAL_DOCUMENTnode 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
768, 1536, or 3072 (default)# 1. Generate embeddings for multiple documents
node scripts/embed.js "Machine learning is AI" "Deep learning is a subset" "Neural networks power AI" --json > embeddings.jsonl
# 2. Process embeddings with clustering algorithm (your code)
# Use scikit-learn, KMeans, etc.
CLUSTERING# 1. Create document embeddings (one-time setup)
node scripts/embed.js "Document 1 content" "Document 2 content" --task RETRIEVAL_DOCUMENT --dim 1536
# 2. For each query, find similar documents
node scripts/embed.js "User query here" --task RETRIEVAL_QUERY
# 3. Use retrieved documents in prompt to LLM (gemini-text)
node skills/gemini-text/scripts/generate.js "Context: [retrieved docs]. Answer: [user query]"
node scripts/embed.js "Text to process" --json
# 1. Create JSONL with documents
echo '{"text": "Document 1"}' > docs.jsonl
echo '{"text": "Document 2"}' >> docs.jsonl
# 2. Process with script or custom code
python3 << 'EOF'
import json
from google import genai
client = genai.Client()
texts = []
with open("docs.jsonl") as f:
for line in f:
texts.append(json.loads(line)["text"])
response = client.models.embed_content(
model="gemini-embedding-001",
contents=texts,
task_type="RETRIEVAL_DOCUMENT"
)
embeddings = [e.values for e in response.embeddings]
print(f"Generated {len(embeddings)} embeddings")
EOF
| Task Type | Best For | When to Use |
|-----------|----------|-------------|
| SEMANTIC_SIMILARITY | Comparing text similarity | General comparison tasks |
| RETRIEVAL_DOCUMENT | Embedding documents | Storing documents for retrieval |
| RETRIEVAL_QUERY | Embedding search queries | Finding similar documents |
| CLASSIFICATION | Text classification | Categorizing text |
| CLUSTERING | Grouping similar texts | Document clustering |
| Dimensions | Use Case | Trade-off | |------------|----------|-----------| | 768 | High-volume, real-time | Lower accuracy, faster | | 1536 | Balanced performance | Good accuracy/speed balance | | 3072 | Highest accuracy | Slower, more storage |
| Score | Interpretation | |-------|---------------| | 0.8 - 1.0 | Very similar (likely duplicates) | | 0.6 - 0.8 | Highly related (same topic) | | 0.4 - 0.6 | Moderately related | | 0.2 - 0.4 | Weakly related | | 0.0 - 0.2 | Unrelated |
Pairwise Similarity:
'What is the meaning of life?...' <-> 'What is the purpose of existence?...': 0.8742
'What is the meaning of life?...' <-> 'How do I bake a cake?...': 0.1234
[[0.123, -0.456, 0.789, ...], [0.234, -0.567, 0.890, ...]]
npm install @google/genai@latest dotenv@latest
pip install numpy
--similarity flag--dim parameter# 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
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".