Text
Create Embedding
Creates an embedding vector representing the input text
Use GET /v1/models?recommended_for=embedding to get current embedding models.
Request Body
This endpoint returns after the vectors are ready. For large batches, set your HTTP client timeout to at least 120s.
ID of the embedding model to use (e.g., text-embedding-3-small).
Text to embed: a string or an array of strings. Models that support token input also accept number[] for one token sequence or number[][] for multiple sequences.
floatFormat for the embeddings: float or base64.
Number of dimensions for the output (model-specific).
A unique identifier representing your end-user for abuse monitoring.
Choose a Model
Use GET /v1/models?recommended_for=embedding for current models and dimensions.
Response
Always list.
Array of embedding objects.
Each object contains:
object(string):embeddingindex(integer): Index in the input arrayembedding(array | string): A numeric vector forfloat, or a Base64 string forbase64.
Model used.
Token usage with prompt_tokens and total_tokens.
Request
curl -X POST "https://api.tokenlab.sh/v1/embeddings" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}'The example vector is shortened for readability.
Response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0194, 0.0081]
}
],
"model": "text-embedding-3-small",
"usage": {
"prompt_tokens": 9,
"total_tokens": 9
}
}Batch Embeddings
# Embed multiple texts at once
response = client.embeddings.create(
model="text-embedding-3-small",
input=[
"First document text",
"Second document text",
"Third document text"
]
)
for i, data in enumerate(response.data):
print(f"Document {i}: {len(data.embedding)} dimensions")Authorization
BearerAuth API Key authentication. Create or manage API keys in Dashboard > API > API Keys.
In: header
Headers
Per-request Delivery policy. Overrides the API key and Workspace defaults. Auto tries TokenLab Verified first and may switch once to Official only before output, request acceptance, or persistent resource creation.
Value in
- "auto"
- "verified"
- "official"
Request Body
application/json
Response
application/json
application/json
application/json
application/json
application/json
application/json
application/json