AWS Marketplace (x402) and Deepgram
Let AI agents pay for Deepgram speech-to-text and text-to-speech per request, billed to their AWS account through AWS Marketplace and Amazon Bedrock AgentCore payments.
Agents can buy Deepgram Nova-3 speech-to-text and Deepgram Flux TTS and Aura-2 text-to-speech one request at a time, with no contract or Deepgram API key to manage. An agent calls https://x402.deepgram.com, pays each request’s price quote with Amazon Bedrock AgentCore payments, and gets the result. Charges are billed in USD to your AWS account under AWS Marketplace.
How to pay with AgentCore payments
The endpoints are sold pay-per-request through AWS Marketplace using x402. To call them, set up AgentCore payments in your AWS account: a Payment Manager with an AWS Billing connector, and a payment session with a spend limit. Your agent uses it to obtain the AWS Marketplace payment token.
- Send your request to one of the endpoints below. The API returns HTTP
402 Payment Required. ThePAYMENT-REQUIREDheader (base64 JSON) holds an AWS Marketplace x402 price quote: theacceptsentry withnetworkaws:base, whoseextra.quoteTokenis the signed quote. - Pass that
acceptsentry, unchanged, to AgentCore paymentsProcessPaymentwithpaymentTypeAWS_BILLING_X402. It returns a payment token. - Retry the same request with the payment token in the
PAYMENT-SIGNATUREheader, plus aDPoPheader if you bound the token to a key. - A successful call returns
200with your result. ThePAYMENT-RESPONSEheader contains your AWS Marketplace payment ID.
The AgentCore payments plugins for Strands Agents and LangGraph currently handle stablecoin (CRYPTO_X402) payments only. To pay AWS Marketplace quotes from those frameworks, call ProcessPayment from a tool, as the examples do.
How to call the x402 endpoints
Three batch endpoints, all POST and priced per request. Rates follow Deepgram pricing, and the 402 quote states the exact USD price of each request. Streaming (WebSocket) endpoints aren’t available through AWS Marketplace.
Speech-to-text
Endpoint: POST https://x402.deepgram.com/v1/listen
- Price: Deepgram’s pay-as-you-go pre-recorded rates for Deepgram Nova-3 (monolingual, or multilingual with
language=multi), plus any add-ons you use (keyterm,redact,detect_entities). - Query parameters: Deepgram
/v1/listenparameters, e.g.model=nova-3,language,smart_format=true,diarize=true.callbackisn’t supported; results are returned synchronously. - Body, hosted audio (recommended, any length):
Content-Type: application/json,{"url": "https://..."}. The URL must be fetchable by the API, e.g. an S3 presigned URL. - Body, raw audio up to ~4.5 MB:
Content-Type: audio/wav(oraudio/mpeg,audio/flac,audio/ogg), body = audio bytes. - Response: Deepgram transcript JSON.
Text-to-speech: Flux TTS (recommended)
Endpoint: POST https://x402.deepgram.com/v2/speak
- Price: Deepgram’s pay-as-you-go Flux TTS rate, per 1,000 input characters.
- Query parameters:
model(required; a Flux TTS voiceflux-{voice}-{language}, e.g.flux-haley-en), optionalencoding(mp3default,opus,flac,aac,linear16,mulaw,alaw),sample_rate,container,bit_rate,speed. - Body:
Content-Type: application/json,{"text": "..."}. - Response: audio bytes (MP3 by default).
Text-to-speech: Aura-2
Endpoint: POST https://x402.deepgram.com/v1/speak
- Price: Deepgram’s pay-as-you-go Aura-2 rate, per 1,000 input characters.
- Query parameters:
model(anaura-2voice, e.g.aura-2-thalia-en), optionalencoding,sample_rate,container. - Body:
Content-Type: application/json,{"text": "..."}. - Response: audio bytes (MP3 by default).
Paying a quote in Python
This sample shows the core of the flow with boto3 1.44.7 or later (pip install boto3 requests). PAYMENT_MANAGER_ARN, PAYMENT_SESSION_ID, and USER_ID are placeholders for a Payment Manager with an AWS Billing connector and a payment session created for that user. The examples repo has a setup script for both, and its client adds DPoP and error handling.
Notes
- A paid quote is valid for 5 minutes. A failed request (e.g. a
400for an unsupported parameter) doesn’t use up the payment. Retry with corrected parameters, as long as the new request costs no more than what you paid. - Supported models: Nova-3 (speech-to-text), Flux TTS voices on
/v2/speak, and Aura-2 voices on/v1/speak. - Payment tokens can be bound to a key with DPoP (RFC 9449). The proof must be signed for
POSTand the request URL without its query string, and includeath, the hash of the payment token. - AgentCore payments: setup, IAM roles, troubleshooting AWS Billing errors.