Skip to content
Main Site News Console

Text Embeddings

POST https://api.4allapi.com/v1/embeddings

Converts text into high-dimensional vectors for semantic search, clustering, recommendations, and RAG knowledge bases.

Request Example

Terminal window
curl https://api.4allapi.com/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AIPROXY_KEY" \
-d '{
"model": "text-embedding-3-large",
"input": ["What is 4ALL API", "How to create an API token"]
}'

input supports a single string or an array of strings (batch); each input in the response corresponds to one embedding vector:

{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, ...] },
{ "object": "embedding", "index": 1, "embedding": [...] }
],
"model": "text-embedding-3-large",
"usage": { "prompt_tokens": 14, "total_tokens": 14 }
}

Practical Recommendations

  • Use the same embedding model for the entire knowledge base, and do not mix vector spaces from different models;
  • For long documents, split into chunks first (e.g. 300–800 characters, with overlap) before embedding; this improves retrieval hit rates;
  • When embedding in batches, submit multiple items at once as an array; this is faster and more efficient than one request at a time;
  • Embeddings are billed by input tokens, and the price is far lower than chat models, making them suitable for large-scale indexing.