how to set max call duration in python agent?
# ask-ai
c
how to set max call duration in python agent?
t
Thanks for reaching out, ZaidKaraymeh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you set the maximum call duration in a Python agent for LiveKit, you can use the
max_call_duration
parameter found in SIP-related configurations. This parameter is available in the
CreateSIPParticipantRequest
and trunk configuration objects like
SIPInboundTrunkInfo
and
SIPOutboundTrunkInfo
within the LiveKit Python SDK. It’s important to specify it using the
google.protobuf.duration_pb2.Duration
type. Here’s a friendly example of how to set it in a `CreateSIPParticipantRequest`:
Copy code
from livekit.protocol.sip import CreateSIPParticipantRequest
from google.protobuf.duration_pb2 import Duration

# Set maximum call duration to 45 minutes
max_duration = Duration()
max_duration.FromSeconds(2700)  # 45 * 60 seconds

# Create the request object
request = CreateSIPParticipantRequest(
    sip_trunk_id="trunk_123",
    sip_call_to="+1234567890",
    room_name="meeting_room",
    participant_identity="caller1",
    max_call_duration=max_duration  # Apply the duration limit
)
Similarly, you can easily configure an inbound trunk with a max duration like this:
Copy code
from livekit.protocol.sip import SIPInboundTrunkInfo
from google.protobuf.duration_pb2 import Duration

max_duration = Duration()
max_duration.FromSeconds(3600)  # 1 hour

trunk_info = SIPInboundTrunkInfo(
    sip_trunk_id="inbound_trunk_001",
    numbers=["+1234567890"],
    max_call_duration=max_duration,
    # ... other fields
)
If you have any questions or need more help, please don’t hesitate to ask—I’m here to support you! Sources: pkg/sip/participant.go | livekit-plugins/livekit-plugins-ultravox/livekit/plugins/ultravox/realtime/... | livekit-protocol/livekit/protocol/sip.py | SIP APIs | LiveKit Docs | rpc/sip.pb.go