# Embeddings and Rerank

> Generate embeddings and rerank documents through LLMoxy.

## Embeddings

OpenAI-compatible embedding requests use `POST /v1/embeddings`.

```bash
curl https://llmoxy.com/v1/embeddings \
  -H "Authorization: Bearer <LLMOXY_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": ["first document", "second document"],
    "encoding_format": "float"
  }'
```

Common fields:

| Field | Description |
| --- | --- |
| `model` | Required. Embedding model ID. |
| `input` | String or array of strings. |
| `encoding_format` | Can be `float` or `base64` when supported by upstream. |
| `dimensions` | Supported models can specify output dimensions. |
| `user` | Optional tracking identifier. |

Gemini-style embedding requests can use:

```txt
POST /v1/engines/{model}/embeddings
```

## Rerank

Use `POST /v1/rerank` to call Jina, Cohere, and other rerank models.

```bash
curl https://llmoxy.com/v1/rerank \
  -H "Authorization: Bearer <LLMOXY_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "jina-reranker-v2-base-multilingual",
    "query": "What is LLMoxy?",
    "documents": [
      "LLMoxy is an LLM gateway.",
      "A database stores rows."
    ],
    "top_n": 1,
    "return_documents": true
  }'
```

Common fields:

| Field | Description |
| --- | --- |
| `model` | Required. Rerank model ID. |
| `query` | Query text. |
| `documents` | Array of strings or document objects. |
| `top_n` | Maximum number of ranked results to return. |
| `return_documents` | Whether to include original documents in the response. |

This is the markdown version of https://en.llmoxy.com/docs/api-reference/embeddings-rerank.
