Embeddings
Turns text into vectors for search, clustering, and retrieval, in the OpenAI Embeddings format. Embedding models are paid models from providers: each one's price per million input tokens is on its page at freetheai.org/models.
POST
https://api.freetheai.org/v1/embeddingsRequest
bash
curl https://api.freetheai.org/v1/embeddings \
-H "Authorization: Bearer $FTAI_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "MODEL_ID", "input": ["first text", "second text"]}'python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.freetheai.org/v1", api_key=os.environ["FTAI_KEY"])
result = client.embeddings.create(model="MODEL_ID", input=["first text", "second text"])
print(len(result.data[0].embedding))ts
import OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://api.freetheai.org/v1', apiKey: process.env.FTAI_KEY })
const result = await client.embeddings.create({ model: 'MODEL_ID', input: ['first text', 'second text'] })
console.log(result.data[0].embedding.length)| Field | Type | Description |
|---|---|---|
model | string | An embedding model ID from GET /v1/models ("type": "embeddings"). |
input | string or array | One text, a list of texts, or token arrays. |
dimensions | integer | Optional. Fewer dimensions, for models that support it (1 to 65536). |
encoding_format | string | Optional. float (default) or base64. |
Other fields are not sent to the model.
Response
json
{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456] },
{ "object": "embedding", "index": 1, "embedding": [0.0789, 0.0012] }
],
"model": "MODEL_ID",
"usage": { "prompt_tokens": 6, "total_tokens": 6 }
}You are charged for usage.prompt_tokens at the model's input price. The request first holds an estimate on your wallet; the unused part is given back.
Errors
| Status | Meaning |
|---|---|
400 | A field has a value the endpoint does not take (the message names it). |
401 | Missing or invalid API key. |
402 | Not enough wallet balance, or the key's budget is used (paid usage errors). |
404 | No model has that ID, or none of the providers you follow serve it. |
502 / 503 | The provider failed or is busy. Retry; a failed request is not charged. |

