Endpoints
Embeddings
Turn text into vectors with an embedding model.
POST/v1/embeddings
Follows OpenAI's Embeddings format. Use an embedding model from /models?type=embeddings, or from GET /v1/models, which lists them with an embeddings output modality. Send the key as Authorization: Bearer sk-df-... or x-api-key.
Example
curl https://deference.si/v1/embeddings \
-H "Authorization: Bearer $DEFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/text-embedding-3-small",
"input": "A ledger is a list of entries."
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://deference.si/v1", api_key=os.environ["DEFERENCE_API_KEY"])
result = client.embeddings.create(
model="openai/text-embedding-3-small",
input="A ledger is a list of entries.",
)
print(len(result.data[0].embedding))import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://deference.si/v1",
apiKey: process.env.DEFERENCE_API_KEY,
});
const result = await client.embeddings.create({
model: "openai/text-embedding-3-small",
input: "A ledger is a list of entries.",
});
console.log(result.data[0].embedding.length);Request body
- modelstringRequired
- An embedding model id.
- inputstring | arrayRequired
- The text to embed, or an array of strings.
- encoding_formatstring
float(default) orbase64.- dimensionsinteger
- Output size, for models that support shortening.
Response
{
"object": "list",
"data": [{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456] }],
"model": "openai/text-embedding-3-small",
"usage": { "prompt_tokens": 8, "total_tokens": 8 }
}The embedding array is shortened here. Embeddings are charged for input tokens.