narrow-hairdresser-82835
11/10/2025, 2:30 PMtall-airline-16756
11/10/2025, 2:31 PMtall-airline-16756
11/10/2025, 2:31 PMLIVEKIT_API_KEY and LIVEKIT_API_SECRET. Then, include this token as the api_key in your HTTP requests. Don’t worry, we have example code ready for both Python and JavaScript to make this easier for you.
• Using Third-Party LLMs: If you’re working with providers like OpenRouter, Letta, or Azure OpenAI, you’ll need to set up API keys accordingly. Each provider has its own way of handling credentials, whether that’s through environment variables or passing them directly as parameters.
• Server-Side Token Validation: To keep everything secure, you can validate JWT tokens for incoming requests using the AccessToken.verify() method along with your API secret. This step helps ensure safe connections to your LiveKit room.
If you’d like, I’m here to provide detailed examples or walk you through any part of this setup. Just let me know how I can assist!
Sources: Core Platform Architecture & Authentication | livekit/livekit_composite | D... | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py | agents/src/inference/llm.ts | OpenRouter LLM plugin guide | LiveKit docsnarrow-hairdresser-82835
11/10/2025, 2:33 PMtall-airline-16756
11/10/2025, 2:33 PMfrom livekit.agents.inference import LLM
# Initialize the LLM with your LiveKit API credentials
llm = LLM(
model="openai/gpt-4o", # Specify the model you want to use
api_key="your_livekit_api_key", # Replace with your LiveKit API key
api_secret="your_livekit_api_secret" # Replace with your LiveKit API secret
)
# Example usage: Generate a response from the model
response = llm.generate(prompt="What is LiveKit?")
print(response)
Just be sure to replace your_livekit_api_key and your_livekit_api_secret with your actual credentials. If you have any questions or would like me to walk you through more examples, I’m here to help—just let me know!narrow-hairdresser-82835
11/10/2025, 2:34 PMtall-airline-16756
11/10/2025, 2:35 PMAuthorization header as a Bearer token. Don’t worry, I’ll walk you through it:
Using Python:
import openai
client = openai.OpenAI(
base_url="http://localhost:8080/v1", # Replace with your server's base URL
api_key="sk-this-is-the-secret-key" # Replace with your actual API key
)
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the meaning of life?"}
]
)
print(completion.choices[0].message)
Using cURL:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-this-is-the-secret-key" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'
Just make sure your server is set up to validate the API key — you can usually do this by setting the key in your server configuration (like server.api_key). If anything feels unclear or you want a hand with the setup, please don’t hesitate to ask. I’m here to help!
Sources: tools/server/public_simplechat/readme.md