1226* **Opt-in both ways.** No history replays unless the resuming session also sends `resumption.enabled: true`.1226* **Opt-in both ways.** No history replays unless the resuming session also sends `resumption.enabled: true`.
1227* **Expiry.** History is dropped after 30 minutes of inactivity.1227* **Expiry.** History is dropped after 30 minutes of inactivity.
1228 1228
1229## DTMF (SIP Phone Keypresses)
1230
1231When using the Voice Agent API over SIP, phone keypresses (DTMF tones) are automatically buffered and flushed to the model as text input. The client receives `input_audio_buffer.dtmf_event_received` events as an audit trail of each keypress.
1232
1233### Flush Triggers
1234
1235Buffered digits are submitted to the model when any of the following occurs:
1236
1237* The user presses `#` (submit key)
1238* 2.5 seconds of idle time after the last keypress
1239* The user begins speaking (preempts the digit buffer)
1240
1241### Audit Event
1242
1243Each keypress is reported to the client WebSocket:
1244
1245```json customLanguage="json"
1246{
1247 "type": "input_audio_buffer.dtmf_event_received",
1248 "event": "5",
1249 "received_at": 1730000000
1250}
1251```
1252
1253> [!NOTE]
1254>
1255> DTMF is only available on SIP sessions — it is not emitted on direct WebSocket connections.
1256
1257## Best Practices1229## Best Practices
1258 1230
1259This section outlines key recommendations for building low-latency, reliable, and natural-feeling voice experiences using the xAI Voice Agent API.1231This section outlines key recommendations for building low-latency, reliable, and natural-feeling voice experiences using the xAI Voice Agent API.
1375 1347
1376* **Domain Expertise** — Precise transcription of medical, legal, financial, and technical terminology — names, codes, and addresses.1348* **Domain Expertise** — Precise transcription of medical, legal, financial, and technical terminology — names, codes, and addresses.
1377 1349
13781350## Telephony Providers## SIP phone calls
1379
1380Use Direct SIP to route calls from your carrier or PBX into a voice agent. Configure your provider to send calls to the xAI SIP host.
1381
1382| Value | Use |
1383|-------|-----|
1384| SIP host | `sip.voice.x.ai` |
1385| SIP URI | `sip:{number}@sip.voice.x.ai;transport=tls` |
1386
1387Replace `{number}` with your Direct SIP phone number. If you restrict inbound calls by source IP, add your provider's signaling CIDR ranges to the allowlist before testing.
1388
1389#### Twilio
1390
13911. In the Twilio Console, create a TwiML Bin and paste the following:
1392
1393```text
1394<Response>
1395 <Dial answerOnBridge="true">
1396 <Sip>sip:{number}@sip.voice.x.ai;transport=tls</Sip>
1397 </Dial>
1398</Response>
1399```
1400
14012. Open your number's Voice configuration and set the handler to this TwiML Bin.
14023. Place a test call to confirm the agent answers.
1403
1404#### Telnyx
1405
14061. In the Telnyx Portal, create a SIP Connection (FQDN) and an Outbound Voice Profile.
14072. Set the connection's outbound destination to `sip.voice.x.ai`.
14083. Place a test call to confirm the agent answers.
1409
1410#### Microsoft Teams
1411
14121. Stand up a Microsoft-certified SBC (Ribbon, AudioCodes, or Cisco CUBE) with an outbound SIP trunk to `sip.voice.x.ai`.
14132. In the Teams admin center, go to **Voice** → **Direct Routing** → **Add** and register the SBC's public FQDN as a PSTN gateway.
14143. From the Teams PowerShell module, create a voice route and routing policy (`New-CsOnlineVoiceRoute` / `New-CsOnlineVoiceRoutingPolicy`) and grant the policy to your users.
1415
1416#### Cisco Webex Calling
1417
14181. Stand up a Local Gateway (Cisco CUBE or equivalent SBC) with an outbound dial-peer to `sip.voice.x.ai`.
14192. In Webex Control Hub, go to **Calling** → **Locations** → **Add trunk**, choose **Premises-based**, and point it at the Local Gateway's FQDN.
14203. Under **Calling** → **Dial Plans**, route the relevant numbers or prefixes to the new trunk.
1421
1422#### Genesys Cloud
1423
14241. In Genesys Cloud Admin, go to **Telephony** → **Trunks** → **Create New** and pick an External Trunk of type SIP.
14252. Under **SIP Servers or Proxies**, add `sip.voice.x.ai`.
14263. In **Routing** → **Architect Flows**, add a Transfer to External action to the agent's SIP URI and assign a DID to the flow.
1427
1428#### NICE CXone
1429
14301. In CXone Admin, go to **Voice** → **SIP Connectivity** → **Create New** and pick External SIP.
14312. Set the trunk's Destination to `sip.voice.x.ai`.
14323. In Studio, add a SIP Transfer action targeting the agent's SIP URI and assign a DID to the script.
1433
1434#### Amazon Chime SDK
1435
14361. In the AWS console, open **Amazon Chime SDK** → **Voice Connectors** → **Create Voice Connector** and enable Encryption.
14372. On the connector's **Termination** tab, add `sip.voice.x.ai` and allowlist your origination CIDR ranges.
14383. Assign your DIDs, then add a SIP rule that bridges inbound calls out to the agent's SIP URI.
1439
1440#### Amazon Connect
1441
14421. Create an Amazon Chime SDK Voice Connector with Encryption enabled.
14432. On the Voice Connector's **Termination** tab, add `sip.voice.x.ai`.
14443. In your Connect contact flow, add a Lambda block that dials out through the Voice Connector to the agent's SIP URI, passing contact attributes as SIP headers.
1445
1446#### RingCentral
1447
14481. Confirm BYOC is enabled on your plan (Ultimate or Premium).
14492. In the admin portal, go to **Phone System** → **Phone Numbers** → **Carriers** → **Add Carrier** and set the endpoint to `sip.voice.x.ai`.
14503. Under **Phone Numbers**, route the DIDs you want through this carrier.
1451
1452#### Zoom Phone
1453
14541. Make sure BYOC is enabled on your Zoom account.
14552. In the Zoom admin, go to **Phone System Management** → **Carrier Configuration** → **Add Carrier Trunk** and set the trunk address to `sip.voice.x.ai`.
14563. Under the BYOC settings, assign the DIDs you want routed through this trunk.
1457
1458#### Generic SIP / Other
1459 1351
146013521. In your carrier or PBX, create an outbound route or SIP trunk.Route PSTN, contact-center, or PBX calls into a Voice Agent API session. See [SIP Phone Calls](/developers/model-capabilities/audio/voice-agent/sip) for Agent Builder setup, API integration with `CreatePhoneNumberV2`, call control, DTMF, and telephony provider examples.
14612. Point its destination at `sip.voice.x.ai`.
14623. Place a test call to confirm the agent answers.
1463 1353
1464## Migrating from OpenAI Realtime1354## Migrating from OpenAI Realtime
1465 1355