How do I set the maximum call duration in livekit-...
# ask-ai
c
How do I set the maximum call duration in livekit-agents?
t
Thanks for reaching out, Anton. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you set the maximum call duration in
livekit-agents
! You can do this by using the
max_duration
parameter in the configuration options for the
RealtimeModel
when working with the Ultravox plugin. This parameter lets you define how long a call can last before it automatically ends, which is super handy. Here’s a simple example in Python to guide you:
Copy code
from livekit.agents import llm

model = llm.RealtimeModel(
    model="fixie-ai/ultravox",
    voice="Mark",
    api_key="your_api_key",
    max_duration="30m",  # Set maximum call duration to 30 minutes
    time_exceeded_message="Time limit reached. Ending call.",
)
If you’re working with the SIP API, you can set the
max_call_duration
field in the request payloads like
CreateSIPParticipantRequest
. Here’s how it looks in Node.js:
Copy code
await client.createSIPParticipant({
  fromNumber: "+1234567890",
  callTo: "+0987654321",
  roomName: "my-room",
  maxCallDuration: 1800, // 30 minutes in seconds
});
Please feel free to reach out if you have any questions or need a hand with anything else—I’m here to help! Sources: livekit-plugins/livekit-plugins-ultravox/livekit/plugins/ultravox/realtime/... | rpc/io.pb.go | SIP APIs | LiveKit Docs | Docs::Telephony