Im getting invalid token in the regions API
# ask-ai
n
Im getting invalid token in the regions API
t
Thanks for reaching out, neyssi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m sorry you’re running into an “invalid token” error with the regions API. I’ll help you troubleshoot it. To start, here are the most likely causes and quick checks you can run now: • Signed with the wrong secret: Tokens must be signed with the LiveKit API secret that matches your API key. An incorrect secret will cause an invalid token. • Missing or incorrect grants: Tokens require appropriate grants (for example,
roomJoin
/ room-related grants for room access). If the token doesn’t include the right grant for the regions API call you’re making, it will be rejected. • Malformed JWT: Ensure the token structure is a valid JWT (three dot-separated parts) and that the signature algorithm matches what you used to sign (HMAC-SHA256). • Expiration (
exp
) issues: If the token is already expired it will be invalid. Check the
exp
claim to confirm the token is still valid at request time. To narrow this down, please share (or confirm) the following details: 1. Which exact regions API endpoint are you calling? (full path or method) 2. How are you generating the token? Which SDK/language or custom code are you using? 3. Whether you are using the correct API key/secret pair for the project you’re calling. 4. The token payload (the decoded header & payload—do NOT paste the signature or private secret). You can paste the decoded header/payload JSON or the
exp
,
iss
, and grants you see. 5. The exact error response (full HTTP status and body) you receive from the regions API. If you want, you can also: • Decode the JWT at jwt.io (only the header/payload) to confirm claims and expiry. • Recreate a token server-side with the project API key + secret and minimal grants needed for the regions call, then retry. Once you share the endpoint, how you produce the token, and either the decoded payload or the exact error body, I’ll give specific next steps and a small example of generating a correct token for your setup. Sources: server-sdk-kotlin | livekit/livekit_composite | DeepWiki | Server-side | livekit/livekit_composite | DeepWiki
n
Agent is not joining in the dev mode now
t
Thanks — I’m sorry the agent isn’t joining in dev mode. I’m here to help. I’ll first outline the most common causes and quick checks, then ask a few targeted questions so I can narrow the problem and give exact steps. Quick checks you can run now • Confirm you started the agent in dev mode (Python): run
uv run agent.py dev
. For Node.js use
pnpm dev
. • Look for a "registered worker" message in the agent console after startup — that shows the agent connected to LiveKit Cloud. • Verify your environment variables are set:
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
(in
.env
or
.env.local
). • Ensure the agent name used in your
@server.rtc_session
decorator (e.g.,
agent_name="my-agent"
) matches the agent name in your dispatch rule or deployment config. • Make sure you authenticated the CLI for your project with
lk cloud auth
if the workflow requires CLI auth. Please share these details 1. Exact command you run to start the agent (copy/paste). 2. Full console output or error lines you see when starting the agent (paste the logs). 3. Whether you see the
registered worker
message. 4. How you set
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
(env file, export, etc.). 5. The agent name you configured and the dispatch rule you expect to match it. 6. Whether you previously had the agent working and what changed (if anything). If you prefer, paste the small portion of your agent startup log (first ~50–100 lines) and the decoded token payload you used for joining (header/payload only, not signature or secret). I’ll review it and give exact commands or a minimal token example to test with. Next steps I’ll take once you share logs • Check for authentication failures vs. missing dispatch/agent-name mismatches. • Point out any malformed environment variables or common dev-mode pitfalls. • Provide a minimal repro command and a sample token generation snippet you can try immediately. Thanks — share the logs/answers and I’ll guide you through the fix step by step. Sources: examples/drive-thru | livekit/livekit_composite | DeepWiki | Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit | Google AI and LiveKit | LiveKit Documentation | Voice AI quickstart | LiveKit Documentation