# Create Embeddings

`POST /v1/embeddings`

Turn text, or images from your own library, into vectors for memory, search, recommendations and near-duplicate detection. OpenAI-compatible.

`spicy-embed-1` embeds text ($0.14 per 1M tokens): companion memory, prompt search, recommendations. 1024 dimensions by default, 64 to 2048 with `dimensions`. Works with the OpenAI SDK's `client.embeddings.create`.
`spicy-embed-vision-1` puts images and text in one 768-dimension space (text $0.18, images $0.06 per 1M tokens): "more like this" search over your generations, tagging, dedupe. Every image must be an output of your own account (the same provenance rule as every image input); a text query and an image land in the same space, so you can search images with words.
Up to 10 inputs per request, each up to 8,192 tokens. Billed on the tokens used (minimum $0.00001 per request). Nothing is generated, so inputs are not screened. Sandbox keys get deterministic fixture vectors and pay nothing.

Base URL: `https://api.spicyapi.com`

## Authorizations

- `Authorization` (string, header, required): Bearer authentication header of the form `Bearer <token>`, where `<token>` is your SpicyAPI key (`sk-spicy-…`). Create one in the dashboard under API Keys.

## Body (application/json)

- `model` (string, required): `spicy-embed-1` or `spicy-embed-vision-1`.
- `input` (string | array, required): A string or an array of up to 10 items. On `spicy-embed-1` every item is a string. On `spicy-embed-vision-1` an item is a string, `{ "text": "..." }` or `{ "image": "https://..." }` where the image is one of your generated images.
- `dimensions` (integer, optional): `spicy-embed-1` only: `64`, `128`, `256`, `512`, `768`, `1024` (default), `1536` or `2048`. `spicy-embed-vision-1` always returns 768 and rejects it.
- `encoding_format` (string, optional): `float` (default) or `base64` (little-endian float32).

## Request

```bash
curl --request POST \
  --url https://api.spicyapi.com/v1/embeddings \
  --header 'Authorization: Bearer $SPICYAPI_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "spicy-embed-1",
    "input": ["She likes rainy evenings and old jazz records.", "Her favourite drink is a dirty martini."],
    "dimensions": 512
  }'

# images and text in one space: search your library with words
curl --request POST \
  --url https://api.spicyapi.com/v1/embeddings \
  --header 'Authorization: Bearer $SPICYAPI_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "spicy-embed-vision-1",
    "input": [
      { "image": "https://cdn.spicyapi.com/outputs/a1b2/sj_2f1c7e9a-0.png" },
      { "text": "red silk robe on a hotel balcony at night" }
    ]
  }'
```

## Response: 200 application/json

Successful Response

- `object` (string, required): Always `list`.
- `model` (string, required): The model used.
- `data` (Embedding · object[], required): One vector per input, in order.
  - `object` (string, required): Always `embedding`.
  - `index` (integer, required): Position of the input.
  - `embedding` (number[] | string, required): The vector, or a base64 string with `encoding_format: "base64"`.
- `usage` (object, required): Token counts, as in the OpenAI API.
- `cost_usd` (number, required): What this request cost, in US dollars, already debited from your balance.

```json
{
  "object": "list",
  "model": "spicy-embed-1",
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.0213, -0.0447, 0.0132, "..."] },
    { "object": "embedding", "index": 1, "embedding": [-0.0081, 0.0356, 0.0274, "..."] }
  ],
  "usage": { "prompt_tokens": 22, "total_tokens": 22 },
  "cost_usd": 0.00001
}
```
