Utilization-based metering for bidirectional streaming solves a software program billing downside for real-time speech AI. Prospects deploying streaming fashions on Amazon SageMaker AI bidirectional streaming pay for the endpoint infrastructure that hosts the mannequin. Individually, mannequin suppliers itemizing on AWS Market want a method to cost for what clients eat throughout a stay stream. Right now, we’re asserting usage-based metering for Amazon SageMaker bidirectional (bidi) streaming inference, so mannequin suppliers can report precise utilization for the AWS Market software program cost. Amazon SageMaker AI endpoint infrastructure fees nonetheless apply.
Deepgram, the real-time speech AI firm, is the launch accomplice for this functionality, bringing usage-based Speech-to-Textual content (STT) and Textual content-to-Speech (TTS) billing to AWS Market. This put up builds on a sequence of improvements between Deepgram and AWS. First, we launched bidirectional streaming for real-time inference on Amazon SageMaker AI, which helps long-lived bidirectional streams between shoppers and mannequin servers. Then, Deepgram enhanced Amazon SageMaker AI assist with AWS Id and Entry Administration (AWS IAM) momentary delegation, simplifying safe authentication for enterprise deployments, and expanded observability with enhanced metrics. Now, with usage-based metering, we additional strengthen the inspiration for manufacturing real-time AI, aligning billing with how clients eat streaming and real-time AI workloads.
Why streaming broke the present billing mannequin
With AWS Market software program metering for SageMaker AI real-time request-response inference, mannequin suppliers can report a unit rely in an HTTP response header. AWS Market makes use of that amount for the software program cost. This works for request-response APIs the place the billable amount is understood when the response is distributed.
Bidirectional streaming is completely different. A shopper streams audio and receives transcriptions by the SageMaker AI API utilizing an HTTP/2 occasion stream. SageMaker AI connects to the mannequin server over WebSockets. A session can final 30 seconds or half-hour. Utilization accumulates because the session runs, and the ultimate whole isn’t recognized till it ends. A response header alone can’t report periodic utilization throughout that stay session.
Hourly software program pricing can cost clients whereas a mannequin is offered, together with quiet durations. With usage-based metering, suppliers can align the AWS Market software program cost with reported utilization. SageMaker AI endpoint infrastructure fees stay separate and proceed to use whereas the endpoint is provisioned.
The answer introduces a second WebSocket connection alongside the present inference stream. When a bidirectional streaming session begins, SageMaker AI establishes two connections to the mannequin server:
- Knowledge connection: carries inference request and response information, the present bidirectional stream.
- Metadata connection: a companion WebSocket devoted to metering information.
Mannequin servers choose in by returning one header on the WebSocket improve response:
X-Amzn-SageMaker-Metadata-Stream-Supported: true
SageMaker AI then opens a companion WebSocket to the mannequin server at /invocations-bidirectional-stream-metadata. Each connections carry the identical X-Amzn-SageMaker-Request-Id header, which the mannequin server makes use of to correlate metering data with the lively inference session.
The mannequin server sends metering information as JSON textual content frames on the metadata connection. Ship data at a frequency that matches the billing mannequin: incrementally as utilization accrues (really useful), both as every unit is consumed or as periodic batches of items consumed because the earlier document. Ship any last document as quickly because the session ends. Every body comprises precisely one metering document, slightly than an array of data. The metadata stream has a fee quota of 1 message per second per connection, with a most message measurement of 512 bytes.
We advocate sending metering data incrementally as utilization accrues. This reduces the quantity of utilization left unreported if a session ends unexpectedly. Transport supply alone doesn’t set up that utilization has been billed. Validate reported items in opposition to AWS Market stories and purchaser fees.
Metering messages use the inference.rely dimension, and ConsumedUnits provides the amount for that dimension. If the product fees per second of audio, a document reporting 12 minutes of metered audio carries 720 seconds as ConsumedUnits: 720. The dimension title doesn’t imply one unit per request. The supplier defines which audio counts as metered utilization, and the AWS Market provide maps the unit to its value. The itemizing exhibits one value per unit, labeled per request, with as much as three decimal locations. The ClientToken subject helps idempotency. If a replica token arrives on the identical connection, SageMaker AI drops the duplicate message silently.
The metadata connection runs over TCP, which offers ordered, dependable supply on the transport layer. If it fails to ascertain or drops mid-session, inference continues by default as a result of X-Amzn-SageMaker-Metadata-Stream-Required defaults to false. Set this header to true when the supplier should cease inference if the metadata stream turns into unavailable. This alternative trades inference availability for metering continuity. It doesn’t assure that malformed or dropped data are billed.
What this implies for patrons
In case you deploy real-time AI fashions for transcription, contact facilities, voice brokers, or captioning, the brand new metering mannequin adjustments how the AWS Market software program cost is calculated. SageMaker AI endpoint infrastructure fees nonetheless apply.
Clear, per-unit billing by AWS Market means utilization flows immediately into your AWS invoice. You get consolidated AWS billing, negotiated charges by non-public provides, and no separate billing relationship with the mannequin supplier to handle.
Pay for audio processed in accordance with the product’s unit definition. If the product fees per second of audio, 12 minutes of metered audio equals 720 billable seconds and ConsumedUnits: 720. An open connection lasting 12 minutes doesn’t, by itself, outline the billable audio amount. The supplier’s counting guidelines decide the metered utilization, whereas endpoint infrastructure fees stay separate.
Mannequin suppliers can provide negotiated per-unit charges or fixed-price contracts by AWS Market non-public provides.
We advocate discussing immediately along with your AWS account consultant or accomplice consultant.
What this implies for mannequin suppliers
In case you’re a mannequin supplier itemizing on AWS Market, you may configure your mannequin server to report utilization throughout streaming inference classes by companion metadata streaming.
The SageMaker Market Onboarding Agent Ability accelerates onboarding with an opt-in inference metering path. Its starter templates promote metadata-stream assist and construct validated, incremental ConsumedUnits frames for the companion WebSocket. Assessment and production-harden the code earlier than submission.
Align billing along with your pricing mannequin by defining what one unit represents and reporting items because the session progresses. AWS Market fees one per-unit value for real-time inference.
The next three-step walkthrough describes the best way to combine your mannequin server to report metering information throughout bidirectional streaming inference classes.
When SageMaker AI opens the information WebSocket connection to your mannequin server, embrace these headers in your WebSocket improve (101) response:
| Header | Required | Values | Description | |
| 1 | X-Amzn-SageMaker-Metadata-Stream-Supported |
Sure (to choose in) | TRUE | Indicators that your mannequin server helps the companion metadata stream. If absent or not true, no metadata connection is tried. With out the metadata stream, the session shouldn’t be metered for the mannequin supplier’s software program cost. |
| 2 | X-Amzn-SageMaker-Metadata-Stream-Required |
No | true / false |
This header solely takes impact when X-Amzn-SageMaker-Metadata-Stream-Supported is true. If true, inference stops when the metadata connection fails. If false or absent, inference continues in data-only mode. Default: false. Select true when metering continuity takes precedence over inference availability. This setting doesn’t assure billing for malformed or dropped data. |
| 3 | X-Amzn-SageMaker-Metadata-Invocation-Path |
No | Customized path string | Overrides the default metadata WebSocket path. Default: /invocations-bidirectional-stream-metadata. |
Step 2: Settle for the metadata WebSocket connection
After your mannequin server returns X-Amzn-SageMaker-Metadata-Stream-Supported: true, SageMaker AI opens a second WebSocket connection to your mannequin server on the default path /invocations-bidirectional-stream-metadata (or the customized path you specified by utilizing X-Amzn-SageMaker-Metadata-Invocation-Path).
SageMaker AI consists of the header X-Amzn-SageMaker-Request-Id on each the information and metadata WebSocket handshakes. Your mannequin server should do the next:
- Settle for the WebSocket improve on the metadata path.
- Use
X-Amzn-SageMaker-Request-Idto correlate the metadata reference to the corresponding information connection for a similar inference session.
Step 3: Ship metering messages
Ship metering information as a JSON object in a WebSocket textual content body on the metadata connection. Every body should comprise precisely one metering document. On this instance, the product fees per second of audio, and the document stories 12 minutes of metered audio as 720 items:
Message fields:
| Area | Required | Kind | Constraints | Description | |
| 1 | Metering |
Sure | Object | — | Container for the metering document. |
| 2 | Metering.Dimension |
Sure | String | Have to be inference.rely |
The billing dimension. Have to be inference.rely. |
| 3 | Metering.ConsumedUnits |
Sure | Quantity | 0 or better | The items consumed since your earlier document. Every document is billed individually. A worth of 0 is accepted however not billed. |
| 4 | Metering.ClientToken |
No | String | Max 64 characters | A singular token (for instance, a UUID) for idempotency. If the identical ClientToken is distributed a number of occasions on the identical connection, solely the primary incidence is recorded. |
Ship metering data incrementally as utilization accrues to cut back unreported utilization if a session ends unexpectedly. Reconcile the reported portions with AWS Market stories and purchaser fees to confirm billing, together with interrupted-session assessments.
Constraints and limits
| Restrict | Worth | Notes | |
| 1 | Most message measurement | 512 bytes | Complete measurement of the JSON textual content body |
| 2 | Most ship fee | 1 message per second per connection | Exceeding this fee would possibly lead to dropped messages |
| 3 | Most Dimension size | 128 characters | — |
| 4 | Most ClientToken size | 64 characters | — |
| 5 | Messages per body | Precisely 1 | Don’t batch a number of metering data in a single body |
| 6 | Body kind | Textual content frames solely | Binary frames should not supported for metering |
Error dealing with and failure modes
The Required header controls what occurs when the metadata connection turns into unavailable. Set it to true to cease inference, or use the default false to let inference proceed in data-only mode. It is a alternative between metering continuity and inference availability. Malformed messages can nonetheless be dropped with both setting.
| State of affairs | Required = true | Required = false (default) | |
| 1 | Metadata WebSocket fails to attach | Knowledge stream is terminated | Knowledge stream continues usually (data-only mode) |
| 2 | Metadata WebSocket drops mid-session | Knowledge stream is terminated | Knowledge stream continues usually. Metering stops |
| 3 | Malformed metering message | Message is dropped. Metadata connection stays open | Message is dropped. Metadata connection stays open |
| 4 | Knowledge connection breaks mid-stream | Metadata stream is closed | Metadata stream is closed |
Checklist your mannequin on AWS Market
- Register your AWS account as an AWS Market vendor. For paid merchandise, full the tax and banking info.
- Create a SageMaker AI mannequin package deal out of your container in a supported publishing Area, and an AWS Id and Entry Administration (IAM) position that AWS Market can assume to learn it.
- In AWS Companion Central, select Construct, Machine studying, then Create machine studying product, and add the mannequin package deal as the primary model.
- Select per-inference pricing. You set one per-unit value for real-time inference throughout all occasion varieties, proven per request with as much as three decimal locations. You additionally set an hourly value for every batch remodel occasion kind. Select the pricing mannequin while you create the itemizing as a result of you may’t swap a launched itemizing between hourly and per-inference pricing.
- After validation, request Public visibility. For enterprise consumers, lengthen non-public provides with a negotiated per-unit fee or a fixed-price contract.
Validate billing earlier than launch
Validate the mixing with a Restricted itemizing and an allowlisted check purchaser. Use an acceptable provide, together with a non-public provide the place wanted, so the check workouts the supposed unit and value mapping.
- Run a known-quantity check. For a product priced per second of audio, ship 12 minutes of metered audio and test that the reported data whole 720 items.
- Reconcile the model-server data with the vendor’s utilization stories and the customer’s fees. Enable time for stories to populate and confirm the utilization kind
(for instance,-SMMP:inference.rely.m.i.c USE1-SMMP:inference.rely.m.i.cinus-east-1). Affirm the provide’s unit and value mapping slightly than assuming a set reporting delay. - Check regular completion, interrupted classes, metadata-stream loss, and malformed messages. Examine reported and billed portions for every case with the SageMaker AI and AWS Market groups earlier than launch.
- Delete check endpoints when testing is full to keep away from ongoing infrastructure fees.
Getting began with Deepgram on AWS Market
To deploy Deepgram with usage-based metering on SageMaker AI, comply with these steps.
- Subscribe to the Deepgram Voice AI streaming mannequin you want on AWS Market, equivalent to Deepgram Nova-3 Monolingual Speech-to-Textual content (STT) Streaming.
- Deploy a SageMaker AI real-time endpoint utilizing the Deepgram mannequin package deal out of your AWS Market subscription.
- Connect with the endpoint utilizing the SageMaker AI bidirectional streaming API and stream audio by its HTTP/2 occasion stream.
Deepgram’s mannequin server calculates metering mechanically, and Amazon SageMaker AI and AWS Market course of it. You don’t have to configure something on the shopper facet.
Clear up
While you end testing, delete the SageMaker AI real-time endpoint and mannequin useful resource to cease infrastructure fees. In case you now not want the product, take away the AWS Market subscription.
Conclusion
With usage-based metering for bidirectional streaming, mannequin suppliers can align AWS Market software program pricing with reported utilization throughout a stay session. Prospects pay the software program cost for the metered items outlined by the product and provide. Amazon SageMaker AI endpoint infrastructure fees stay separate and nonetheless apply. Study extra about Amazon SageMaker AI.
To get began:
Acknowledgements
Particular because of Kareem Syed-Mohammed (Principal Product Supervisor), Susmitha Marupaka (Product Advertising and marketing Supervisor), Zhengfei Ji (Software program Improvement Engineer for Amazon SageMaker AI), and EJ Ferrell for reviewing this put up and main the event of this functionality.
In regards to the authors


