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:
Name | Type | Required | Description |
---|---|---|---|
engine_name | str | Yes | The name of the video understanding engine to use. Example: "Marengo-retrieval-2.6". |
text | str | Yes | The text for which you want to create an embedding. |
text_truncate | Literal["none", "start", "end"] | Yes | Specifies how to truncate the text if it exceeds the maximum length of 77 tokens. |
**kwargs | dict | No | Additional 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.