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

# Embeddings

The SambaNova Embeddings API generates vector representations (embeddings) of input text, facilitating tasks such as semantic similarity analysis, clustering, search optimization, and retrieval-augmented generation (RAG). This API enables developers to integrate advanced AI capabilities into their applications by transforming textual data into structured numerical representations.

## Endpoint

The API provides an endpoint to generate embedding vectors for input text.

### Request

```python
POST https://api.sambanova.ai/v1/embeddings
```

<Note>
  For SambaStack, developers should check with their system administrator for the correct URL.
</Note>

### Request body parameters

| Parameter | Type                       | Description                                                             | Required |
| :-------- | :------------------------- | :---------------------------------------------------------------------- | :------- |
| `input`   | String or array of strings | The input text to be embedded. Must not exceed the model's token limit. | Yes      |
| `model`   | String                     | The model used to generate embeddings (e.g., `E5-Mistral-7B-Instruct`). | Yes      |

This API ensures efficient embedding generation, supporting multiple input formats while enforcing model constraints.

## Example request

The following example demonstrates how to send a request to the SambaCloud Embeddings API using curl.

### CURL request

```python CURL request
curl https://api.sambanova.ai/v1/embeddings \
  -H "Authorization: Bearer <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "The curious fox dashed through the golden field.",
    "model": "E5-Mistral-7B-Instruct"
  }'
```

### Example response

```python Example response
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [0.00333473, -0.0223934397434, ..., -0.013434322],
      "index": 0
    }
  ],
  "model": "E5-Mistral-7B-Instruct",
  "usage": {
    "prompt_tokens": 28,
    "total_tokens": 28
  }
}
```

### Response properties

The API response consists of the following properties:

| Property | Type   | Description                                                        |
| :------- | :----- | :----------------------------------------------------------------- |
| `object` | String | The type of response, always `list`.                               |
| `data`   | Array  | A list of embedding objects.                                       |
| `model`  | String | The name of the model used to generate embeddings.                 |
| `usage`  | Object | Token usage statistics for the request, including `prompt_tokens`. |

### Embedding object

| Property    | Type    | Description                                            |
| :---------- | :------ | :----------------------------------------------------- |
| `object`    | String  | Always `embedding`.                                    |
| `embedding` | Array   | The embedding vector, represented as a list of floats. |
| `index`     | Integer | The index of the embedding in the list of embeddings.  |

### Error handling

See [API error codes](/api-reference/using-the-api/api-error-codes) page for more information.

| Error type            | HTTP code | Description                                                                         | Code                     |
| :-------------------- | :-------- | :---------------------------------------------------------------------------------- | :----------------------- |
| Invalid request error | 400       | An issue with the request parameters, e.g., model not compatible or input too long. | `invalid_request_error`  |
| Authentication error  | 401       | The provided API key is invalid.                                                    | `invalid_authentication` |
| Rate limit exceeded   | 429       | Request quota exceeded.                                                             | `insufficient_quota`     |
| Request timeout       | 408       | The request timed out.                                                              | `request_timeout`        |

## **Example error response**

```python Example error response
{
  "error": {
    "message": "Model 'model_name' does not support embeddings.",
    "type": "invalid_request_error",
    "param": "model",
    "code": "model_not_compatible"
  }
}
```
