> For the complete documentation index, see [llms.txt](https://docs.parasail.io/parasail-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.parasail.io/parasail-docs/api-reference/embeddings.md).

# Embeddings

Generate vector embeddings for text using open-source embedding models. The API is OpenAI-compatible—use the same `client.embeddings.create` interface.

## Endpoint

```
POST https://api.parasail.io/v1/embeddings
```

## Authentication

Pass your API key in the `Authorization` header:

```
Authorization: Bearer <PARASAIL_API_KEY>
```

The OpenAI SDK reads this from the `api_key` argument. See [Authentication](/parasail-docs/api-reference/authentication.md) for how to create and store a key.

## Request

### Python (OpenAI SDK)

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.parasail.io/v1",
    api_key=os.environ["PARASAIL_API_KEY"],
)

response = client.embeddings.create(
    model="parasail-ai/GritLM-7B-vllm",
    input="Parasail provides affordable cloud GPUs for AI inference.",
    encoding_format="base64"
)

print(response.data[0].embedding[:5])
```

### cURL

```bash
curl https://api.parasail.io/v1/embeddings \
  -H "Authorization: Bearer $PARASAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "parasail-ai/GritLM-7B-vllm",
    "input": "Parasail provides affordable cloud GPUs for AI inference.",
    "encoding_format": "float"
  }'
```

## Parameters

| Parameter         | Type            | Default  | Description                                                          |
| ----------------- | --------------- | -------- | -------------------------------------------------------------------- |
| `model`           | string          | required | Embedding model ID (for example, `parasail-ai/GritLM-7B-vllm`)       |
| `input`           | string or array | required | Text to embed. Pass an array to embed multiple inputs in one request |
| `encoding_format` | string          | "float"  | `"float"` or `"base64"` (recommended for smaller payloads)           |

These fields follow the OpenAI schema. For exhaustive field semantics, see the [OpenAI embeddings reference](https://platform.openai.com/docs/api-reference/embeddings/create).

## Response

A successful request returns a list of embedding objects. With one input string, `data` contains a single embedding:

```json
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, -0.0091, 0.0145, "..."]
    }
  ],
  "model": "parasail-ai/GritLM-7B-vllm",
  "usage": {
    "prompt_tokens": 12,
    "total_tokens": 12
  }
}
```

| Field              | Description                                                                      |
| ------------------ | -------------------------------------------------------------------------------- |
| `data[].embedding` | The vector (array of floats, or a base64 string when `encoding_format="base64"`) |
| `data[].index`     | Position of this embedding in the input array                                    |
| `usage`            | Prompt and total token counts                                                    |

When `input` is an array, `data` contains one object per input, ordered by `index`.

## Available embedding models

| Model                 | HuggingFace ID                      |
| --------------------- | ----------------------------------- |
| GritLM                | `parasail-ai/GritLM-7B-vllm`        |
| GTE-Qwen2-7B-Instruct | `Alibaba-NLP/gte-Qwen2-7B-instruct` |

Any embedding model on HuggingFace can be used with dedicated or batch endpoints.

## Error responses

Errors use OpenAI-compatible status codes and a JSON body with an `error` object (`message`, `type`, `code`).

| Status Code | Description                                                                     |
| ----------- | ------------------------------------------------------------------------------- |
| `400`       | Malformed request—invalid JSON, missing `input`, or unsupported parameter value |
| `401`       | Missing or invalid API key                                                      |
| `403`       | API key lacks access to the requested model                                     |
| `404`       | Model or endpoint not found                                                     |
| `429`       | Rate limit or quota exceeded—back off and retry                                 |
| `500`       | Internal server error—retry with exponential backoff                            |

## Tips

* Use `encoding_format="base64"` to reduce output file sizes, especially for batch processing.
* For large-scale embedding generation, use [batch processing](/parasail-docs/products/quickstart.md) at 50% off serverless pricing.

## Next steps

* [RAG and embeddings use case](/parasail-docs/use-cases/rag-embeddings.md)—RAG pipeline guide
* [Batch embedding models](/parasail-docs/products/quickstart.md#batch-embedding-models)—batch embedding generation
* [Model selection](/parasail-docs/guides/model-recommendations.md#evaluate-candidates)—embedding model evaluation
* [Chat completions API](/parasail-docs/api-reference/chat-completions.md)—endpoint compatibility matrix and base URL
