You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(sagemaker): move SageMaker transport to separate package (#662)
## Summary
- Move the SageMaker transport out of the SDK into a standalone
[`deepgram-sagemaker`](https://github.com/deepgram/deepgram-python-sdk-transport-sagemaker)
package, since its AWS dependencies require Python >=3.12 but the SDK
supports >=3.8
- Consolidate the README's "Custom WebSocket Transport" and "SageMaker
Transport" sections into a single "Custom Transports" section that
explains the concept, shows how to build one (sync + async), and uses
`deepgram-sagemaker` as the real-world example
- Remove unused imports (`JSONDecodeError`, `websockets`) from socket
client files flagged by ruff F401
## Changes
| File | Change |
|------|--------|
| `src/deepgram/transports/sagemaker.py` | Deleted — moved to
`deepgram-sagemaker` package |
| `src/deepgram/transports/__init__.py` | Cleared SageMaker exports |
| `pyproject.toml` | Removed mypy overrides for AWS SDK modules |
| `README.md` | Consolidated custom transports section with
`deepgram-sagemaker` example |
| `examples/27-transcription-live-sagemaker.py` | Updated imports and
install instructions |
| `src/deepgram/*/socket_client.py` (×4) | Removed unused imports |
| `.fernignore` | Updated comments |
## Test plan
- [x] `ruff check src/` passes
- [x] `mypy src/deepgram/transports/` passes
- [x] No remaining `sagemaker`/`SageMaker` references in `src/deepgram/`
- [x] New `deepgram-sagemaker` package structure verified in
`../deepgram-python-sdk-transport-sagemaker/`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@
10
10
### Features
11
11
12
12
***helpers:** add TextBuilder class for TTS pronunciation and pause controls ([#660](https://github.com/deepgram/deepgram-python-sdk/issues/660)) ([4324120](https://github.com/deepgram/deepgram-python-sdk/commit/43241200a7e025bdc4633bdb47f6708921c82ad1))
13
-
***sagemaker:** add SageMaker transport for running Deepgram on AWS SageMaker endpoints ([#659](https://github.com/deepgram/deepgram-python-sdk/issues/659)) ([2046175](https://github.com/deepgram/deepgram-python-sdk/commit/204617538339b1958e2fe562dc94c8887de94a5d))
13
+
***sagemaker:** add SageMaker transport support via the separate [`deepgram-sagemaker`](https://pypi.org/project/deepgram-sagemaker/) package (`pip install deepgram-sagemaker`) ([#659](https://github.com/deepgram/deepgram-python-sdk/issues/659))
14
14
* v6 — fully generated SDK with latest APIs and WebSocket support ([#640](https://github.com/deepgram/deepgram-python-sdk/issues/640)) ([bc918fe](https://github.com/deepgram/deepgram-python-sdk/commit/bc918fe23e92eefb5e4c24cbfaad369d4e2818f3))
15
15
***websockets:** add custom WebSocket transport support ([#658](https://github.com/deepgram/deepgram-python-sdk/issues/658)) ([f6cf0fb](https://github.com/deepgram/deepgram-python-sdk/commit/f6cf0fbc9aaaa844e475e014560cc377819ec1f9))
Copy file name to clipboardExpand all lines: README.md
+17-12Lines changed: 17 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -335,11 +335,15 @@ client = DeepgramClient(
335
335
)
336
336
```
337
337
338
-
### Custom WebSocket Transport
338
+
### Custom Transports
339
339
340
340
Replace the built-in `websockets` transport with your own implementation for WebSocket-based APIs (Listen, Speak, Agent). This enables alternative protocols (HTTP/2, SSE), test doubles, or proxied connections.
341
341
342
-
Implement the `SyncTransport` or `AsyncTransport` protocol from `deepgram.transport_interface` and pass your class as `transport_factory`:
342
+
Any class that implements the right methods can be used as a transport — no inheritance required. Pass your class (or a factory callable) as `transport_factory` when creating a client.
343
+
344
+
#### Sync transports
345
+
346
+
Implement `send()`, `recv()`, `__iter__()`, and `close()`, then pass the class to `DeepgramClient`:
343
347
344
348
```python
345
349
from deepgram import DeepgramClient
@@ -361,7 +365,9 @@ with client.listen.v1.connect(model="nova-3") as connection:
361
365
connection.start_listening()
362
366
```
363
367
364
-
For async transports, implement `async def send()`, `async def recv()`, `async def __aiter__()`, and `async def close()`, then use `AsyncDeepgramClient`:
368
+
#### Async transports
369
+
370
+
Implement `async def send()`, `async def recv()`, `async def __aiter__()`, and `async def close()`, then use `AsyncDeepgramClient`:
365
371
366
372
```python
367
373
from deepgram import AsyncDeepgramClient
@@ -373,15 +379,19 @@ async with client.listen.v1.connect(model="nova-3") as connection:
373
379
await connection.start_listening()
374
380
```
375
381
376
-
See `src/deepgram/transport_interface.py` for the full protocol definitions.
382
+
See `src/deepgram/transport_interface.py` for the full protocol definitions (`SyncTransport` and `AsyncTransport`).
377
383
378
-
### SageMaker Transport
384
+
####SageMaker transport
379
385
380
-
The SDK includes a built-in transport for running Deepgram models on [AWS SageMaker](https://aws.amazon.com/sagemaker/) endpoints. It uses HTTP/2 bidirectional streaming under the hood, but exposes the same SDK interface — just swap in a `transport_factory`:
386
+
The [`deepgram-sagemaker`](https://pypi.org/project/deepgram-sagemaker/) package ([source](https://github.com/deepgram/deepgram-python-sdk-transport-sagemaker)) is a ready-made async transport for running Deepgram models on [AWS SageMaker](https://aws.amazon.com/sagemaker/) endpoints. It uses HTTP/2 bidirectional streaming under the hood, but exposes the same SDK interface — just install the package and swap in a `transport_factory`:
0 commit comments