Create text, image, and audio embeddings

The resources.Embed class provides methods to create text, image, and audio embeddings.

Create text, image, and audio embeddings

Description: This method creates a new embedding.

Note that you must specify at least the following parameters:

  • model_name: The name of the video understanding model to use.

  • One or more of the following input types:

    • text: For text embeddings
    • audio_url or audio_file: For audio embeddings. If you specify both, the audio_url parameter takes precedence.
    • image_url or image_file: For image embeddings. If you specify both, the image_url parameter takes precedence.

You must provide at least one input type, but you can include multiple types in a single function call.

Function signature and example:

1def create(
2 self,
3 model_name: Literal["Marengo-retrieval-2.7"],
4 *,
5 # text params
6 text: str = None,
7 text_truncate: Literal["none", "start", "end"] = None,
8 # audio params
9 audio_url: str = None,
10 audio_file: Union[str, BinaryIO, None] = None,
11 # image params
12 image_url: str = None,
13 image_file: Union[str, BinaryIO, None] = None,
14 **kwargs,
15) -> models.CreateEmbeddingsResult

Parameters:

NameTypeRequiredDescription
model_nameLiteral["Marengo-retrieval-2.7"YesThe name of the video understanding model to use. Example: “Marengo-retrieval-2.7”.
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.
audio_urlstrA publicly accessible URL of your audio file.
audio_fileUnion[str, BinaryIO, None]A local audio file.
image_urlstrA publicly accessible URL of your image file.
image_fileUnion[str, BinaryIO, None]A local image file.
**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, audio, and image embeddings page.

Related guides:

Built with