Skip to main content

Deepgram SageMaker Transport

PyPI version Python 3.12+ MIT License

SageMaker transport for the Deepgram Python SDK. Uses AWS SageMaker's HTTP/2 bidirectional streaming API as an alternative to WebSocket, allowing transparent switching between Deepgram Cloud and Deepgram on SageMaker.

Requires Python 3.12+ (due to AWS SDK dependencies).

Installation

pip install "deepgram-sdk>=7.8.1,<8.0.0" deepgram-sagemaker

deepgram-sagemaker installs aws-sdk-sagemaker-runtime-http2 0.11.x with its awscrt extra, plus boto3. awscrt uses a compiled extension; supported platforms install a wheel, while source builds require a C toolchain.

Usage

The SageMaker transport is async-only and must be used with AsyncDeepgramClient:

import asyncio
from deepgram import AsyncDeepgramClient
from deepgram.core.events import EventType
from deepgram_sagemaker import SageMakerTransportFactory

factory = SageMakerTransportFactory(
    endpoint_name="my-deepgram-endpoint",
    region="us-west-2",
)

# SageMaker uses AWS credentials (not Deepgram API keys)
client = AsyncDeepgramClient(api_key="unused", transport_factory=factory)

async def main():
    async with client.listen.v1.connect(model="nova-3") as connection:
        connection.on(EventType.MESSAGE, lambda msg: print(msg))
        await connection.start_listening()

asyncio.run(main())

Configuration

For burst-tuned timeouts and retry behavior, build a SageMakerConfig and pass it via config=:

from deepgram_sagemaker import SageMakerConfig, SageMakerTransportFactory

config = SageMakerConfig(
    endpoint_name="my-deepgram-endpoint",
    region="us-east-2",
    connection_timeout=5.0,
    connection_acquire_timeout=15.0,
)
factory = SageMakerTransportFactory(config=config)

All time-based fields are float seconds (matching asyncio convention).

Parameter Required Default Description
endpoint_name Yes — SageMaker endpoint name
region No us-west-2 AWS region
connection_timeout No 30.0 Max time for the underlying TCP/TLS connect (AWS default is ~2 s — bumped here so cold-start endpoints under burst load have time to accept TLS handshakes).
connection_acquire_timeout No 60.0 Max time to acquire a connection from the underlying HTTP/2 pool (AWS default is ~10 s — bumped so a 200–500-stream burst doesn't drain the acquire pool).
subscription_timeout No 60.0 Max time the transport waits for the SageMaker bidi stream to open before failing. A timeout here is treated as a transient connect failure and counts against max_retries / retry_budget.
max_concurrency No 500 Cap on simultaneous in-flight HTTP/2 streams. Advisory in Python today (the underlying smithy HTTP/2 stack does not expose a hard cap), but kept for surface parity with the Java transport.
max_retries No 5 Max retries on transient AWS errors (throttling, pool-exhausted, transient connect/timeout). Set to 0 to disable internal retry. Terminal errors (auth, validation) bypass this.
initial_backoff No 0.1 First backoff delay applied after the initial failure.
max_backoff No 5.0 Cap on the per-attempt backoff delay regardless of multiplier.
backoff_multiplier No 2.0 Exponential growth factor between retry attempts. Must be >= 1.0.
retry_budget No 30.0 Total wall-clock cap across all retry attempts before giving up and surfacing the error to the application.
max_replay_buffer_bytes No 8 * 1024 * 1024 Cap on the in-memory replay buffer that holds sent-but-unacked stream events. Set to 0 to disable replay (sent events are dropped on internal reset).

High-concurrency notes

The transport's defaults are tuned for high-burst workloads (large numbers of streams opened in a tight loop against an endpoint that may need to scale up). If you're opening 200–500 streams simultaneously against a cold endpoint, the AWS SDK's general-purpose defaults (~2 s connect, ~10 s acquire) will fire before the load balancer has accepted all of the inbound TLS handshakes — you will see a wave of acquire / connect timeouts that look like server-side problems but are really client-side fail-fast tripping early.

This transport ships with more lenient defaults (30 s / 60 s) so the common high-concurrency path works out of the box. Tighten them if you need fail-fast behavior in low-latency pipelines:

config = SageMakerConfig(
    endpoint_name="my-deepgram-endpoint",
    region="us-east-2",
    connection_timeout=5.0,
    connection_acquire_timeout=15.0,
)

Retry & storm absorption

Transient AWS-side failures (ThrottlingException, connection-pool exhaustion, transient connect/timeout failures) are absorbed by the transport itself: classified as retryable, retried with jittered exponential backoff up to max_retries and retry_budget, with messages buffered during the reset window replayed onto the new stream so audio isn't dropped. Only terminal errors (auth, validation, resource-not-found) and budget-exhausted retryable errors propagate to the application.

config = SageMakerConfig(
    endpoint_name="my-deepgram-endpoint",
    max_retries=10,
    initial_backoff=0.2,
    max_backoff=10.0,
    retry_budget=60.0,
)

Set max_retries=0 to disable internal retry entirely (every transient AWS error then surfaces immediately to the application).

AWS Credentials

The transport resolves AWS credentials using boto3's credential chain:

  • Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
  • Shared credentials file (~/.aws/credentials)
  • IAM role (EC2, ECS, Lambda)

Metadata

Release files for deepgram-sagemaker 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deepgram-sagemaker 0.4.0
File Size Uploaded
deepgram_sagemaker-0.4.0.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for deepgram-sagemaker 0.4.0
File Interpreter ABI Platform
deepgram_sagemaker-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.2 kB

Release files / deepgram_sagemaker-0.4.0.tar.gz

Download URL deepgram_sagemaker-0.4.0.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
08ea0f6b82e2b720eafba0aef22d2f57abfdb621de80d0bd01b07a3457301b72
BLAKE2b-256 checksum
How to use checksums
b97ebc4daead7f4ad62095905b12610ca6ca004c97fa509f7fe287b8162310e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release files / deepgram_sagemaker-0.4.0-py3-none-any.whl

Download URL deepgram_sagemaker-0.4.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21d4f176c420098e3dfbbc2e2bb6e94d806e971cdc975b5c534e57ac2deb5ed9
BLAKE2b-256 checksum
How to use checksums
5e11416262c25f09806474888fe87ec74622c241513fb63ce85e7eb0901fa7b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page