Embeddings are numerical representations of text that capture its semantic meaning. These embeddings map similar pieces of text closer in vector space, enabling advanced text analysis tasks such as:

  • Semantic Search: Retrieve content with similar meaning. Find similar texts by comparing embeddings using cosine similarity or dot product.
  • Content Recommendation: Suggest relevant items or information. Use embeddings to recommend content similar to a user’s preferences.
  • Text Classification: Categorize text into predefined groups. Group related texts together based on embedding similarity.
  • Similarity Analysis: Measure how closely texts are related.

Available Models

Tune Studio supports the following embedding models:

Model NameDimensionsMax Input TokensDescriptionBest For
openai/text-embedding-3-small15368191Lightweight model with strong performanceCost-effective, general-purpose use
openai/text-embedding-3-large30728191High-accuracy model for critical tasksApplications requiring high precision
openai/text-embedding-ada-00215368191Legacy model for compatibilitySystems already using Ada embeddings

Understanding Model Parameters

Dimensions:

The dimensions value represents the length of the embedding vector that the model produces.

  • Each piece of text is converted into a vector of floating-point numbers
  • The number of dimensions affects the model’s ability to capture semantic nuances
  • Higher dimensions (like 3072 in text-embedding-3-large) can capture more detailed semantic relationships
  • Lower dimensions (like 1536) require less storage and are faster to process while still maintaining good performance

Maximum Input Tokens:

  • Represents the maximum length of text that can be processed in a single request
  • Tokens are roughly equal to 4 characters or ~¾ of a word
  • Longer texts need to be chunked into smaller pieces before processing
  • All current models support up to 8,191 tokens per input

Higher dimensions don’t always mean better performance for your specific use case. text-embedding-3-small (1536 dimensions) is suitable for most applications, while text-embedding-3-large (3072 dimensions) should be used when maximum accuracy is required.


Getting Started

Create Embeddings

To generate embeddings, make a POST request to the API endpoint with your text input and selected model.

Endpoint

POST https://proxy.tune.app/v1/embeddings

Sample Request

curl -X POST "https://proxy.tune.app/v1/embeddings" \
-H "Authorization: Bearer <YOUR_TUNE_KEY>" \
-H "Content-Type: application/json" \
-d '{
  "input": "The food was delicious and the waiter...",
  "model": "openai/text-embedding-3-small"
}'

Response Format

{
  "data": [
    {
      "embedding": [0.123, -0.456, ...],
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "openai/text-embedding-3-small",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}

Request Parameters

ParameterTypeRequiredDescription
inputstring or arrayYesText to embed
modelstringYesID of the model to use

Best Practices

Input Types

The API accepts the following input types:

  • Single string: For embedding one text at a time.
  • Array of strings: For embedding multiple texts in a batch.

Example:

{
  "input": ["Text 1", "Text 2", "Text 3"],
  "model": "openai/text-embedding-3-small"
}

Batching Requests

  • Batch requests for efficiency (up to 2048 tokens per batch).
  • Balance batch size with response time based on your application needs.

Preprocessing

  • Remove unnecessary whitespace and special characters.
  • Use consistent formatting, such as lowercasing all text for uniformity.

Embeddings are billed based on the number of tokens in the input text. For details, see our pricing page.

The Embedding API generates embeddings but does not store them. Users are responsible for storing embeddings in their preferred database or storage solution.