# OpenAI Embedding Format (Embeddings)

### Introduction

Get a vector representation of a given input text that can be easily consumed by machine learning models and algorithms. For a related guide, see the [Embeddings Guide](https://platform.openai.com/docs/guides/embeddings).

!> All vector models supported by this site use this format for requests and responses, such as Google's `text-embedding-3-large`, `text-embedding-3-small`, `qwen3-embedding-8b`, and `text-embedding-v4`.

Please note:

- Some models may have a limit on the total number of input tokens

- You can use the [example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) to count the number of tokens

- For example: the text-embedding-3-small model outputs vectors with a dimension of 1536

### Create Text Embeddings:

```
curl https://beeroute.ai/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "input": "The food was delicious and the waiter...",
    "model": "text-embedding-3-small",
    "encoding_format": "float"
  }'
  
```

### Example Response:

```
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0023064255,
        -0.009327292,
        // ... (1536 floats for text-embedding-3-small)
        -0.0028842222
      ],
      "index": 0
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}
```

### Batch Create Embeddings:

```
curl https://beeroute.ai/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "input": ["The food was delicious", "The waiter was friendly"],
    "model": "text-embedding-3-small",
    "encoding_format": "float"
  }'
  
```

### Example Response:

```
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0023064255,
        // ... (1536 floats)
      ],
      "index": 0
    },
    {
      "object": "embedding",
      "embedding": [
        -0.008815289,
        // ... (1536 floats)  
      ],
      "index": 1
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 12,
    "total_tokens": 12
  }
}
```


### Error Responses
When something goes wrong with a request, the API will return an error response object with an HTTP status code in the 4XX-5XX range.

### Common Error Status Codes
- 401 Unauthorized: API key is invalid or not provided
- 400 Bad Request: Invalid request parameters, for example empty input or exceeding the token limit
- 429 Too Many Requests: API call limit exceeded
- 500 Internal Server Error: Internal server error

### Example Error Response:

```
{
  "error": {
    "message": "The input exceeds the maximum length. Please reduce the length of your input.",
    "type": "invalid_request_error",
    "param": "input",
    "code": "context_length_exceeded"
  }
}
```




