Skip to content
Cloudflare Docs
Google logo

embeddinggemma-300m

Text EmbeddingsGoogle
@cf/google/embeddinggemma-300m

EmbeddingGemma is a 300M parameter, state-of-the-art for its size, open embedding model from Google, built from Gemma 3 (with T5Gemma initialization) and the same research and technology used to create Gemini models. EmbeddingGemma produces vector representations of text, making it well-suited for search and retrieval tasks, including classification, clustering, and semantic similarity search. This model was trained with data in 100+ spoken languages.

Usage

export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
// Can be a string or array of strings]
const stories = [
"This is a story about an orange cloud",
"This is a story about a llama",
"This is a story about a hugging emoji",
];
const embeddings = await env.AI.run(
"@cf/google/embeddinggemma-300m",
{
text: stories,
}
);
return Response.json(embeddings);
},
} satisfies ExportedHandler<Env>;

Parameters

* indicates a required field

Input

  • text one of required

    • 0 string min 1

      The text to embed

    • 1 array

      Batch of text values to embed

      • items string min 1

        The text to embed

Output

  • shape array

    • items number

  • data array

    Embeddings of the requested text values

    • items array

      Floating point embedding representation shaped by the embedding model

      • items number

API Schemas

The following schemas are based on JSON Schema

{
"type": "object",
"properties": {
"text": {
"oneOf": [
{
"type": "string",
"description": "The text to embed",
"minLength": 1
},
{
"type": "array",
"description": "Batch of text values to embed",
"items": {
"type": "string",
"description": "The text to embed",
"minLength": 1
},
"maxItems": 100
}
]
}
},
"required": [
"text"
]
}