Every voice agent depends on two things: hearing the caller correctly and knowing when they've stopped talking. Mishear an account number and the task fails. Catch the end of a turn too late and the caller sits through dead air. Many of the teams building these agents work in healthcare, financial services and insurance, where call audio can't leave their own AWS account.
Today, AssemblyAI-STT-3.7-Realtime-Agent is available in AWS Marketplace for deployment as an Amazon SageMaker AI real-time endpoint. The model streams audio over SageMaker AI bidirectional streaming and runs with network isolation, so audio and transcripts stay in your account. You pay for usage per audio hour on your AWS bill.
AssemblyAI, an independent software vendor (ISV) in AWS Marketplace, builds voice AI models for developers and enterprises. Founded in 2017, AssemblyAI serves thousands of customers and hundreds of thousands of developers through its API. AssemblyAI-STT-3.7-Realtime-Agent is its streaming model tuned for voice agents, with turn detection your application can control.
In this post, we show you how to subscribe to the model in AWS Marketplace, deploy it to a SageMaker AI endpoint, stream audio to it from Python, and size the endpoint for your traffic.
Running the model in your own account gives you the controls of a self-hosted deployment, while SageMaker AI handles the infrastructure:
- Security, compliance and data residency. The endpoint runs in your AWS account, in the AWS Region you choose, with network isolation. Audio, transcripts and model outputs stay in your environment and never reach AssemblyAI or the public internet, which helps you meet regional data residency, security and compliance requirements.
- Managed hosting. SageMaker AI provisions the GPUs, runs health checks, replaces unhealthy instances and scales the endpoint with Application Auto Scaling. You don't manage containers, drivers or clusters.
- Same streaming protocol as the AssemblyAI API. The container speaks the AssemblyAI Streaming v3 message format over the bidirectional stream, so applications already built on AssemblyAI streaming port over with a transport change.
- Procurement through AWS. Usage is billed per audio hour through AWS Marketplace and appears on your AWS bill next to the instance cost. Marketplace purchases can count toward your AWS commitments; check with your AWS account team.
- Built for voice agents. AssemblyAI-STT-3.7-Realtime-Agent is built to get entities right, such as names, account numbers, dates and addresses. Entity-aware endpointing keeps a turn open while the caller is still reading out a number or an address. agent_context passes the agent's last reply into each turn, so the model knows what question the caller is answering and transcribes the reply more accurately. You can tune it for your use case with contextual prompting (prompt) and custom vocabulary (keyterms_prompt).
Solution overview
Your application opens one bidirectional stream per call to a SageMaker AI endpoint in your account. It sends audio as the caller speaks and receives partial and final transcripts on the same stream.
Audio and transcripts stay inside your AWS account Your application streams audio to the SageMaker AI runtime over a bidirectional HTTP/2 stream on port 8443 and receives text back. The runtime connects to the AssemblyAI-STT-3.7-Realtime-Agent SageMaker AI endpoint, which runs network isolated on GPUs. The endpoint reports usage to AWS Marketplace, billed per audio hour, and metrics to Amazon CloudWatch. Everything sits inside your AWS account. YOUR AWS ACCOUNT Your application voice agent or call analytics service SageMaker AI runtime bidirectional stream HTTP/2, port 8443 AssemblyAI-STT-3.7- Realtime-Agent SageMaker AI endpoint network isolated, GPUs AWS Marketplace billed per audio hour Amazon CloudWatch usage metrics and logs audio text usage metrics
The solution has the following components:
- Your application captures audio and sends it to the endpoint. It is typically a voice agent built with a framework such as LiveKit or Pipecat, or a contact-center service.
- SageMaker AI runtime carries the stream over HTTP/2 using the InvokeEndpointWithBidirectionalStream API and handles authentication with IAM.
- The SageMaker AI endpoint runs the AssemblyAI container on NVIDIA GPU instances with network isolation. The container serves streaming sessions, whole-file requests (InvokeEndpoint) and batch transform from one model package.
- AWS Marketplace bills the audio each session processes, per audio hour.
- Amazon CloudWatch receives the container's logs and usage metrics.
Prerequisites
To follow this walkthrough, you need:
- An AWS account with permissions to subscribe to AWS Marketplace products and create SageMaker AI models, endpoint configurations and endpoints.
- A SageMaker AI execution role with the AmazonSageMakerFullAccess managed policy.
- Service quota for at least one supported instance type in your Region, for example ml.g7e.2xlarge for endpoint usage.
- Python 3.12 or later, with the packages in the samples repository's requirements.txt. These include boto3 and aws-sdk-sagemaker-runtime-http2, the AWS SDK for SageMaker AI bidirectional streaming.
- A local clone of the assemblyai-sagemaker-samples repository. The code in this post comes from its stt-3-7-realtime-agent/ folder.
Solution walkthrough
The walkthrough has five steps: subscribe, deploy an endpoint, stream audio, control turn detection, and transcribe whole files. Each step uses code from the samples repository.
Step 1: Subscribe in AWS Marketplace
- Open the AssemblyAI Realtime Speech-to-Text for Voice Agents listing in AWS Marketplace and choose Continue to
- Review the pricing and the End User License Agreement, then choose Accept offer.
- Choose Continue to configuration, select version 3.7.0 and your Region, and copy the model package ARN. The ARN is specific to the Region.
Step 2: Deploy a real-time endpoint
Create a model from the package, an endpoint configuration and an endpoint. AWS Marketplace model packages run with network isolation, so the container has no outbound network access.
import boto3 sm = boto3.client("sagemaker") name = "stt-3-7-realtime-agent" sm.create_model( ModelName=name, PrimaryContainer={"ModelPackageName": "<model-package-arn>"}, ExecutionRoleArn="<sagemaker-execution-role-arn>", EnableNetworkIsolation=True, # required for Marketplace model packages ) sm.create_endpoint_config( EndpointConfigName=name, ProductionVariants=[{ "VariantName": "primary", "ModelName": name, "InitialInstanceCount": 1, "InstanceType": "ml.g7e.2xlarge", "InferenceAmiVersion": "al2023-ami-sagemaker-inference-gpu-4-1", # Send each new stream to the instance with the fewest open streams. "RoutingConfig": {"RoutingStrategy": "LEAST_OUTSTANDING_REQUESTS"}, "ModelDataDownloadTimeoutInSeconds": 1800, "ContainerStartupHealthCheckTimeoutInSeconds": 3600, }], ) sm.create_endpoint(EndpointName=name, EndpointConfigName=name) sm.get_waiter("endpoint_in_service").wait(EndpointName=name)
A few settings matter for this model:
- InferenceAmiVersion selects an AMI with NVIDIA driver 580, which the model uses natively.
- RoutingConfig set to LEAST_OUTSTANDING_REQUESTS keeps load even across instances. SageMaker AI counts an open stream as outstanding for as long as it is open.
- ContainerStartupHealthCheckTimeoutInSeconds allows time for the model to compile for the GPU at startup. The package ships a precompiled model for ml.g7, which reaches InService in about 9 minutes; other GPU types took 14 to 26 minutes in our tests.
If capacity for one instance type is tight in your Region, replace InstanceType with an InstancePools list of types with the same GPU, and SageMaker AI uses the first one it can place. The samples' deploy.py --instance-type ml.g7e.2xlarge,ml.g7e.4xlarge does this.
Step 3: Stream audio and receive transcripts
Open a stream with InvokeEndpointWithBidirectionalStream on the SageMaker AI runtime's HTTP/2 endpoint. Session options go in ModelQueryString. Every message on the stream follows the AssemblyAI Streaming v3 protocol: you send audio as binary payloads and control messages as JSON, and you receive Begin, Turn, Termination and Error messages.
import asyncio, json, boto3 from aws_sdk_sagemaker_runtime_http2.client import AsyncSageMakerRuntimeHTTP2Client from aws_sdk_sagemaker_runtime_http2.config import AsyncSageMakerRuntimeHTTP2Config from aws_sdk_sagemaker_runtime_http2.models import ( InvokeEndpointWithBidirectionalStreamInput, RequestPayloadPart, RequestStreamEventPayloadPart) from smithy_http.aio.crt import AWSCRTHTTPClient REGION, ENDPOINT = "us-east-1", "stt-3-7-realtime-agent" def part(data, data_type): return RequestStreamEventPayloadPart(value=RequestPayloadPart(bytes_=data, data_type=data_type)) async def transcribe(pcm_frames): # 16 kHz, 16-bit mono PCM, 50 ms per frame creds = boto3.Session().get_credentials().get_frozen_credentials() config = await AsyncSageMakerRuntimeHTTP2Config.resolve( region=REGION, endpoint_uri=f"https://runtime.sagemaker.{REGION}.amazonaws.com:8443", transport=AWSCRTHTTPClient(), aws_access_key_id=creds.access_key, aws_secret_access_key=creds.secret_key, aws_session_token=creds.token, ) async with AsyncSageMakerRuntimeHTTP2Client(config=config) as client: # one client per stream stream = await client.invoke_endpoint_with_bidirectional_stream( InvokeEndpointWithBidirectionalStreamInput( endpoint_name=ENDPOINT, model_query_string="sample_rate=16000&encoding=pcm_s16le")) async def send(): for frame in pcm_frames: await stream.input_stream.send(part(frame, "BINARY")) await asyncio.sleep(0.05) # real time await stream.input_stream.send(part(json.dumps({"type": "Terminate"}).encode(), "UTF8")) sender = asyncio.create_task(send()) _, output = await stream.await_output() while True: message = json.loads((await output.receive()).value.bytes_) if message["type"] == "Turn" and message["end_of_turn"]: print(message["turn_order"], message["transcript"]) if message["type"] == "Termination": break await sender
The full version, examples/stream_file.py, adds WAV loading, error handling and partial transcripts. Streaming the 30-second sample file prints partial and final transcripts as the audio plays. The final turns are:
$ python examples/stream_file.py stt-3-7-realtime-agent data/input/sample-30s.wav [0] FINAL This is a LibriVox recording. [1] FINAL All LibriVox recordings are in the public domain. [2] FINAL For more information and to find out how you can volunteer, please visit librivox.org. That's L-I-B-R-I-V-O-X dot org. [3] FINAL Recording by Annie Coleman in St. Louis, Missouri.
To improve recognition of names and product terms, add keyterms_prompt (up to 100 terms) or prompt to the session. To give the model the agent's last reply as context, send agent_context in an UpdateConfiguration message.
Step 4: Control turn detection
The model has built-in turn detection: by default it decides when each turn ends. The mode parameter picks how it trades latency against accuracy: balanced (the default), min_latency or max_accuracy. To tune it further, set min_turn_silence, the silence in milliseconds before the model checks whether the turn is complete, and max_turn_silence, the silence after which a turn always ends. Set these in model_query_string when you open the stream, or change them mid-session with an UpdateConfiguration message.
If your voice agent runs its own turn detection, such as voice activity detection (VAD) or push-to-talk, turn off the model's: open the session with mode=manual and send ForceEndpoint when your detector fires. The model ends the turn there and returns the final transcript right away, without waiting for silence of its own.
# Open the stream with model_query_string="sample_rate=16000&encoding=pcm_s16le&mode=manual" # ...then, when your VAD detects the end of speech: await stream.input_stream.send(part(json.dumps({"type": "ForceEndpoint"}).encode(), "UTF8"))
The samples' stream_file.py --force-endpoint shows this with a simple energy detector. In a production agent, call it from the VAD in your orchestration framework, such as Pipecat or LiveKit Agents.
Step 5: Transcribe whole files
The same endpoint transcribes complete files with InvokeEndpoint. Send a WAV, FLAC, OGG or MP3 file as the request body; pass options as JSON in CustomAttributes.
from botocore.config import Config smr = boto3.client("sagemaker-runtime", config=Config(read_timeout=70, retries={"max_attempts": 0})) with open("data/input/sample-10s.wav", "rb") as f: response = smr.invoke_endpoint(EndpointName=ENDPOINT, ContentType="audio/wav", Body=f.read()) print(json.loads(response["Body"].read())["text"]) # This is a LibriVox recording. All LibriVox recordings are in the public domain.
For large backlogs of recordings in Amazon S3, use SageMaker AI batch transform on ml.g6e.xlarge; examples/invoke_batch.py shows the job settings.
Sizing the endpoint
Size the endpoint by concurrent streams per GPU. The following figures keep latency low for voice agents. We measured them on SageMaker AI with concurrent streams that each end their turns with ForceEndpoint.
On an instance with several GPUs, the container runs one copy of the model per GPU and sends each new stream to the GPU with the fewest open streams. Capacity grows with the GPU count: in our tests an 8-GPU ml.g7.48xlarge carried 240 concurrent streams with the same latency as one GPU at 30.
To plan an endpoint, divide your peak concurrent streams by streams per GPU, then by GPUs per instance. For example, 500 concurrent calls on ml.g7e.2xlarge need 500 / 90 = 5.6, so 6 instances. Add headroom for growth and for an instance being replaced. Then scale the instance count with Application Auto Scaling. Usage metrics such as ConsumedUnits and AudioDurationSeconds are published to Amazon CloudWatch under the namespace AssemblyAI/STT-3.7-Realtime-Agent.
Pricing
The software charge is $0.45 per hour of audio ($0.0075 per minute), billed through AWS Marketplace by the exact duration of audio processed. A 12-minute call costs $0.09; nothing is rounded up, and failed requests aren't billed. You also pay the standard SageMaker AI charge for the instances behind the endpoint. Batch transform is billed at $2.25 per instance-hour on ml.g6e.xlarge. See the listing for current pricing and the free trial.
Clean up
To stop incurring charges, delete the endpoint, endpoint configuration and model:
sm.delete_endpoint(EndpointName=name) sm.delete_endpoint_config(EndpointConfigName=name) sm.delete_model(ModelName=name)
Or run python examples/deploy.py --delete. If you no longer need the product, cancel the subscription under Manage subscriptions in AWS Marketplace.
Get started
- Run the samples and notebook in .
- Read the AssemblyAI documentation for Amazon SageMaker AI.
- Learn more about SageMaker AI bidirectional streaming.
For help with sizing or a private offer, contact your AssemblyAI or AWS account team.
David Lange leads self-hosted deployments of AssemblyAI's speech models at AssemblyAI, including on Amazon SageMaker AI.












