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).
pip install deepgram-sagemakerThis installs aws-sdk-sagemaker-runtime-http2 and boto3 automatically.
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())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)