Live
OpenShift 5 observability adds autonomous troubleshooting with LightspeedPartitioned __cf_bm cookie enables Bot Management continuity in third‑party iframesAI Production Architecture: Lessons from Microsoft Ignite’s Frontier TransformationBorderless Lakehouse Redefines Data Access for AI AgentsDynamic Model Switching in Gemini 4 Cuts Coding Agent Latency and Token CostRunning SGLang‑Neuron on AWS Trainium: Architecture and Ops GuideTerraform v5.29.0 adds full namespace control for Cloudflare AI SearchBeyond Token Pricing: Managing Amazon Bedrock Cost per TaskOpenShift 5 observability adds autonomous troubleshooting with LightspeedPartitioned __cf_bm cookie enables Bot Management continuity in third‑party iframesAI Production Architecture: Lessons from Microsoft Ignite’s Frontier TransformationBorderless Lakehouse Redefines Data Access for AI AgentsDynamic Model Switching in Gemini 4 Cuts Coding Agent Latency and Token CostRunning SGLang‑Neuron on AWS Trainium: Architecture and Ops GuideTerraform v5.29.0 adds full namespace control for Cloudflare AI SearchBeyond Token Pricing: Managing Amazon Bedrock Cost per Task
Cloudflare

EmbeddingGemma 2 on Workers AI: Multimodal embeddings for cloud‑native pipelines

AI SummaryPowered by AI

EmbeddingGemma 2 is now offered as a model in Cloudflare Workers AI. The model adds multimodal, multilingual, and configurable‑size embeddings that let engineers index text, images, video, and audio with a single vector space.

Cloudflare has added the @cf/google/embeddinggemma-2 model to the Workers AI catalog. The change introduces a multimodal embedding service that accepts text, images, video, and audio in a single request and returns a 768‑dimensional vector (or a reduced‑size variant) that can be used for search, classification, clustering, or similarity matching.

New capabilities and API surface

  • Multimodal input: Any combination of text, image, video, or audio can be supplied in the messages array. Images, video, and audio are provided as base64‑encoded data URIs.
  • Multilingual and code support: The model claims coverage of more than 100 languages and improved code retrieval compared with the original EmbeddingGemma.
  • Adjustable vector size: The dimensions parameter can be set to 128, 256, or 512, trading a small amount of quality for reduced storage and bandwidth.
  • Long context window: An 8,192‑token window is shared across all content in a single request, allowing larger documents or combined media to be embedded together.
  • Task prefixes: Short instructions such as task: search result | query: … can be prepended to steer the embedding toward a specific downstream use case.
const response = await env.AI.run("@cf/google/embeddinggemma-2", {
  messages: [
    [{ role: "user", content: [
      { type: "text", text: "Waterproof running shoes." },
      { type: "image_url", image_url: { url: imageDataUri } }
    ]}],
    [{ role: "user", content: "task: search result | query: waterproof shoes for trail running" }]
  ]
});

Architectural and operational considerations

EmbeddingGemma 2 runs inside the Workers AI runtime, so the usual Workers deployment model applies. Engineers should treat the model as a stateless function that receives a request payload and returns a vector. When using reduced dimensions, storage costs for vector databases drop proportionally, but the trade‑off in retrieval quality should be evaluated in the context of the target application.

The 8,192‑token limit means that very large media files may need to be chunked before embedding. Chunking strategy will affect both latency and vector consistency, so monitoring request latency and token usage is advisable.

Security and data handling notes

All media are transmitted as base64 data URIs inside the request body. Practitioners should ensure that any sensitive content is appropriately protected before encoding, as the payload travels through the Workers AI service. Access to the Workers AI model is governed by the same Cloudflare account permissions that protect other Workers resources, so role‑based access control should be reviewed to limit who can invoke the model.

Because the model returns raw vectors, downstream storage (e.g., vector databases) must be secured according to the organization’s data‑at‑rest policies. Encryption at rest and network‑level controls remain the responsibility of the consuming service.

Related CloudNinjas coverage: AI engineering.

What This Means For Practitioners

EmbeddingGemma 2 gives AI and platform teams a single, Cloudflare‑native endpoint for generating embeddings across heterogeneous media. Engineers can replace separate text‑only and image‑only pipelines with a unified call, simplifying architecture and reducing operational overhead. When adopting the model, evaluate dimension size against storage budgets, design chunking for large inputs to stay within the token window, and enforce strict access controls around the Workers AI invocation to protect any proprietary media being embedded.

Originally published atCloudflare Developer Platform