google-gemini-embeddings

jezweb/claude-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/jezweb/claude-skills --skill google-gemini-embeddings
0 commentsdiscussion
summary

$22

skill.md

Google Gemini Embeddings

Complete production-ready guide for Google Gemini embeddings API

This skill provides comprehensive coverage of the gemini-embedding-001 model for generating text embeddings, including SDK usage, REST API patterns, batch processing, RAG integration with Cloudflare Vectorize, and advanced use cases like semantic search and document clustering.


Table of Contents

  1. Quick Start
  2. gemini-embedding-001 Model
  3. Basic Embeddings
  4. Batch Embeddings
  5. Task Types
  6. RAG Patterns
  7. Error Handling
  8. Best Practices

1. Quick Start

Installation

Install the Google Generative AI SDK:

npm install @google/genai@^1.37.0

For TypeScript projects:

npm install -D typescript@^5.0.0

Environment Setup

Set your Gemini API key as an environment variable:

export GEMINI_API_KEY="your-api-key-here"

Get your API key from: https://aistudio.google.com/apikey

First Embedding Example

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

const response = await ai.models.embedContent({
  model: 'gemini-embedding-001',
  content: 'What is the meaning of life?',
  config: {
    taskType: 'RETRIEVAL_QUERY',
    outputDimensionality: 768
  }
});

console.log(response.embedding.values); // [0.012, -0.034, ...]
console.log(response.embedding.values.length); // 768

Result: A 768-dimension embedding vector representing the semantic meaning of the text.


2. gemini-embedding-001 Model

Model Specifications

Current Model: gemini-embedding-001 (stable, production-ready)

  • Status: Stable
  • Experimental: gemini-embedding-exp-03-07 (deprecated October 2025, do not use)

Dimensions

The model supports flexible output dimensionality using Matryoshka Representation Learning:

Dimension Use Case Storage Performance
768 Recommended for most use cases Low Fast
1536 Balance between accuracy and efficiency Medium Medium
3072 Maximum accuracy (default) High Slower
128-3071 Custom (any value in range) Variable Variable

Default: 3072 dimensions Recommended: 768, 1536, or 3072 for optimal performance

Context Window

  • Input Limit: 2,048 tokens per text
  • Input Type: Text only (no images, audio, or video)

Rate Limits

Tier RPM TPM RPD Requirements
Free 100 30,000 1,000 No billing account
Tier 1 3,000 1,000,000 - Billing account linked
Tier 2 5,000 5,000,000 - $250+ spending, 30-day wait
Tier 3 10,000 10,000,000 - $1,000+ spending, 30-day wait

RPM = Requests Per Minute TPM = Tokens Per Minute RPD = Requests Per Day

Output Format

{
  embedding: {
    values: number[] // Array of floating-point numbers
  }
}

3. Basic Embeddings

SDK Approach (Node.js)

Single text embedding:

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

const response = await ai.models.embedContent({
  model: 'gemini-embedding-001',
  content: 'The quick brown fox jumps over the lazy dog',
  config: {
    taskType: 'SEMANTIC_SIMILARITY',
    outputDimensionality: 768
  }
});

console.log(response.embedding.values);
// [0.00388, -0.00762, 0.01543, ...]

Fetch Approach (Cloudflare Workers)

For Workers/edge environments without SDK support:

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const apiKey = env.GEMINI_API_KEY;
    const text = "What is the meaning of life?";

    const response = await fetch(
      'https://generativelanguage.googleapis.com/v1beta/models/gemini-embedding-001:embedContent',
      {
        method: 'POST',
        headers: {
          'x-goog-api-key': apiKey,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          content: {
            parts: [{ text }]
          },
          taskType: 'RETRIEVAL_QUERY',
          outputDimensionality: 768
        })
      }
    );

    const data = await response.json();

    // Response format:
    // {
    //   embedding: {
    //     values: [0.012, -0.034, ...]
    //   }
    // }

    return new Response(JSON.stringify(data), {
      headers: { 'Content-Type': 'application/json' }
    });
  }
};

Response Parsing

interface EmbeddingResponse {
  embedding: {
    values: number[];
  };
}

const response: EmbeddingResponse = await ai.models.embedContent({
  model: 'gemini-embedding-001',
  content: 'Sample text',
  config: { taskType: 'SEMANTIC_SIMILARITY' }
});

const embedding: number[] = response.embedding.values;
const dimensions: number = embedding.length; // 3072 by default

Normalization Requirement

⚠️ CRITICAL: When using dimensions other than 3072, you MUST normalize embeddings before computing similarity. Only 3072-dimensional embeddings are pre-normalized by the API.

Why This Matters: Non-normalized embeddings have varying magnitudes that distort cosine similarity calculations, leading to incorrect search results.

Normalization Helper Function:

/**
 * Normalize embedding vector for accurate similarity calculations.
 * REQUIRED for dimensions other than 3072.
 *
 * @param vector - Embedding values from API response
 * @returns Normalized vector (unit length)
 */
function normalize(vector: number[]): number[] {
  const magnitude = Math.sqrt(
    vector.reduce((sum, val) => sum + val * val, 0)
  );
  return vector.map(val =>
how to use google-gemini-embeddings

How to use google-gemini-embeddings on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add google-gemini-embeddings
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/jezweb/claude-skills --skill google-gemini-embeddings

The skills CLI fetches google-gemini-embeddings from GitHub repository jezweb/claude-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/google-gemini-embeddings

Reload or restart Cursor to activate google-gemini-embeddings. Access the skill through slash commands (e.g., /google-gemini-embeddings) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.663 reviews
  • Valentina Brown· Dec 28, 2024

    google-gemini-embeddings has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Shikha Mishra· Dec 24, 2024

    Registry listing for google-gemini-embeddings matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Sakura Gonzalez· Dec 24, 2024

    Solid pick for teams standardizing on skills: google-gemini-embeddings is focused, and the summary matches what you get after install.

  • Noah Sethi· Dec 24, 2024

    google-gemini-embeddings fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Noah Torres· Dec 12, 2024

    I recommend google-gemini-embeddings for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Diego Park· Dec 4, 2024

    google-gemini-embeddings reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Mateo Flores· Nov 27, 2024

    Useful defaults in google-gemini-embeddings — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Soo Okafor· Nov 23, 2024

    Registry listing for google-gemini-embeddings matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Carlos Smith· Nov 19, 2024

    Solid pick for teams standardizing on skills: google-gemini-embeddings is focused, and the summary matches what you get after install.

  • Yash Thakker· Nov 15, 2024

    google-gemini-embeddings reduced setup friction for our internal harness; good balance of opinion and flexibility.

showing 1-10 of 63

1 / 7