Build with the API
Create embeddings
POST /v1/embeddings turns text into vectors you can search, compare or cluster. It takes an embedding model, which is one whose capabilities include embeddings in the model list.
curl https://sven.swedishembedded.com/v1/embeddings \
-H "Authorization: Bearer $SVEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "MODEL_ID", "input": ["Hello", "World"], "encoding_format": "float"}'
Parameters#
modelis required.inputis one text, or a list of up to 2048 texts. Each text must not be empty.encoding_formatmay only befloat, which is also what you get when you leave it out. OpenAI's clients ask for a different encoding unless you say otherwise, so passfloatexplicitly as shown.dimensionsis not supported and is refused with a400.
The response#
A list with one embedding per input, in order, as an array of numbers, each with its index, and the usage, in input tokens:
json
{
"object": "list",
"model": "MODEL_ID",
"data": [{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789] }],
"usage": { "prompt_tokens": 2, "total_tokens": 2 }
}
What it costs#
You are charged per input token, never more than the model's price. See How calls are charged.