# Embeddings for one text or a list, in the OpenAI embeddings format

`POST /models/v1/embeddings` · Rivier · models

Embeddings for one text or a list, in the OpenAI embeddings format. `model` is an embeddings route name from the model list. Say `input_type: "query"` for a search query; texts to be searched are the default. Where the route takes pictures, an item may be `{ type: "image", mime, data }` with the picture in base64. The answer carries `cost.usd`; `purpose` is a short tag of your own that the day's usage is counted under.

- Scope: models:write
- Graphql: Mutation.modelsEmbeddingCreate
- Sdk: models.embedding.create
- Cli: models embedding create

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "model": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "input": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "image"
            },
            "mime": {
              "type": "string",
              "minLength": 3,
              "maxLength": 40
            },
            "data": {
              "type": "string",
              "minLength": 1,
              "maxLength": 5600000,
              "pattern": "^[A-Za-z0-9+/]+={0,2}$"
            }
          },
          "required": [
            "type",
            "mime",
            "data"
          ],
          "additionalProperties": false
        },
        {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "image"
                  },
                  "mime": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 40
                  },
                  "data": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 5600000,
                    "pattern": "^[A-Za-z0-9+/]+={0,2}$"
                  }
                },
                "required": [
                  "type",
                  "mime",
                  "data"
                ],
                "additionalProperties": false
              }
            ]
          },
          "minItems": 1,
          "maxItems": 100
        }
      ]
    },
    "dimensions": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 8192
        },
        {
          "type": "null"
        }
      ]
    },
    "encoding_format": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "float",
            "base64"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "input_type": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "query",
            "passage",
            "document"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "purpose": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9._-]{0,39}$"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "model",
    "input"
  ],
  "additionalProperties": true
}
```

## Responses

- `200`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/models/v1/embeddings' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "string",
  "input": "string"
}'
```
