> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# embeddinggemma2

> Embed text, images, or one interleaved text+image record into a shared space

Embed text, images, or one interleaved text+image record into a shared space.

Exactly one of three modes is selected by which arguments are present:

* `text` only — one row per string.
* `image_input` only — one row per image.
* both — a single interleaved row; `text` must be one string whose
  `<|image|>` placeholders are filled from `image_input` in order.

## Parameters

<ParamField body="text" type="List[str] | None">
  Up to 64 UTF-8 strings. Required unless `image_input` is given.
</ParamField>

<ParamField body="image_input" type="Union[ImageInput, Sequence[ImageInput], None]">
  One image or up to 64 images (path, URL, PIL Image, or numpy array). Required unless `text` is given; capped at 8 in interleaved mode.
</ParamField>

<ParamField body="prompt_name" type="str | None">
  Task instruction prefix applied to text only — e.g. `"SearchQuery"` for queries and `"Document"` for corpus items. Omitting it still works but reduces retrieval precision.
</ParamField>

<ParamField body="truncate_dim" type="int | None">
  Matryoshka output width: 768 (default), 512, 256 or 128. Rows are re-normalized after truncation, and queries must share a dimension with the corpus they are scored against.
</ParamField>

<ParamField body="timeout" type="float | None">
  Optional timeout in seconds for the HTTP request.
</ParamField>

## Returns

Dict\[str, Any]: Dict with `features` of shape `(N, truncate_dim)`, `float32`,
L2-normalized per row (cosine similarity == dot product); `mode`
(`"text"`, `"image"` or `"interleaved"`); `model_revision`
of the backing checkpoint; and `normalized=True`.

## Example

```python theme={null}
from grid_cortex_client import CortexClient, ModelType
client = CortexClient()
query = client.run(
    ModelType.EMBEDDINGGEMMA2,
    text=["a red cup on a table"],
    prompt_name="SearchQuery",
)["features"]
corpus = client.run(
    ModelType.EMBEDDINGGEMMA2,
    image_input=["cup.jpg", "chair.jpg"],
)["features"]
int((query @ corpus.T)[0].argmax())   # cup.jpg
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.