Create text embeddings

The resources.Embed class provides methods to create text embeddings.

Create text embeddings

Description: This method creates a new text embedding.

Function signature and example:

def create(
    self,
    engine_name: str,
    text: str,
    *,
    text_truncate: Literal["none", "start", "end"],
    **kwargs
) -> models.CreateEmbeddingsResult
Marengo-retrieval-2.6
embedding = client.embed.create(
  engine_name="Marengo-retrieval-2.6",
  text_truncate="start",
  text="<YOUR_TEXT>"
)

print("Created a text embedding")
print(f" Engine: {embedding.engine_name}")
print(f" Embedding: {embedding.text_embedding.float}")

Parameters:

NameTypeRequiredDescription
engine_namestrYesThe name of the video understanding engine to use. Example: "Marengo-retrieval-2.6".
textstrYesThe text for which you want to create an embedding.
text_truncateLiteral["none", "start", "end"]YesSpecifies how to truncate the text if it exceeds the maximum length of 77 tokens.
**kwargsdictNoAdditional keyword arguments for the request.

Return value: Returns a models.CreateEmbeddingsResult object containing the embedding results.

API Reference: For a description of each field in the request and response, see the Create text embeddings page.

Related guide: Create text embeddings.