Im getting the following error in my livekit serve...
# ask-ai
h
Im getting the following error in my livekit server logs: invalid credentials were provided what are the list of possible issues that can be causing this. I'm using twilio as my service provider
t
Thanks for reaching out, Ahmed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like you're seeing the error "invalid credentials were provided" in your LiveKit server logs during SIP authentication with Twilio. Let’s walk through some common reasons this might happen: • Incorrect SIP username or password: Double-check that the
auth_username
and
auth_password
in your LiveKit setup exactly match the credentials listed in Twilio's SIP credential list. • Missing or unlinked SIP credentials list in Twilio: Make sure you have a credential list created in Twilio and that it’s properly linked to your SIP trunk. • Improperly set environment variables: Verify that
TWILIO_SIP_USERNAME
and
TWILIO_SIP_PASSWORD
are correctly set in your LiveKit environment. • Digest authentication mismatch: Confirm that LiveKit is responding correctly to Twilio’s authentication challenge. To get this sorted, I recommend checking the credentials on both sides, reviewing your environment variables, and taking a look at the LiveKit server logs for more detailed authentication info. If you’d like, I’m here to help you step-by-step—just let me know! Sources: test/lktest-sip-outbound/README.md | packages/sip--um-actually/src/setup-twilio.ts | src/setup-livekit.ts | Create and configure a Twilio SIP trunk | LiveKit Docs | Making calls using SIP | LiveKit Docs
h
how can I confirm step 1
t
Let's walk through Step 1 together to verify your SIP credentials list in Twilio: 1. First, log in to your Twilio Console. 2. Then, head over to Elastic SIP Trunking > Manage > Credential Lists. 3. Take a look to see if there’s a credential list there (something like "LiveKit SIP Credentials") and make sure it has both a username and password. 4. Next, go to Elastic SIP Trunking > Manage > Trunks and pick the trunk you’re using for LiveKit. 5. Under the Termination > Authentication section, double-check that the credential list is linked to the trunk. If you find the credential list is missing or not connected to the trunk, no worries! You can create a new credential list and link it to the trunk. Just let me know if you’d like me to guide you through that process—I’m here to help!
h
how do I confirm this Incorrect SIP username or password
t
Let's make sure your SIP username and password are all set correctly. Here's a simple way to check: 1. Head over to your Twilio Console and navigate to Elastic SIP Trunking > Manage > Credential Lists. Find the credential list linked to your trunk. 2. Take note of the username and password listed there. 3. Next, look at your LiveKit configuration and check the
TWILIO_SIP_USERNAME
and
TWILIO_SIP_PASSWORD
environment variables. You’ll usually find these in your
.env.local
file or as environment variables passed to your LiveKit server. 4. Double-check that the username and password in Twilio’s credential list exactly match what’s in your LiveKit setup. Remember, they’re case sensitive, and even an extra space can cause issues. If you spot any differences, just update the credentials in either Twilio or LiveKit so they match perfectly. And please don’t hesitate to reach out if you’d like me to walk you through any part of this—I’m here to help!
h
how do i do this: Digest authentication mismatch: Confirm that LiveKit is responding correctly to Twilio’s authentication challenge.
t
Let's walk through how to check if there's a digest authentication mismatch together: 1. First, enable detailed logging on your LiveKit server. This will capture the SIP authentication details and give us a clearer picture of how LiveKit is responding to Twilio's authentication challenge. 2. Next, take a look at the LiveKit server logs for any entries related to SIP authentication. Keep an eye out for messages like these: • "No Proxy header found. Sending 407 Unauthorized": This means Twilio has challenged the authentication, and LiveKit is responding accordingly. • "Authentication failed - response mismatch": This suggests the digest response LiveKit computed doesn’t match what Twilio expects, which usually points to incorrect credentials. • "SIP invite authentication successful": Great news—this means the authentication went through successfully. 1. Then, compare the username and password used in the digest computation (you can find these in the logs) with the credentials you have set up in Twilio’s SIP credential list. If you notice a response mismatch, it’s a good idea to double-check the username and password on both Twilio and LiveKit. And please don’t hesitate to reach out if you’d like a hand enabling detailed logging or making sense of the logs—I’m here to help!
h
this is the error that i see in the livekit logs: error: "invalid credentials were provided"
t
It looks like the error "invalid credentials were provided" in the LiveKit logs is pointing to a SIP authentication issue. This usually happens for a few common reasons: • Incorrect SIP username or password: Please double-check that the
TWILIO_SIP_USERNAME
and
TWILIO_SIP_PASSWORD
in your LiveKit setup exactly match the credentials listed in Twilio's SIP credential list. • Missing or unlinked SIP credentials list in Twilio: Make sure that the credential list has been created and properly linked to your SIP trunk in Twilio. • Digest authentication mismatch: Take a look at the LiveKit logs for more clues, such as whether the Proxy-Authorization header is missing or if there’s a response mismatch. I understand this can be a bit tricky, so I recommend going over the credentials again in both Twilio and LiveKit to ensure they match perfectly. If you’d like, I’m here to help you through the next steps—just let me know!
h
do I need to add a request handler to accept the room request when i call the agent?
t
Hi there! You actually don’t need to explicitly add a request handler to accept the room request when calling the agent in LiveKit. By default, if a
request_fnc
isn’t defined, the system will automatically accept all job requests sent to the worker, which makes things simpler for you. That said, if you’d like to have more control over which jobs your agent accepts—maybe based on room metadata or other specific conditions—you can definitely define a
request_fnc
function. This way, you can decide whether to accept or reject a job based on what you need. Here’s a quick example:
Copy code
async def request_fnc(req: JobRequest):
    await req.accept(name="agent", identity="identity", attributes={"myagent": "rocks"})
This step is totally optional and only necessary if you want that fine-grained control over job acceptance. If you have any questions or want me to walk you through it more, just let me know—I’m here to help! Sources: Worker options | LiveKit Docs | livekit-agents/livekit/agents/worker.py
Hi there! You actually don’t need to add a request handler explicitly to accept the room request when calling the agent in LiveKit. By default, if no
request_fnc
is set up, the system kindly accepts all job requests sent to the worker automatically. That said, if you'd like to have more control over which jobs your agent accepts—maybe based on room metadata or specific agent conditions—you can create a
request_fnc
function. This lets you decide whether to accept or reject each job. For example:
Copy code
async def request_fnc(req: JobRequest):
    await req.accept(name="agent", identity="identity", attributes={"myagent": "rocks"})
This step is totally optional and only necessary if you want to customize how jobs are accepted. If you have any questions or want me to walk you through it, just let me know—I’m here to help!