square-flag-66304
09/30/2025, 10:29 AM{
"reason": "error",
"error": "type='realtime_model_error' timestamp=1759228075.8803654 label='livekit.plugins.google.beta.realtime.realtime_api.RealtimeModel' error=ConnectionClosedError(Close(code=1008, reason='API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a prin'), Close(code=1008, reason='API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a prin'), True) recoverable=False"
}tall-airline-16756
09/30/2025, 10:29 AMtall-airline-16756
09/30/2025, 10:30 AMsquare-flag-66304
09/30/2025, 10:52 AMtall-airline-16756
09/30/2025, 10:52 AMLIVEKIT_API_KEY and LIVEKIT_API_SECRET to create a signed JWT.
• Make sure to include the necessary permissions (like roomJoin, canPublish, and canSubscribe), along with the room name and participant identity.
Here’s an example in Node.js to help you out:
import { AccessToken } from 'livekit-server-sdk';
const apiKey = process.env.LIVEKIT_API_KEY;
const apiSecret = process.env.LIVEKIT_API_SECRET;
const roomName = 'my-room';
const participantIdentity = 'user1';
const token = new AccessToken(apiKey, apiSecret, {
identity: participantIdentity,
ttl: '1h',
});
token.addGrant({
roomJoin: true,
room: roomName,
canPublish: true,
canSubscribe: true,
});
const jwtToken = await token.toJwt();
// Send this token to the client
2. Use the Token on the Client:
const room = new Room();
await room.connect('wss://your-server.livekit.cloud', jwtToken);
Just a quick reminder: Please avoid using LIVEKIT_API_KEY or LIVEKIT_API_SECRET directly in your client-side code. Generating and using a JWT token is the safest way to go.
If you have any questions or need a hand with this, feel free to reach out—I’m here to help!
Sources: frontend/lib/server-utils.ts | packages/rpc-demo/.env.local | packages/react/src/components/LiveKitRoom.tsx | Authentication | LiveKit Docs | Connecting to LiveKit | LiveKit Docssquare-flag-66304
09/30/2025, 10:53 AMtall-airline-16756
09/30/2025, 10:54 AMpip install livekit-api
2. Next, generate the token with this code:
from livekit import api
import os
# Set your API key and secret
api_key = os.getenv("LIVEKIT_API_KEY")
api_secret = os.getenv("LIVEKIT_API_SECRET")
# Create the token
token = (
api.AccessToken(api_key, api_secret)
.with_identity("your-identity")
.with_grants(
api.VideoGrants(
room_join=True,
room="your-room-name"
)
)
.to_jwt()
)
print(token) # Send this token to the client
3. If you'd like, you can also add an expiry time (TTL) like this:
import datetime
token = (
api.AccessToken(api_key, api_secret)
.with_identity("your-identity")
.with_grants(
api.VideoGrants(
room_join=True,
room="your-room-name"
)
)
.with_ttl(datetime.timedelta(hours=1)) # Token expires in 1 hour
.to_jwt()
)
4. Finally, use the token on the client side:
const room = new Room();
await room.connect('wss://your-server.livekit.cloud', jwtToken);
Just a quick reminder to replace your-identity and your-room-name with the actual participant identity and room name you want to use. If you have any questions or need a hand with anything else, feel free to ask—I’m here to help!
Sources: auth.py | Authentication | LiveKit Docs | Docs::Agents | Generating tokens | LiveKit Docs | examples/agent_dispatch.py