my code goes ```load_dotenv(".env.local") class...
# ask-ai
r
my code goes
Copy code
load_dotenv(".env.local")


class MyAgent(Agent):
    def __init__(
        self,
        llm=groq.LLM(model="openai/gpt-oss-20b"),
...
works well locally, but deployment fails with error
GROQ_API_KEY is required
, API key is present in agent secrets. What is the issue?
t
Thanks for reaching out, Ivan. 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 encountering the error
GROQ_API_KEY is required
during deployment, which usually means the secret isn't being passed correctly to the runtime environment. Don’t worry, I’m here to help you through this! Here are some friendly steps to get this sorted out: 1. Verify Secret Injection: First, double-check that your CI/CD workflow is explicitly including
GROQ_API_KEY
in the
env
block. For instance, in GitHub Actions, it should look like this:
Copy code
env:
  GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
1. Check GitHub Secrets: Make sure that
GROQ_API_KEY
is actually added in your repository's GitHub Secrets. You can find this under Settings → Secrets and variables → Actions. Sometimes it’s easy to miss this step! 2. Use Correct .env File: Confirm that your deployment is using a real secrets file like
.env.local
containing the actual key value. Avoid using placeholder files such as
.env.example
which don’t have the real keys. 3. Update Secrets via CLI: If you’re not using CI/CD, you can also inject secrets directly using the LiveKit CLI like this:
Copy code
lk agent update-secrets --id <agent-id> --secrets GROQ_API_KEY=your_actual_key
1. Debug Secret Availability: To be extra sure the key is being read at runtime, you can add a quick debug log in your code like this:
Copy code
import os
print(os.getenv("GROQ_API_KEY")[:5] + "...")
If you try these steps and still see the issue, please don’t hesitate to reach out again. I’m happy to dig deeper and help you get this resolved! Sources: Secrets management | LiveKit Docs | Agent deployment CLI reference | LiveKit Docs | Groq LLM plugin guide | LiveKit Docs | Groq STT plugin guide | LiveKit Docs | .github/workflows/evals.yml
r
It work if I use
Copy code
session = AgentSession(
   llm=groq.LLM(
      model="openai/gpt-oss-20b",
   ),
)
t
I'm happy to help clarify the difference between
Agent
and
AgentSession
for you: • Agent: This represents the AI's core logic — including its instructions, tools, and overall behavior. Think of it as defining what the AI is capable of, like answering your questions or carrying out tasks. • AgentSession: This handles the live interactions, such as processing voice input (VAD, STT, TTS) and managing the flow of audio, transcription, and responses. It works alongside an
Agent
instance to smoothly coordinate the entire interaction experience. If you'd like me to walk you through this further or help with your deployment setup, please don’t hesitate to reach out. I’m here to support you! Sources: Building voice agents | LiveKit Docs | README.md | basics/say_in_voice.py | agents/src/voice/agent_session.ts | Agents v0.x migration guide - Node.js | LiveKit Docs