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

# Embeddings

> Create text embeddings.

## Create Embeddings

Generate vector embeddings from text for semantic search, similarity, clustering, and retrieval.
Requests are served through the attested TEE gateway, which does not retain request bodies. Embedding
requests route to a third-party provider; no embedding model runs on a verified confidential upstream today.

```bash theme={null}
POST https://api.redpill.ai/v1/embeddings
```

## Request Body

<ParamField body="model" type="string" required>
  Embedding model id. See [Supported models](#supported-models) below.
</ParamField>

<ParamField body="input" type="string | string[]" required>
  Text to embed. Pass a single string or an array of strings for batch embedding.
</ParamField>

<ParamField body="encoding_format" type="string">
  `float` (default) or `base64`.
</ParamField>

<ParamField body="dimensions" type="integer">
  Optional output dimension count. Supported by `openai/text-embedding-3-small` and
  `openai/text-embedding-3-large`, which can return fewer dimensions than their default.
</ParamField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.redpill.ai/v1/embeddings \
    -H "Authorization: Bearer $API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/text-embedding-3-small",
      "input": "Confidential AI you can verify."
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://api.redpill.ai/v1",
  )

  resp = client.embeddings.create(
      model="openai/text-embedding-3-small",
      input="Confidential AI you can verify.",
  )
  print(len(resp.data[0].embedding))  # 1536
  ```

  ```javascript JavaScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.redpill.ai/v1",
    apiKey: process.env.API_KEY,
  });

  const resp = await client.embeddings.create({
    model: "openai/text-embedding-3-small",
    input: "Confidential AI you can verify.",
  });
  console.log(resp.data[0].embedding.length); // 1536
  ```
</CodeGroup>

### Batch input

Pass an array to embed several strings in one request. Results are returned in input order, each with
its `index`.

```bash theme={null}
curl https://api.redpill.ai/v1/embeddings \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": ["first document", "second document"]
  }'
```

## Response

```json theme={null}
{
  "object": "list",
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.0167, -0.0557, "…"] }
  ],
  "model": "openai/text-embedding-3-small",
  "usage": { "prompt_tokens": 8, "total_tokens": 8 }
}
```

## Supported models

| Model id                        | Dimensions |
| ------------------------------- | ---------- |
| `openai/text-embedding-3-small` | 1536       |
| `openai/text-embedding-3-large` | 3072       |
| `openai/text-embedding-ada-002` | 1536       |
| `qwen/qwen3-embedding-8b`       | 4096       |

If a model id returns `model_not_found`, it is not currently routed.

## Custom dimensions

`openai/text-embedding-3-small` and `openai/text-embedding-3-large` accept a `dimensions` parameter to
return shorter vectors, which reduces storage and speeds up similarity search at some cost to quality.

```bash theme={null}
curl https://api.redpill.ai/v1/embeddings \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-large",
    "input": "shorter vector",
    "dimensions": 1024
  }'
```

Keep one model and one dimension count per index. Vectors from different models are not comparable.

## Related

<CardGroup cols={2}>
  <Card title="Models" icon="list" href="/get-started/models">
    Chat and confidential models.
  </Card>

  <Card title="Trust boundary" icon="shield-halved" href="/confidential-ai/trust-boundary">
    What the gateway protects.
  </Card>
</CardGroup>
