Turn text into understanding.

Both platforms offer state-of-the-art embeddings. OpenAI offers text-embedding-3-small and text-embedding-3-large. Google offers gemini-embedding-exp-03-07. Competition raises quality and lowers prices, which benefits developers.

Start here: OpenAI’s power move

Two columns comparing text-embedding-3-small and text-embedding-3-large on pages per dollar, dimensions and MTEB score.

text-embedding-3-small processes 62,500 pages per dollar.

The model is fast, cheap, and accurate enough for most projects, which is why most start here. It handles 8,192 tokens, delivers 1,536 dimensions, and scores 62.3% on MTEB benchmarks.

If you want more precision, text-embedding-3-large doubles the dimensions to 3,072 and raises performance to 64.6%. The cost increases to $0.13 per million tokens, and the model still processes 9,615 pages per dollar. Choose between volume and accuracy.

from openai import OpenAI
client = OpenAI()

# One line. One embedding. Done.
embedding = client.embeddings.create(
    input="Your text here",
    model="text-embedding-3-small"
).data[0].embedding

Dimensions are adjustable. If you need smaller vectors, add one parameter. Storage costs fall and speed increases, and accuracy holds up well.

# Compress to 512 dimensions
compressed = client.embeddings.create(
    input="Your text here",
    model="text-embedding-3-small",
    dimensions=512  # Magic happens here
).data[0].embedding

Gemini’s counter-strike

Three tiles showing Gemini embedding sizes of 768, 1,536 and 3,072 dimensions, with a lock noting that you choose upfront.

Google built a different model.

gemini-embedding-exp-03-07 targets multilingual use, code comprehension, and retrieval. The model accepts 8,192 tokens and offers three dimension options: 768, 1,536, or 3,072. You choose the dimension upfront, and you cannot compress later.

Rate limits are tight, and the model is experimental. Its performance is state-of-the-art across the benchmarks Google reports. When accuracy matters most, when languages mix, or when code meets prose, Gemini fits well.

For production, use text-embedding-004. It is stable and proven. It is limited to 2,048 tokens and 768 dimensions, but it is reliable at 1,500 requests per minute and outperforms comparable models. It is the workhorse for Google Cloud users.

import google.generativeai as genai

# Flexible dimensions with experimental model
result = genai.GenerativeModel('gemini-embedding-exp-03-07').embed_content(
    content="Your multilingual text here",
    task_type="RETRIEVAL_DOCUMENT",
    output_dimensionality=1536
)

Real implementation patterns

A pipeline in which hundreds of documents go into one batch request, then an embeddings API, and come out as vectors.

Batch processing saves money.

Embed hundreds of documents at a time, not one. OpenAI accepts arrays of up to 2,048 elements per request. Gemini handles batches through Vertex AI. Batching saves time, cuts costs, keeps latency manageable, and lets your pipeline scale.

def intelligent_batch_embed(texts, model="text-embedding-3-small"):
    embeddings = []
    batch_size = 100 if model.startswith("text-embedding") else 50
    
    for i in range(0, len(texts), batch_size):
        batch = texts[i:i+batch_size]
        response = client.embeddings.create(input=batch, model=model)
        embeddings.extend([d.embedding for d in response.data])
    
    return embeddings

Semantic search requires a strategy.

Store embeddings in purpose-built databases such as Pinecone, Weaviate, Qdrant, and ChromaDB. Each optimizes differently. Pinecone excels at scale, Weaviate integrates broadly, Qdrant runs anywhere, and ChromaDB stays simple. Choose based on your constraints.

For the search itself, cosine similarity usually works best. Dot product sometimes suffices, and Euclidean distance rarely helps. The largest gains come before the similarity calculation: index properly, partition intelligently, and cache aggressively.

Advanced patterns that actually work

Two developers discussing a combined approach at a whiteboard, showing how teams pair different models for different content.

Hybrid strategies multiply power.

Use OpenAI for general text and Gemini for code blocks, then average the results for consensus. The overhead pays off when accuracy matters.

Dynamic dimensions solve real problems.

Start with high dimensions during development and measure actual performance. Then reduce dimensions gradually until you find the best tradeoff. OpenAI makes this easy with its dimensions parameter. Gemini requires you to choose upfront, so prototype carefully.

Cross-language search removes language barriers.

Gemini’s multilingual strength helps here. Embed English queries, search Spanish documents, and find Chinese results. The semantic space spans languages, so one model gives you unified understanding.

Cost reality check

Horizontal bars comparing embedding costs of $0.02 and $0.13 per million tokens with Gemini offering its first 1 billion characters free.

OpenAI pricing favors volume:

  • text-embedding-3-small: $0.02 per million tokens
  • text-embedding-3-large: $0.13 per million tokens
  • Adjust dimensions to reduce storage costs
  • Batch as many requests as possible

Gemini pricing rewards commitment:

  • The first 1 billion characters per month are free (experimental)
  • Production models follow Google Cloud pricing
  • Rate limits enforce reasonable usage
  • Enterprise agreements support larger scale

Performance truth

An analyst comparing two printed result charts with a pen, showing that your own data matters more than benchmarks.

MTEB benchmarks tell part of the story. Real applications tell the rest. text-embedding-3-large achieves 64.6%. gemini-embedding-exp-03-07 claims state-of-the-art results across multiple dimensions, which might be more impressive.

Your data matters more than benchmarks. Your use case outweighs evaluations, and your constraints define success. Test both models, measure everything, and let the results guide your decision.

Implementation wisdom

A long document split into three overlapping chunks with shaded overlaps, showing how to chunk within an 8,192 token limit.

Token limits shape architecture. A limit of 8,192 tokens seems generous until you process legal documents. Chunk thoughtfully, maintain context, and overlap slightly. Do not break chunks mid-sentence. Consider sliding windows for long texts.

Plan for errors. APIs fail, networks hiccup, and rate limits hit. Implement exponential backoff and add jitter to prevent thundering herds. Log everything, monitor patterns, and alert on anomalies.

Embedding drift is real. Models update, vectors shift, and similarities change. Document your model versions, timestamp your embeddings, plan re-embedding cycles, and version your vector databases.

Task parameters matter. Gemini’s RETRIEVAL_DOCUMENT and RETRIEVAL_QUERY task types change results. OpenAI optimizes automatically, but understanding the options helps. Match task types to use cases, because consistency beats optimization.

The decision framework

A decision tree that sends you to OpenAI for speed and cost, Gemini for languages and code, or both when accuracy is paramount.

Choose OpenAI when speed matters most, English dominates your content, you need to control costs, dimensions must flex, stability matters more than features, or you already use GPT models.

Choose Gemini when your languages vary, code understanding is critical, you work in Google’s ecosystem, experimental features appeal to you, or state-of-the-art performance justifies the restrictions.

Choose both when accuracy is paramount, your budget allows, you have different content types, redundancy matters, or you need validation.

Start now

A developer starting a new project at a sunlit desk, showing the advice to pick one model, build something and measure it.

Pick one model, build something, and measure the results. Iterate. The best embedding model is the one you ship with.

# Your journey starts here
text = "What matters most to your users?"
embedding = get_embedding(text)
# Now find what's similar

A simple start can produce strong results. Try my version of semantic analysis using embeddings.

Start building. Text becomes vectors, vectors become insights, and insights become value.

This is how modern search works, how AI understands, and how you compete.

Build it today.