some-grass-64312
12/09/2025, 9:31 AMtall-airline-16756
12/09/2025, 9:31 AMtall-airline-16756
12/09/2025, 9:32 AMapi.LiveKitAPI.sip.create_sip_participant() and api.LiveKitAPI.agent_dispatch.create_dispatch() can be called without await using the Python SDK.
Those Python SDK methods are asynchronous and expect to run inside an async event loop — there is no built-in synchronous wrapper that avoids await. If you need to call them from synchronous code, you can run the coroutine on an event loop. Options:
• Use asyncio.run() from top-level sync code:
import asyncio
async def call():
await api.LiveKitAPI.sip.create_sip_participant(...)
asyncio.run(call())
• Run the coroutine on an existing loop (e.g., in a thread where an event loop is running) using `asyncio.get_event_loop().run_until_complete(...)`:
loop = asyncio.get_event_loop()
loop.run_until_complete(api.LiveKitAPI.sip.create_sip_participant(...))
• If your app is primarily synchronous and you must avoid touching the main thread event loop, run an event loop in a separate thread and submit coroutines to it (e.g., with loop.call_soon_threadsafe + asyncio.run_coroutine_threadsafe).
If you want, tell me whether you’re in a script, web framework, or threaded app and I’ll show the exact pattern/code best suited for your environment.
Sources: SIP APIs | LiveKit docs | Make outbound calls | LiveKit docs | Agents telephony integration | LiveKit docs | Creating SIP Inbound Trunks and Dispatch Rules with Python SDKsome-grass-64312
12/09/2025, 9:35 AMtall-airline-16756
12/09/2025, 9:35 AMawait.
What you can do
• Call the Twirp endpoints directly (HTTP POST) for:
◦ Create SIP participant: /twirp/livekit.SIP/CreateSIPParticipant
◦ Create dispatch rule: /twirp/livekit.SIP/CreateSIPDispatchRule
• Use any synchronous HTTP client (e.g., Python requests, curl, Go http client).
What you need
• A JWT signed with your API key/secret that includes the sip grants (call for creating participants, admin for dispatch rules) and video.roomJoin as needed.
• Content-Type: application/json and Authorization: Bearer <JWT> headers.
Example (synchronous Python with requests)
import requests
url = "https://your-livekit-server/twirp/livekit.SIP/CreateSIPParticipant"
headers = {
"Authorization": "Bearer YOUR_JWT",
"Content-Type": "application/json",
}
payload = {
"sip_trunk_id": "ST_xxx",
"sip_call_to": "+15105550123",
"room_name": "my-room",
"participant_identity": "sip-caller",
"wait_until_answered": True
}
resp = requests.post(url, json=payload, headers=headers)
print(resp.status_code, resp.text)
Example (curl)
curl -X POST https://your-livekit-server/twirp/livekit.SIP/CreateSIPParticipant \
-H "Authorization: Bearer <YOUR_JWT>" \
-H "Content-Type: application/json" \
-d '{"sip_trunk_id":"ST_xxx","sip_call_to":"+15105550123","room_name":"my-room","participant_identity":"sip-caller","wait_until_answered":true}'
If you’d like, I can:
• Provide the exact JSON schema for each endpoint.
• Show how to generate the JWT in synchronous Python.
• Give a synchronous example for CreateSIPDispatchRule.
Which of those would help you most?
Sources: SIP APIs | LiveKit docs | sip | livekit/livekit_composite | DeepWiki