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

# Embedding & rerank models

> Text embeddings and document reranking for RAG scenarios

OpenPAI offers **embedding** and **rerank** models from the major vendors, ready to use for RAG / semantic retrieval / recommendation scenarios.

## Embedding models

### OpenAI

| Model ID                 | Dimensions              | Notes                               |
| ------------------------ | ----------------------- | ----------------------------------- |
| `text-embedding-3-small` | 1536 (reducible to 512) | Default recommendation, great value |
| `text-embedding-3-large` | 3072 (reducible to 256) | Higher retrieval quality            |
| `text-embedding-ada-002` | 1536                    | Older, for compatibility            |

### Google

| Model ID               | Dimensions       |
| ---------------------- | ---------------- |
| `text-embedding-004`   | 768              |
| `gemini-embedding-001` | 3072 (reducible) |

### Chinese / open-source

| Model ID            | Dimensions | Vendor             |
| ------------------- | ---------- | ------------------ |
| `bge-large-zh-v1.5` | 1024       | BAAI               |
| `bge-m3`            | 1024       | BAAI, multilingual |
| `text-embedding-v3` | 1024       | Tongyi Qianwen     |
| `doubao-embedding`  | 2048       | ByteDance          |

### Example

```python theme={null}
from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://openp.ai/v1")

resp = client.embeddings.create(
    model="text-embedding-3-small",
    input=["OpenPAI is an API gateway", "What is RAG?"],
)
for item in resp.data:
    print(len(item.embedding), item.embedding[:5])
```

```bash theme={null}
curl https://openp.ai/v1/embeddings \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "OpenPAI is an API gateway"
  }'
```

See the [Embeddings API](/en/api-reference/openai/embeddings).

## Rerank models

Rerank is used in RAG to re-sort the initial recall results, improving Top-K recall quality.

### Available models

| Model ID                             | Vendor | Context |
| ------------------------------------ | ------ | ------- |
| `rerank-multilingual-v3.0`           | Cohere | 4K      |
| `rerank-english-v3.0`                | Cohere | 4K      |
| `jina-reranker-v2-base-multilingual` | Jina   | 1K      |
| `bge-reranker-large`                 | BAAI   | 512     |
| `bge-reranker-v2-m3`                 | BAAI   | 8K      |

### API

OpenPAI provides a dedicated `/v1/rerank` endpoint, fully compatible with the Cohere / Jina request structure:

```bash theme={null}
curl https://openp.ai/v1/rerank \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "rerank-multilingual-v3.0",
    "query": "What is a vector database?",
    "documents": [
      "A vector database stores high-dimensional vectors for similarity search.",
      "Postgres is a relational database.",
      "FAISS and Milvus are common vector-retrieval solutions."
    ],
    "top_n": 2
  }'
```

Response:

```json theme={null}
{
  "results": [
    {"index": 0, "relevance_score": 0.98},
    {"index": 2, "relevance_score": 0.83}
  ]
}
```

See the [Rerank API](/en/api-reference/rerank/create-rerank).

## Selection guidance

| Scenario                       | Recommendation                                        |
| ------------------------------ | ----------------------------------------------------- |
| Primarily Chinese RAG          | `bge-m3` + `bge-reranker-v2-m3`                       |
| Multilingual                   | `text-embedding-3-small` + `rerank-multilingual-v3.0` |
| High-quality English retrieval | `text-embedding-3-large` + `rerank-english-v3.0`      |
| Ultra-low latency              | `text-embedding-3-small` + no rerank                  |

<Tip>Persist embedding vectors on your application side; only rerank the Top-50/100 recalls — there's no need to rerank the full dataset.</Tip>
