Gemini Embeddings 2: one vector space for text, images and video

Google put Gemini Embeddings 2 into public preview. The docs read like another endpoint for your vector database, and there is a bigger shift underneath. For the last few years we have been stitching models together: one for text, one for CLIP-based image search, maybe a whisper-based one for audio. The pipelines that came out of that were bloated and easy to break.

The unified vector space in Gemini Embeddings 2

The one-model pitch holds up this time. Gemini Embeddings 2 is natively multimodal, so text, PDFs, images, audio and video all land in the same vector space. For a Retrieval-Augmented Generation setup on a high-traffic WordPress site that removes a whole layer of work: no more aligning separate embedding spaces so a text query can find the image that matches it.

The fine print is where preview releases live, and the current limits are tight:

  • Text: 8192 tokens, roughly 6,000 words.
  • Images: 6 per request, PNG or JPEG.
  • Video: 2 minutes, MP4 or MOV.
  • Audio: 80 seconds, MP3 or WAV.

Integrating Gemini Embeddings 2 in WordPress

Most tutorials do this in Python inside jupyter notebooks. That is fine for a data scientist, less useful when the thing has to run in production. In a custom WordPress plugin you are not going to stand up a Python environment on shared hosting or a small VPS. You are going to call the Google AI Studio API with wp_remote_post.

Below is a bare-bones text embedding request through the WordPress HTTP API. For the wider picture, I have a guide on optimizing WordPress for AI search.

<?php
/**
 * Generate an embedding for text using Gemini Embeddings 2.
 *
 * @param string $text The content to embed.
 * @return array|WP_Error The vector array or error object.
 */
function bbioon_get_gemini_embedding( $text ) {
    $api_key = 'YOUR_GOOGLE_AI_KEY';
    $url     = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-embedding-2:embedContent?key=' . $api_key;

    $body = [
        'model'   => 'models/gemini-embedding-2',
        'content' => [
            'parts' => [
                ['text' => $text]
            ]
        ]
    ];

    $response = wp_remote_post( $url, [
        'headers' => [ 'Content-Type' => 'application/json' ],
        'body'    => wp_json_encode( $body ),
        'timeout' => 15,
    ]);

    if ( is_wp_error( $response ) ) {
        return $response;
    }

    $data = json_decode( wp_remote_retrieve_body( $response ), true );
    return $data['embedding']['values'] ?? [];
}

Why vector similarity still fails

A better model does not fix a bad pipeline. Even with Gemini Embeddings 2, plain cosine similarity keeps missing niche search terms, which I have gone into at length in why vector similarity fails in complex RAG setups. You still want a hybrid setup: these multimodal embeddings next to a traditional keyword index such as BM25.

If Gemini Embeddings 2 is eating your dev hours, I can take it off your plate. I have been wrestling with WordPress since the 4.x days.

Where to start

Semantic search across audio and video in one vector space is worth having on a content-heavy site. Try the preview now, and keep the production path wrapped in real error handling, because Google changes v1beta specs without much warning. Read the official Gemini API documentation for the current schema before you plan a large refactor.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.