> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.twelvelabs.io/v1.3/docs/cloud-partner-integrations/amazon-bedrock/create-embeddings/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.twelvelabs.io/_mcp/server. # Create embeddings > Create video embeddings with Marengo on Amazon Bedrock. Use the Marengo video understanding model to generate embeddings from video, audio, text, and image inputs. These embeddings enable similarity search, content clustering, recommendation systems, and other machine learning applications. > **Note** > > Marengo 2.7 will be deprecated. Embeddings created with Marengo 2.7 are not compatible with Marengo 3.0. You must migrate to 3.0 and regenerate all your embeddings. For details, see the [Migration guide](/v1.3/docs/cloud-partner-integrations/amazon-bedrock/migration-guide) page. # Regional availability Marengo is available in the following regions: US East (N. Virginia), Europe (Ireland), Asia Pacific (Seoul) # Model specification | Specification | Marengo 3.0 | Marengo 2.7 | | ----------------- | ----------------------------------------- | ----------------------------------- | | Model ID | `twelvelabs.marengo-embed-3-0-v1:0` | `twelvelabs.marengo-embed-2-7-v1:0` | | Input | Video, audio, image, text, image and text | Video, audio, image, text | | Input methods | S3 URI or base64 encoded string | S3 URI or base64 encoded string | | Output | 512-dimensional embeddings | 1024-dimensional embeddings | | Similarity metric | Cosine similarity | Cosine similarity | The model has two types of limits: the maximum input size you can submit and the portion of content that it embeds. ## Input requirements This table shows the maximum size for each type of input: | Input type | Marengo 3.0 | Marengo 2.7 | | :--------- | :--------------------------------------------- | :--------------------------------------------- | | Video | - S3: 6 GB - base64: 36 MB - Duration: 4 hours | - S3: 2 GB - base64: 36 MB - Duration: 2 hours | | Audio | - S3: 6 GB - base64: 36 MB - Duration: 4 hours | S3: 2 GB - base64: 36 MB - Duration: 2 hours | | Image | 5 MB | 5 MB | | Text | 500 tokens | 77 tokens | ## Embedding coverage per input type This table shows what portion of your input the model processes into embeddings: | Input type | Embedding behavior | | :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Video** | Creates multiple embeddings for segments throughout the video. Segments are 1-10 seconds each. You can specify which portion of the video to process. | | **Audio** | Creates multiple embeddings, dividing the audio into segments as close to 10 seconds as possible. You can specify which portion of the audio to process. | | **Image** | Processes the entire image. | | **Text** | Processes up to the maximum tokens supported, and automatically truncates text exceeding 500 tokens from the end. | | **Text with image** | Processes both text and image together to create a single embedding. | # Pricing For details on pricing, see the [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/) page. # Choose the processing method Select the processing method based on your use case and performance requirements. Synchronous processing returns embeddings immediately in the API response, while asynchronous processing handles larger files and batch operations by saving results to S3. > **Note** > > Synchronous processing supports text and image inputs. Asynchronous processing supports video, audio, and image inputs. Use synchronous processing to: * Build real-time applications like chatbots, search, and recommendation systems. * Enable interactive features that require immediate results. Use asynchronous processing to: * Build applications that process video, audio, and images. * Run batch operations and background workflows. # Prerequisites Before you start, ensure you have the following: * An AWS account with access to a region where the TwelveLabs models are supported. * An AWS IAM principal with sufficient Amazon Bedrock permissions. For details on setting permissions, see the [Identity and access management for Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html) page. * S3 permissions to read input files and write output files for Marengo operations. * The [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) and configured with your credentials. * Python 3.7 or later with the [`boto3`](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html) library. * Access to the model you want to use. Navigate to the [**AWS Console** > **Bedrock** > **Model Access**](https://eu-west-1.console.aws.amazon.com/bedrock/home?region=eu-west-1#/model-catalog) page and request access. Note that the availability of the models varies by region. # Create embeddings Marengo supports base64 encoded strings and S3 URIs for media input. Note that the base64 method has a 36MB file size limit. This guide uses S3 URIs. > **Note** > > Your S3 input and output buckets must be in the same region as the model. If regions don't match, the API returns a `ValidationException` error. To generate embeddings from your content, you use one of two Amazon Bedrock APIs, depending on your processing needs. ## Synchronous processing The [InvokeModel API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) processes your request synchronously and returns embeddings directly in the response. The InvokeModel API requires two parameters: * `modelId`: The inference profile ID for the model. * `body`: A JSON-encoded string containing your input parameters. The request body contains the following fields: * `inputType`: The type of content. Values: "text", "image", or "text\_image". * For text inputs, include a string named `inputText` with the text to embed. * For image inputs, include an object named `image` with with the following fields: * `mediaSource`: The image source containing either `base64String` or `s3Location` * For text with image inputs, include an object named `text_image` with the following fields: * `inputText`: The text to embed * `mediaSource`: The image source containing either `base64String` or `s3Location` ### Examples Ensure you replace the placeholders surrounded by `<>` with your values. #### Text **`Python`** ```Python Python import boto3 import json INFERENCE_PROFILE_ID = "twelvelabs.marengo-embed-3-0-v1:0" REGION_NAME = "" PROFILE_NAME = "" INPUT_TEXT="" model_input = { "inputType": "text", "text": { "inputText": INPUT_TEXT } } # Initialize the Bedrock Runtime client boto3_session = boto3.Session(profile_name=PROFILE_NAME, region_name=REGION_NAME) client = boto3_session.client('bedrock-runtime') # Make the request response = client.invoke_model( modelId=INFERENCE_PROFILE_ID, body=json.dumps(model_input) ) # Print the response body response_body = json.loads(response['body'].read().decode('utf-8')) print(response_body) ``` #### Image **`Python`** ```Python Python import boto3 import json INFERENCE_PROFILE_ID = "twelvelabs.marengo-embed-3-0-v1:0" REGION_NAME = "" PROFILE_NAME = "" ACCOUNT_ID = "" BUCKET = "" IMAGE_FILE_NAME = "" INPUT_TYPE = "image" model_input = { "inputType": "image", "image": { "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{IMAGE_FILE_NAME}", "bucketOwner": ACCOUNT_ID } } } } # Initialize the Bedrock Runtime client boto3_session = boto3.Session(profile_name=PROFILE_NAME, region_name=REGION_NAME) client = boto3_session.client('bedrock-runtime') # Make the request response = client.invoke_model( modelId=INFERENCE_PROFILE_ID, body=json.dumps(model_input) ) # Print the response body response_body = json.loads(response['body'].read().decode('utf-8')) print(response_body) ``` #### Text with image **`Python`** ```python Python import boto3 import json INFERENCE_PROFILE_ID = "twelvelabs.marengo-embed-3-0-v1:0" REGION_NAME = "" INPUT_TEXT = "" ACCOUNT_ID = "" BUCKET = "" IMAGE_FILE_NAME = "" model_input = { "inputType": "text_image", "text_image": { "inputText": INPUT_TEXT, "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{IMAGE_FILE_NAME}", "bucketOwner": ACCOUNT_ID } } } } # Initialize the Bedrock Runtime client boto3_session = boto3.Session(profile_name=PROFILE_NAME, region_name=REGION_NAME) client = boto3_session.client('bedrock-runtime') # Make the request response = client.invoke_model( modelId=INFERENCE_PROFILE_ID, body=json.dumps(model_input) ) # Print the response body response_body = json.loads(response['body'].read().decode('utf-8')) print(response_body) ``` ## Asynchronous processing The [StartAsyncInvoke API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_StartAsyncInvoke.html) processes your request asynchronously, storing the results in your S3 bucket. To create embeddings asynchronously, you must complete the following steps: Submit your request, providing an S3 location for your input media file and an S3 location for the output. Note that this example uses the same bucket. Check the job status using the returned invocation ARN. Retrieve the results from the S3 output location once the job has completed. The StartAsyncInvoke API requires three parameters: * `modelId`: The model ID. * `modelInput`: A dictionary containing your input parameters. * `outputDataConfig`: A dictionary specifying where to save the results The `modelInput` dictionary contains the following required fields: * `inputType`: The type of content ("video", "audio", "image", "text", or "text\_image") * For video inputs, include an object named `video` containing at least the following fields: * `mediaSource`: The S3 location of your video file * For audio inputs, include an object named `audio` containing at least the following required fields: * `mediaSource`: The S3 location of your audio file * For image inputs, include an `image` object with: * `mediaSource`: The S3 location of your image file * For text inputs, include a `text` object with: * `inputText`: The text to embed * For text with image inputs, include a `text_image` object with: * `inputText`: The text to embed * `mediaSource`: The S3 location of your image file ### S3 output structure Each invocation creates a unique directory in your S3 bucket with two files: * `manifest.json`: Contains metadata including the request ID. * `output.json`: Contains the actual embeddings. ### Examples Ensure you replace the placeholders surrounded by `<>` with your values. #### Video **`Python`** ```python Python import boto3 import time REGION_NAME = "" PROFILE_NAME = "" MODEL_ID = "twelvelabs.marengo-embed-3-0-v1:0" ACCOUNT_ID = "" BUCKET = "" FILE_NAME = "" INPUT_TYPE = "" boto3_session = boto3.Session(profile_name=PROFILE_NAME, region_name=REGION_NAME) bedrock_client = boto3_session.client('bedrock-runtime') # Start async video embedding model_input = { "inputType": "video", "video": { "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{VIDEO_FILE}", "bucketOwner": ACCOUNT_ID } }, } } async_request_response = bedrock_client.start_async_invoke( modelId=MODEL_ID, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": f"s3://{BUCKET}", "bucketOwner": ACCOUNT_ID } } ) print("async_request_response: ", async_request_response) # Get the invocation arn invocation_arn = async_request_response.get("invocationArn") # Wait for the async job to complete max_retries = 60 retries = 0 while True: response = bedrock_client.get_async_invoke( invocationArn=invocation_arn ) print(f"status: {response.get('status')}") if response.get("status") == "Completed": break time.sleep(1) retries += 1 if retries > max_retries: break print(response) # Extract the S3 URI where results are stored output_s3_uri = response.get("outputDataConfig", {}).get("s3OutputDataConfig", {}).get("s3Uri") print(f"Results stored at: {output_s3_uri}") ``` #### Text inputs **`Python`** ```python Python import boto3 import time REGION_NAME = "" PROFILE_NAME = "" MODEL_ID = "twelvelabs.marengo-embed-3-0-v1:0" ACCOUNT_ID = "" BUCKET = "" boto3_session = boto3.Session(profile_name=PROFILE_NAME, region_name=REGION_NAME) bedrock_client = boto3_session.client('bedrock-runtime') # Start async video embedding model_input = { "inputType": "text", "text": { "inputText": "" } } async_request_response = bedrock_client.start_async_invoke( modelId=MODEL_ID, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": f"s3://{BUCKET}", "bucketOwner": ACCOUNT_ID } } ) print("async_request_response: ", async_request_response) # get the invocation arn invocation_arn = async_request_response.get("invocationArn") # wait for the async job to complete max_retries = 60 retries = 0 while True: response = bedrock_client.get_async_invoke( invocationArn=invocation_arn ) print(f"status: {response.get('status')}") if response.get("status") == "Completed": break time.sleep(1) retries += 1 if retries > max_retries: break print(response) # Extract the S3 URI where results are stored output_s3_uri = response.get("outputDataConfig", {}).get("s3OutputDataConfig", {}).get("s3Uri") print(f"Results stored at: {output_s3_uri}") ``` #### Audio inputs **`Python`** ```python Python import boto3 import time REGION_NAME = "" PROFILE_NAME = "" MODEL_ID = "twelvelabs.marengo-embed-3-0-v1:0" ACCOUNT_ID = "" BUCKET = "" AUDIO_FILE = "" boto3_session = boto3.Session(profile_name=PROFILE_NAME, region_name=REGION_NAME) bedrock_client = boto3_session.client('bedrock-runtime') # Start async image embedding model_input = { "inputType": "audio", "audio": { "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{AUDIO_FILE}", "bucketOwner": ACCOUNT_ID } } } } async_request_response = bedrock_client.start_async_invoke( modelId=MODEL_ID, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": f"s3://{BUCKET}", "bucketOwner": ACCOUNT_ID } } ) print("async_request_response: ", async_request_response) # Get the invocation ARN invocation_arn = async_request_response.get("invocationArn") # Wait for the async job to complete max_retries = 60 retries = 0 while retries < max_retries: response = bedrock_client.get_async_invoke( invocationArn=invocation_arn ) status = response.get("status") print(f"status: {status}") if status == "Completed": break elif status in ["Failed", "Cancelled"]: print(f"Job failed: {response}") break time.sleep(1) retries += 1 if status == "Completed": output_s3_uri = response.get("outputDataConfig", {}).get("s3OutputDataConfig", {}).get("s3Uri") print(f"Results stored at: {output_s3_uri}") ``` #### Image inputs **`Python`** ```python Python import boto3 import time REGION_NAME = "" PROFILE_NAME = "" MODEL_ID = "twelvelabs.marengo-embed-3-0-v1:0" ACCOUNT_ID = "" BUCKET = "" IMAGE_FILE = "" boto3_session = boto3.Session(profile_name=PROFILE_NAME, region_name=REGION_NAME) bedrock_client = boto3_session.client('bedrock-runtime') # Start async image embedding model_input = { "inputType": "image", "image": { "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{IMAGE_FILE}", "bucketOwner": ACCOUNT_ID } } } } async_request_response = bedrock_client.start_async_invoke( modelId=MODEL_ID, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": f"s3://{BUCKET}", "bucketOwner": ACCOUNT_ID } } ) print("async_request_response: ", async_request_response) # Get the invocation ARN invocation_arn = async_request_response.get("invocationArn") # Wait for the async job to complete max_retries = 60 retries = 0 while retries < max_retries: response = bedrock_client.get_async_invoke( invocationArn=invocation_arn ) status = response.get("status") print(f"status: {status}") if status == "Completed": break elif status in ["Failed", "Cancelled"]: print(f"Job failed: {response}") break time.sleep(1) retries += 1 if status == "Completed": output_s3_uri = response.get("outputDataConfig", {}).get("s3OutputDataConfig", {}).get("s3Uri") print(f"Results stored at: {output_s3_uri}") ``` #### Text and image inputs **`Python`** ```python Python import boto3 import time REGION = "" MODEL_ID = "twelvelabs.marengo-embed-3-0-v1:0" ACCOUNT_ID = "" BUCKET = "" INPUT_TEXT = "" IMAGE_FILE = "" bedrock_client = boto3.client(service_name="bedrock-runtime", region_name=REGION) # Start async text with image embedding model_input = { "inputType": "text_image", "text_image": { "inputText": INPUT_TEXT, "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{IMAGE_FILE}", "bucketOwner": ACCOUNT_ID } } } } async_request_response = bedrock_client.start_async_invoke( modelId=MODEL_ID, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": f"s3://{BUCKET}", "bucketOwner": ACCOUNT_ID } } ) print("async_request_response: ", async_request_response) # Get the invocation ARN invocation_arn = async_request_response.get("invocationArn") # Wait for the async job to complete max_retries = 60 retries = 0 while retries < max_retries: response = bedrock_client.get_async_invoke( invocationArn=invocation_arn ) status = response.get("status") print(f"status: {status}") if status == "Completed": break elif status in ["Failed", "Cancelled"]: print(f"Job failed: {response}") break time.sleep(1) retries += 1 if status == "Completed": output_s3_uri = response.get("outputDataConfig", {}).get("s3OutputDataConfig", {}).get("s3Uri") print(f"Results stored at: {output_s3_uri}") ``` # Use embeddings After generating embeddings, you can store them in a vector database for efficient similarity search and retrieval. The typical workflow is as follows: Generate embeddings for your content. Store embeddings with metadata in your chosen vector database. Generate an embedding for user queries. Use cosine similarity to find the most relevant content. Retrieve the original content or use the results for RAG applications. # Request parameters and response fields For a complete list of request parameters and response fields, see the [TwelveLabs Marengo Embed 3.0](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-marengo-3.html) page in the Amazon Bedrock documentation. --- # Using Marengo 2.7 > **Note** > > Marengo 2.7 will be deprecated. Embeddings created with Marengo 2.7 are not compatible with Marengo 3.0. You must migrate to 3.0 and regenerate all your embeddings. For details, see the [Migration guide](/v1.3/docs/cloud-partner-integrations/amazon-bedrock/migration-guide) page. ## Synchronous processing ### Request body structure The request body contains the following fields: * `inputType`: The type of content. Values: "text" or "image". * `inputText`: The text to embed. Required for text inputs. * `mediaSource`: The image source containing either `base64String` or `s3Location`. Required for image inputs. ### Examples #### Text Replace `` with the text for which you wish to create an embedding. **`Python`** ```python Python import boto3 import json # Replace the `us` prefix depending on your region INFERENCE_PROFILE_ID = "us.twelvelabs.marengo-embed-2-7-v1:0" INPUT_TEXT = "" model_input = { "inputType": "text", "inputText": INPUT_TEXT } # Initialize the Bedrock Runtime client client = boto3.client('bedrock-runtime') # Make the request response = client.invoke_model( modelId=INFERENCE_PROFILE_ID, body=json.dumps(model_input) ) # Print the response body response_body = json.loads(response['body'].read().decode('utf-8')) print(response_body) ``` #### Image Replace the following placeholders with your values: * ``: Your AWS account ID * ``: The name of your S3 bucket * ``: The name of your image file **`Python`** ```python Python import boto3 import json # Replace the `us` prefix depending on your region INFERENCE_PROFILE_ID = "us.twelvelabs.marengo-embed-2-7-v1:0" ACCOUNT_ID = "" BUCKET = "" IMAGE_FILE_NAME = "" model_input = { "inputType": "image", "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{IMAGE_FILE_NAME}", "bucketOwner": ACCOUNT_ID } } } # Initialize the Bedrock Runtime client client = boto3.client('bedrock-runtime') # Make the request response = client.invoke_model( modelId=INFERENCE_PROFILE_ID, body=json.dumps(model_input) ) # Print the response body response_body = json.loads(response['body'].read().decode('utf-8')) print(response_body) ``` ### Asynchronous processing ### Model input structure The `modelInput` dictionary contains the following fields: * `inputType`: The type of content ("video", "audio", "image", or "text") * `mediaSource`: The S3 location of your input file (for video, audio, and image) * `inputText`: The text content (for text inputs only) ### Examples #### Video, audio, or image Replace the following placeholders with your values: * ``: Your AWS region * ``: Your AWS account ID * ``: The name of your S3 bucket * ``: The name of your file * ``: The type of media ("video", "audio", or "image") **`Python`** ```python Python import boto3 import time REGION = "" MODEL_ID = "twelvelabs.marengo-embed-2-7-v1:0" ACCOUNT_ID = "" BUCKET = "" FILE_NAME = "" INPUT_TYPE = "" bedrock_client = boto3.client(service_name="bedrock-runtime", region_name=REGION) # Start async embedding model_input = { "mediaSource": { "s3Location": { "uri": f"s3://{BUCKET}/{FILE_NAME}", "bucketOwner": ACCOUNT_ID } }, "inputType": INPUT_TYPE } async_request_response = bedrock_client.start_async_invoke( modelId=MODEL_ID, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": f"s3://{BUCKET}", "bucketOwner": ACCOUNT_ID } } ) print("async_request_response: ", async_request_response) # Get the invocation ARN invocation_arn = async_request_response.get("invocationArn") # Wait for the async job to complete max_retries = 60 retries = 0 while True: response = bedrock_client.get_async_invoke( invocationArn=invocation_arn ) print(f"status: {response.get('status')}") if response.get("status") == "Completed": break time.sleep(1) retries += 1 if retries > max_retries: break print(response) # Extract the S3 URI where results are stored output_s3_uri = response.get("outputDataConfig", {}).get("s3OutputDataConfig", {}).get("s3Uri") print(f"Results stored at: {output_s3_uri}") ``` #### Text Replace the following placeholders with your values: * ``: Your AWS region * ``: Your AWS account ID * ``: The name of your S3 bucket * ``: The text to embed **`Python`** ```python Python import boto3 import time REGION = "" MODEL_ID = "twelvelabs.marengo-embed-2-7-v1:0" ACCOUNT_ID = "" BUCKET = "" bedrock_client = boto3.client(service_name="bedrock-runtime", region_name=REGION) # Start async text embedding model_input = { "inputType": "text", "inputText": "" } async_request_response = bedrock_client.start_async_invoke( modelId=MODEL_ID, modelInput=model_input, outputDataConfig={ "s3OutputDataConfig": { "s3Uri": f"s3://{BUCKET}", "bucketOwner": ACCOUNT_ID } } ) print("async_request_response: ", async_request_response) # Get the invocation ARN invocation_arn = async_request_response.get("invocationArn") # Wait for the async job to complete max_retries = 60 retries = 0 while True: response = bedrock_client.get_async_invoke( invocationArn=invocation_arn ) print(f"status: {response.get('status')}") if response.get("status") == "Completed": break time.sleep(1) retries += 1 if retries > max_retries: break print(response) # Extract the S3 URI where results are stored output_s3_uri = response.get("outputDataConfig", {}).get("s3OutputDataConfig", {}).get("s3Uri") print(f"Results stored at: {output_s3_uri}") ``` ### Request parameters and response fields For a complete list of request parameters and response fields, see the [TwelveLabs Marengo Embed 2.7](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-marengo.html) page in the Amazon Bedrock documentation. > Create video embeddings with Marengo on Amazon Bedrock.