TokenLab

Text

Create Embedding

Creates an embedding vector representing the input text

POST
/v1/embeddings

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.

modelstringrequired

ID of the embedding model to use (e.g., text-embedding-3-small).

inputstring | arrayrequired

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.

encoding_formatstringdefault: float

Format for the embeddings: float or base64.

dimensionsinteger

Number of dimensions for the output (model-specific).

userstring

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

objectstring

Always list.

dataarray

Array of embedding objects.

Each object contains:

  • object (string): embedding
  • index (integer): Index in the input array
  • embedding (array | string): A numeric vector for float, or a Base64 string for base64.
modelstring

Model used.

usageobject

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

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")

POST /v1/multimodal/embeddings

Read the selected model’s current model details before using another interface. Availability and request fields depend on the model.

Multimodal input uses one object or an array of objects with text, image_url, or image_base64 plus image_mime_type. Image input also requires enabled image support and explicit support in the model details. It is not available for every embedding model.

Authorization

BearerAuth
AuthorizationBearer <token>

API Key authentication. Create or manage API keys in Dashboard > API > API Keys.

In: header

Headers

X-TokenLab-Delivery-Policy?string

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