---
title: "Create embeddings"
description: "Embeds texts, or media for models that take it, and returns one vector per item. Follows OpenAI's Embeddings API. Send JSON: a form is refused with `400`."
---

<a id="playground-button:docs/apis/gateway/create-embeddings"></a>

**POST** `https://gateway.respan.ai/v1/embeddings`

Embeds texts, or media for models that take it, and returns one vector per item. Follows OpenAI's Embeddings API. Send JSON: a form is refused with `400`.

## Servers

`https://gateway.respan.ai`: Respan gateway

## Authentication

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


## Request body

A request body is required.

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | Additional properties are allowed |
| `model` | `string` | Required in parent | The embedding model, such as `text-embedding-3-small`. |
| `input` | `any` | Required in parent | A text, an array of texts, an array of token ids, or an array of `{"content": [parts]}` objects for media. One vector comes back per item. |
| `dimensions` | `integer` | Optional | Output size, where the model supports it. |
| `encoding_format` | `string` | Optional | `float` by default.<br />Allowed: `"float"`, `"base64"` |
| `input_type` | `string` | Optional | What the vectors are for, where the model embeds differently for it.<br />Allowed: `"query"`, `"document"`, `"classification"`, `"clustering"` |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "type": "object",
  "required": [
    "model",
    "input"
  ],
  "properties": {
    "model": {
      "type": "string",
      "description": "The embedding model, such as `text-embedding-3-small`."
    },
    "input": {
      "description": "A text, an array of texts, an array of token ids, or an array of `{\"content\": [parts]}` objects for media. One vector comes back per item."
    },
    "dimensions": {
      "type": "integer",
      "description": "Output size, where the model supports it."
    },
    "encoding_format": {
      "type": "string",
      "description": "`float` by default.",
      "enum": [
        "float",
        "base64"
      ]
    },
    "input_type": {
      "type": "string",
      "description": "What the vectors are for, where the model embeds differently for it.",
      "enum": [
        "query",
        "document",
        "classification",
        "clustering"
      ]
    }
  },
  "additionalProperties": true
}
```

</details>

##### Example


```json
{
  "model": "text-embedding-3-small",
  "input": "hello"
}
```


## Responses

### 200

One vector per item, in `data`.

#### Response headers


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| `X-Respan-Log-Id` | `string` | Optional | ID of the Respan request log for this call. |


#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |
| `data` | `array<object>` | Optional | - |
| `data[]` | `object` | Array item | Additional properties are allowed |
| `data[].index` | `integer` | Optional | - |
| `data[].embedding` | `any` | Optional | A vector of numbers, or base64 text with `encoding_format: base64`. |
| `model` | `string` | Optional | - |
| `usage` | `object` | Optional | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer"
          },
          "embedding": {
            "description": "A vector of numbers, or base64 text with `encoding_format: base64`."
          }
        },
        "additionalProperties": true
      }
    },
    "model": {
      "type": "string"
    },
    "usage": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
```

</details>

### 400

The request is malformed, or a field is one the provider cannot take. Fields refused before the call say which one.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": true
}
```

</details>

### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 429

A rate limit or usage limit was reached. Retry with exponential backoff.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": true
}
```

</details>

## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Create embeddings",
  "operationId": "createEmbeddings",
  "tags": [
    "Gateway"
  ],
  "servers": [
    {
      "url": "https://gateway.respan.ai",
      "description": "Respan gateway"
    }
  ],
  "description": "Embeds texts, or media for models that take it, and returns one vector per item. Follows OpenAI's Embeddings API. Send JSON: a form is refused with `400`.",
  "security": [
    {
      "RespanApiKey": []
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "model",
            "input"
          ],
          "properties": {
            "model": {
              "type": "string",
              "description": "The embedding model, such as `text-embedding-3-small`."
            },
            "input": {
              "description": "A text, an array of texts, an array of token ids, or an array of `{\"content\": [parts]}` objects for media. One vector comes back per item."
            },
            "dimensions": {
              "type": "integer",
              "description": "Output size, where the model supports it."
            },
            "encoding_format": {
              "type": "string",
              "description": "`float` by default.",
              "enum": [
                "float",
                "base64"
              ]
            },
            "input_type": {
              "type": "string",
              "description": "What the vectors are for, where the model embeds differently for it.",
              "enum": [
                "query",
                "document",
                "classification",
                "clustering"
              ]
            }
          },
          "additionalProperties": true
        },
        "example": {
          "model": "text-embedding-3-small",
          "input": "hello"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "One vector per item, in `data`.",
      "headers": {
        "X-Respan-Log-Id": {
          "description": "ID of the Respan request log for this call.",
          "schema": {
            "type": "string"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "integer"
                    },
                    "embedding": {
                      "description": "A vector of numbers, or base64 text with `encoding_format: base64`."
                    }
                  },
                  "additionalProperties": true
                }
              },
              "model": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "additionalProperties": true
              }
            },
            "additionalProperties": true
          }
        }
      }
    },
    "400": {
      "description": "The request is malformed, or a field is one the provider cannot take. Fields refused before the call say which one.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "429": {
      "description": "A rate limit or usage limit was reached. Retry with exponential backoff.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    }
  }
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
