Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI & ML · Const

Embedding

Embeddings represent text as vectors that preserve aspects of content or meaning. They support similarity-based tasks such as search, clustering, recommendations, anomaly detection, and classification.

How it works

An embedding is a vector representation of text that preserves aspects of its content or meaning. Send one or more text inputs with an embedding model to the embeddings endpoint; the response contains a vector for each input, which can then be compared or indexed for similarity-based applications.

Syntax

client.embeddings.create(input=[text], model="text-embedding-3-small")

Parameters

NameTypeDescription
inputstring | array of stringsText, or an array of text inputs, to embed.
modelstringThe identifier of the embedding model, such as text-embedding-3-small.

Returns

An embeddings response containing a data array; each item includes the generated embedding vector.

Key points

  • Embeddings convert text into vectors whose relative closeness represents semantic relatedness.
  • Typical applications include semantic search, clustering, recommendations, anomaly detection, diversity measurement, and classification.
  • Call the embeddings endpoint with the input text and model identifier, such as text-embedding-3-small.
  • Embedding models accept text and return numerical vectors suitable for downstream similarity operations.
  • Check the model index for the input limit of the chosen embedding model.

Common mistakes

  • Keep each input below the selected embedding model’s maximum context length.
  • The request must specify both the text input and an embedding model.

Example: Create a text embedding

from openai import OpenAI

client = OpenAI()
response = client.embeddings.create(
    input=["The food was delicious"],
    model="text-embedding-3-small"
)
print(len(response.data[0].embedding))

Creates an embedding for one text string and prints the returned vector’s dimensionality.

When to use it

Search

Rank documents or passages by semantic similarity to a query.

Clustering

Group text items by semantic similarity.

Recommendations

Recommend related items based on their text representations.

Classification

Assign text to the label with the most similar embedding.

  • text-embedding-3-small
  • embeddings API
  • semantic search
  • clustering
  • recommendations
  • classification

Source: Vector embeddings | OpenAI API. Checked 2026-10-15.