Skip to content

Commit 49c6e26

Browse files
committed
feat: mention keep alive in migration guide
1 parent 3abbac3 commit 49c6e26

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

docs/Migrating-v3-to-v5.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This guide helps you migrate from Deepgram Python SDK v3+ (versions 3.0.0 to 4.8
1616
- [Models V1](#models-v1)
1717
- [Manage V1](#manage-v1)
1818
- [Self-Hosted V1](#self-hosted-v1)
19+
- [Keep Alive Functionality](#websocket-keep-alive-functionality)
1920
- [Breaking Changes Summary](#breaking-changes-summary)
2021

2122
## Installation
@@ -857,15 +858,57 @@ response = client.self_hosted.v1.distribution_credentials.delete(
857858
)
858859
```
859860

861+
## WebSocket Keep Alive Functionality
862+
863+
**v3+ (3.0.0 - 4.8.1)**
864+
865+
```python
866+
# Keep alive was passed as a config option
867+
config = DeepgramClientOptions(
868+
options={"keepalive": "true"}
869+
)
870+
deepgram = DeepgramClient(API_KEY, config)
871+
```
872+
873+
**v5.0.0**
874+
875+
```python
876+
# Keep alive is now manually managed via control messages.
877+
from deepgram.extensions.types.sockets import ListenV1ControlMessage, AgentV1ControlMessage
878+
879+
# For Listen V1 connections
880+
with client.listen.v1.connect(model="nova-3") as connection:
881+
# Send keep alive message
882+
connection.send_control(ListenV1ControlMessage(type="KeepAlive"))
883+
884+
# For Agent V1 connections
885+
with client.agent.v1.connect() as agent:
886+
# Send keep alive message
887+
agent.send_control(AgentV1ControlMessage(type="KeepAlive"))
888+
```
889+
890+
**Key Changes:**
891+
892+
1. **WebSocket Library Upgrade**: The SDK upgraded to `websockets>=12.0`, which introduced some internal changes to connection handling.
893+
894+
2. **Parameter Name Changes**:
895+
- **Sync connections**: Continue to use `additional_headers` parameter
896+
- **Async connections**: Now use `extra_headers` parameter (changed from `additional_headers`)
897+
898+
3. **Keep Alive Control Messages**: The keep alive functionality itself remains unchanged - you still send `KeepAlive` control messages using the `send_control()` method.
899+
900+
4. **Connection Management**: The underlying WebSocket connection management has been updated to use the newer websockets library API, but the public interface for keep alive remains the same.
901+
860902
## Breaking Changes Summary
861903

862904
### Major Changes
863905

864906
1. **Authentication**: New access token support with environment variable `DEEPGRAM_TOKEN`
865907
2. **API structure**: Flattened method names and cleaner parameter passing
866908
3. **WebSocket API**: Complete redesign with context managers and typed message objects
867-
4. **Type safety**: Enhanced type annotations and response objects
868-
5. **Error handling**: Improved error types and handling
909+
4. **WebSocket Keep Alive**: Managed via control messages, no longer an automatic thing via config
910+
5. **Type safety**: Enhanced type annotations and response objects
911+
6. **Error handling**: Improved error types and handling
869912

870913
### Removed Features
871914

@@ -890,5 +933,6 @@ response = client.self_hosted.v1.distribution_credentials.delete(
890933
- [ ] Replace API key configuration with new authentication methods
891934
- [ ] Update all API method calls to new structure
892935
- [ ] Migrate WebSocket connections to new context manager pattern
936+
- [ ] Update WebSocket keep alive implementation
893937
- [ ] Update error handling for new exception types
894938
- [ ] Test all functionality with new API structure

0 commit comments

Comments
 (0)