---
title: "Embeddings"
subtitle: "Create embeddings with OpenAI, Gemini, Mistral, Fireworks, Together and Bedrock models through one API."
---

The gateway serves OpenAI's Embeddings API at `/v1/embeddings`. The model routes to any provider that embeds, on your own key or Respan's credits, and the answer comes back in OpenAI's shape.

**Pick a model:** filter by output type `embeddings` on the [model catalog](https://www.respan.ai/models), or read [Models](/docs/ai-gateway/models/overview).

## Quickstart

<Tabs>
<Tab title="cURL">
```bash
curl https://gateway.respan.ai/v1/embeddings \
  -H "Authorization: Bearer $RESPAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": ["How do I reset my password?", "Where is my order?"]
  }'
```
</Tab>
<Tab title="Python">
```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.respan.ai/v1",
    api_key=os.environ["RESPAN_API_KEY"],
)

result = client.embeddings.create(
    model="text-embedding-3-small",
    input=["How do I reset my password?", "Where is my order?"],
)
print(len(result.data[0].embedding))
```
</Tab>
<Tab title="TypeScript">
```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://gateway.respan.ai/v1",
  apiKey: process.env.RESPAN_API_KEY,
});

const result = await client.embeddings.create({
  model: "text-embedding-3-small",
  input: ["How do I reset my password?", "Where is my order?"],
});
console.log(result.data[0].embedding.length);
```
</Tab>
</Tabs>

## Options

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `model` | string | required | The embedding model. |
| `input` | string, array of strings, or array of token ids | required | The text to embed. |
| `dimensions` | integer | model default | Output size, where the model supports it. |
| `encoding_format` | string | `float` | `float` or `base64`. |

Send the request as JSON. A form-encoded body is refused with `400`.

## Providers

| Provider | Embeddings |
| --- | --- |
| OpenAI | Yes |
| Gemini | Yes |
| Mistral | Yes |
| Fireworks | Yes |
| Together | Yes |
| AWS Bedrock | Yes, Cohere and Titan embedding models |

OpenRouter models are not served for embeddings, because OpenRouter's vendor on the gateway speaks chat only.

## Respan parameters

Add `customer_identifier`, `metadata` and the other Respan parameters in the body (or `extra_body`) or the `X-Data-Respan-Params` header, as on chat. Tagging embedding calls with the same customer as their chat calls lets you see a customer's full spend. See [Respan parameters](/docs/ai-gateway/customers/respan-params).

```python
result = client.embeddings.create(
    model="text-embedding-3-small",
    input="Where is my order?",
    extra_body={"customer_identifier": "user_123"},
)
```

Embedding requests are not redacted, so an organization with [PII redaction](/docs/ai-gateway/features/pii-redaction) on is refused.

## Pricing and logs

- Each call is one trace with one `embedding` row, priced on its input tokens. The row keeps the input texts (`input_text` or `input_texts`), not the vectors.
- Before a call on Respan's credits is sent, the gateway holds credits for the input at the model's input rate.
- On Respan's credits, a model without an input price is refused with `400` before anything is held or sent.
- An answer on Respan's credits that reports no input tokens is refused with `502 no_billable_usage` and charged nothing.
- Embeddings pass the same checks as chat (limit policies, RPM, key usage cap, customer budgets), with no TPM limit and no customer rate limit.

## Next steps

- [Text](/docs/ai-gateway/modalities/text): routing and billing basics.
- [Budgets and limits](/docs/ai-gateway/spend/budgets-and-limits): cap spend per key or customer.
- [Respan parameters](/docs/ai-gateway/customers/respan-params): tag calls with a customer and metadata.
- [Logs](/docs/ai-gateway/observability/logs-and-traces): find each embedding row.
