Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Stream call audio in real-time, fork media to external destinations, and transcribe speech live. Use for real-time analytics and AI integrations. This skill provides Python SDK examples.
.claude/skills/team-telnyx-telnyx-voice-streaming-python/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 99% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 96% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 51% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 152% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 128% | 0% |
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
bashpip install telnyx
pythonimport os from telnyx import Telnyx client = Telnyx( api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted )
All examples below assume client is already initialized as shown above.
All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:
pythonimport telnyx try: result = client.messages.send(to="+13125550001", from_="+13125550002", text="Hello") except telnyx.APIConnectionError: print("Network error — check connectivity and retry") except telnyx.RateLimitError: # 429: rate limited — wait and retry with exponential backoff import time time.sleep(1) # Check Retry-After header for actual delay except telnyx.APIStatusError as e: print(f"API error {e.status_code}: {e.message}") if e.status_code == 422: print("Validation error — check required fields and formats")
Common error codes: 401 invalid API key, 403 insufficient permissions, 404 resource not found, 422 validation error (check field formats), 429 rate limited (retry with exponential backoff).
Call forking allows you to stream the media from a call to a specific target in realtime. This stream can be used to enable realtime audio analysis to support a variety of use cases, including fraud detection, or the creation of AI-generated audio responses. Requests must specify either the target attribute or the rx and tx attributes.
POST /calls/{call_control_id}/actions/fork_start
Optional: client_state (string), command_id (string), rx (string), stream_type (enum: decrypted), tx (string)
pythonresponse = client.calls.actions.start_forking( call_control_id="550e8400-e29b-41d4-a716-446655440000", ) print(response.data)
Returns: result (string)
Stop forking a call. Expected Webhooks:
call.fork.stoppedPOST /calls/{call_control_id}/actions/fork_stop
Optional: client_state (string), command_id (string), stream_type (enum: raw, decrypted)
pythonresponse = client.calls.actions.stop_forking( call_control_id="550e8400-e29b-41d4-a716-446655440000", ) print(response.data)
Returns: result (string)
Start streaming the media from a call to a specific WebSocket address or Dialogflow connection in near-realtime. Audio will be delivered as base64-encoded RTP payload (raw audio), wrapped in JSON payloads. Please find more details about media streaming messages specification under the link.
POST /calls/{call_control_id}/actions/streaming_start
Optional: client_state (string), command_id (string), custom_parameters (arrayobject]), dialogflow_config (object), enable_dialogflow (boolean), stream_auth_token (string), stream_bidirectional_codec (enum: PCMU, PCMA, G722, OPUS, AMR-WB, L16), stream_bidirectional_mode (enum: mp3, rtp), stream_bidirectional_sampling_rate (enum: 8000, 16000, 22050, 24000, 48000), stream_bidirectional_target_legs (enum: both, self, opposite), stream_codec (enum: PCMU, PCMA, G722, OPUS, AMR-WB, L16, default), stream_track (enum: inbound_track, outbound_track, both_tracks), stream_url (string)
pythonresponse = client.calls.actions.start_streaming( call_control_id="550e8400-e29b-41d4-a716-446655440000", stream_url="wss://example.com/audio-stream", ) print(response.data)
Returns: result (string)
Stop streaming a call to a WebSocket. Expected Webhooks:
streaming.stoppedPOST /calls/{call_control_id}/actions/streaming_stop
Optional: client_state (string), command_id (string), stream_id (uuid)
pythonresponse = client.calls.actions.stop_streaming( call_control_id="550e8400-e29b-41d4-a716-446655440000", ) print(response.data)
Returns: result (string)
Start real-time transcription. Transcription will stop on call hang-up, or can be initiated via the Transcription stop command. Expected Webhooks:
call.transcriptionPOST /calls/{call_control_id}/actions/transcription_start
Optional: client_state (string), command_id (string), transcription_engine (enum: Google, Telnyx, Deepgram, Azure, xAI, AssemblyAI, Speechmatics, Soniox, Parakeet, A, B), transcription_engine_config (object), transcription_tracks (string)
pythonresponse = client.calls.actions.start_transcription( call_control_id="550e8400-e29b-41d4-a716-446655440000", ) print(response.data)
Returns: result (string)
Stop real-time transcription.
POST /calls/{call_control_id}/actions/transcription_stop
Optional: client_state (string), command_id (string)
pythonresponse = client.calls.actions.stop_transcription( call_control_id="550e8400-e29b-41d4-a716-446655440000", ) print(response.data)
Returns: result (string)
Telnyx signs webhooks with Ed25519. Each request includes telnyx-signature-ed25519 and telnyx-timestamp headers. Always verify signatures in production:
python# In your webhook handler (e.g., Flask — use raw body, not parsed JSON): @app.route("/webhooks", methods=["POST"]) def handle_webhook(): payload = request.get_data(as_text=True) # raw body as string headers = dict(request.headers) try: event = client.webhooks.unwrap(payload, headers=headers) except Exception as e: print(f"Webhook verification failed: {e}") return "Invalid signature", 400 # Signature valid — event is the parsed webhook payload print(f"Received event: {event.data.event_type}") return "OK", 200
The following webhook events are sent to your configured webhook URL. All webhooks include telnyx-timestamp and telnyx-signature-ed25519 headers for Ed25519 signature verification. Use client.webhooks.unwrap() to verify.
| Event | Description | |-------|-------------| | callForkStarted | Call Fork Started | | callForkStopped | Call Fork Stopped | | callStreamingFailed | Call Streaming Failed | | callStreamingStarted | Call Streaming Started | | callStreamingStopped | Call Streaming Stopped | | transcription | Transcription |
callForkStarted
| Field | Type | Description | |-------|------|-------------| | data.record_type | enum: event | Identifies the type of the resource. | | data.event_type | enum: call.fork.started | The type of event being delivered. | | data.id | uuid | Identifies the type of resource. | | data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. | | data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. | | data.payload.call_control_id | string | Unique ID for controlling the call. | | data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. | | data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook events. | | data.payload.client_state | string | State received from a command. | | data.payload.stream_type | enum: decrypted | Type of media streamed. |
callForkStopped
| Field | Type | Description | |-------|------|-------------| | data.record_type | enum: event | Identifies the type of the resource. | | data.event_type | enum: call.fork.stopped | The type of event being delivered. | | data.id | uuid | Identifies the type of resource. | | data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. | | data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. | | data.payload.call_control_id | string | Unique ID for controlling the call. | | data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. | | data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook events. | | data.payload.client_state | string | State received from a command. | | data.payload.stream_type | enum: decrypted | Type of media streamed. |
callStreamingFailed
| Field | Type | Description | |-------|------|-------------| | data.record_type | enum: event | Identifies the resource. | | data.event_type | enum: streaming.failed | The type of event being delivered. | | data.id | uuid | Identifies the type of resource. | | data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. | | data.payload.call_control_id | string | Call ID used to issue commands via Call Control API. | | data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. | | data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. | | data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook events. | | data.payload.client_state | string | State received from a command. | | data.payload.failure_reason | string | A short description explaning why the media streaming failed. | | data.payload.stream_id | uuid | Identifies the streaming. | | data.payload.stream_type | enum: websocket, dialogflow | The type of stream connection the stream is performing. |
callStreamingStarted
| Field | Type | Description | |-------|------|-------------| | data.record_type | enum: event | Identifies the type of the resource. | | data.event_type | enum: streaming.started | The type of event being delivered. | | data.id | uuid | Identifies the type of resource. | | data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. | | data.payload.call_control_id | string | Call ID used to issue commands via Call Control API. | | data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. | | data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. | | data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook events. | | data.payload.client_state | string | State received from a command. | | data.payload.stream_url | string | Destination WebSocket address where the stream is going to be delivered. |
callStreamingStopped
| Field | Type | Description | |-------|------|-------------| | data.record_type | enum: event | Identifies the type of the resource. | | data.event_type | enum: streaming.stopped | The type of event being delivered. | | data.id | uuid | Identifies the type of resource. | | data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. | | data.payload.call_control_id | string | Call ID used to issue commands via Call Control API. | | data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. | | data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. | | data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook events. | | data.payload.client_state | string | State received from a command. | | data.payload.stream_url | string | Destination WebSocket address where the stream is going to be delivered. |
transcription
| Field | Type | Description | |-------|------|-------------| | data.record_type | enum: event | Identifies the type of the resource. | | data.event_type | enum: call.transcription | The type of event being delivered. | | data.id | uuid | Identifies the type of resource. | | data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. | | data.payload.call_control_id | string | Unique identifier and token for controlling the call. | | data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. | | data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook events. | | data.payload.client_state | string | Use this field to add state to every subsequent webhook. | | data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→pass | 11,536 | 18,496 | +60% | 1 | 1 | 0% | 2,508 | 4,980 | +99% | 0 | 0 | — |
case-07 | fail→pass | 12,394 | 3,648 | -71% | 1 | 1 | 0% | 2,295 | 4,491 | +96% | 0 | 0 | — |
case-20 | pass→pass | 6,228 | 5,966 | -4% | 1 | 1 | 0% | 1,302 | 5,052 | +288% | 0 | 0 | — |
case-01 | fail→pass | 18,181 | 7,861 | -57% | 1 | 1 | 0% | 3,686 | 5,570 | +51% | 0 | 0 | — |
case-03 | fail→pass | 12,970 | 13,713 | +6% | 1 | 1 | 0% | 2,766 | 6,980 | +152% | 0 | 0 | — |
case-04 | fail→pass | 10,449 | 4,454 | -57% | 1 | 1 | 0% | 2,057 | 4,697 | +128% | 0 | 0 | — |
case-05 | fail→pass | 6,848 | 3,542 | -48% | 1 | 1 | 0% | 1,393 | 4,567 | +228% | 0 | 0 | — |
case-06 | fail→pass | 9,147 | 6,477 | -29% | 1 | 1 | 0% | 1,876 | 5,177 | +176% | 0 | 0 | — |
case-08 | fail→pass | 11,661 | 5,589 | -52% | 1 | 1 | 0% | 2,318 | 5,084 | +119% | 0 | 0 | — |
case-09 | fail→pass | 12,779 | 9,060 | -29% | 1 | 1 | 0% | 2,665 | 5,638 | +112% | 0 | 0 | — |
case-10 | pass→pass | 8,535 | 3,725 | -56% | 1 | 1 | 0% | 1,630 | 4,496 | +176% | 0 | 0 | — |
case-11 | pass→pass | 4,913 | 3,287 | -33% | 1 | 1 | 0% | 889 | 4,433 | +399% | 0 | 0 | — |
case-12 | fail→pass | 9,560 | 4,272 | -55% | 1 | 1 | 0% | 1,673 | 4,625 | +176% | 0 | 0 | — |
case-13 | fail→pass | 8,953 | 1,890 | -79% | 1 | 1 | 0% | 1,596 | 4,170 | +161% | 0 | 0 | — |
case-14 | pass→pass | 13,102 | 5,841 | -55% | 1 | 1 | 0% | 2,523 | 5,174 | +105% | 0 | 0 | — |
case-15 | fail→pass | 10,772 | 5,213 | -52% | 1 | 1 | 0% | 1,974 | 4,785 | +142% | 0 | 0 | — |
case-16 | fail→pass | 7,380 | 6,960 | -6% | 1 | 1 | 0% | 1,415 | 4,609 | +226% | 0 | 0 | — |
case-17 | fail→pass | 12,219 | 4,448 | -64% | 1 | 1 | 0% | 2,191 | 4,703 | +115% | 0 | 0 | — |
case-18 | pass→pass | 6,528 | 1,939 | -70% | 1 | 1 | 0% | 1,073 | 4,124 | +284% | 0 | 0 | — |
case-19 | pass→pass | 3,630 | 1,996 | -45% | 1 | 1 | 0% | 566 | 4,120 | +628% | 0 | 0 | — |
case-21 | fail→pass | 3,572 | 3,799 | +6% | 1 | 1 | 0% | 683 | 4,595 | +573% | 0 | 0 | — |
case-22 | fail→pass | 6,564 | 6,065 | -8% | 1 | 1 | 0% | 1,271 | 5,060 | +298% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +73 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.