What Determines the Preferred Whisper Backend When Both API Keys Exist in Claude Video
Groq is preferred over OpenAI when both API keys are present, determined by a hard-coded tuple order in skills/watch/scripts/whisper.py.
The claude-video repository by bradautomates includes a watch skill that transcribes video content using either Groq or OpenAI Whisper services. When both GROQ_API_KEY and OPENAI_API_KEY environment variables are configured, the preferred Whisper backend is selected through a specific priority order defined in the source code.
The Hard-Coded Priority Order in whisper.py
Inside skills/watch/scripts/whisper.py, the load_api_key() function implements the backend selection logic using a statically defined tuple:
candidates = (("GROQ_API_KEY", "groq"), ("OPENAI_API_KEY", "openai"))
The function iterates over this tuple in sequence, checking each environment variable or .env file entry for a valid key. The first match determines the active backend. Because GROQ_API_KEY appears first in the tuple, Groq receives priority when both keys exist.
This behavior is explicitly documented in skills/watch/SKILL.md, which states the default behavior "prefers Groq if both keys exist."
How to Override the Default Preference
Users can bypass the automatic selection by passing the --whisper flag with an explicit backend choice:
# Force OpenAI even when Groq key is present
python3 watch.py "https://youtu.be/example" --whisper openai
The --whisper argument accepts either groq or openai, forcing the selected service regardless of which API keys are available or their configured priority.
Integration with the Transcription Pipeline
The transcribe.py script consumes this logic by calling load_api_key() and passing the returned backend identifier to the transcription flow. This ensures consistent behavior across the skill's execution path, whether running automatically or with explicit overrides.
Summary
- Groq is the default preferred Whisper backend when both
GROQ_API_KEYandOPENAI_API_KEYare present. - The preference is determined by the order of the
candidatestuple inskills/watch/scripts/whisper.py. - Use the
--whisperflag to explicitly select a backend and override the automatic priority. - The selection logic supports both environment variables and
.envfile configuration.
Frequently Asked Questions
Why does Groq take precedence over OpenAI in the default configuration?
The candidates tuple in whisper.py lists GROQ_API_KEY before OPENAI_API_KEY, causing the iteration to select Groq first when both keys are present. This ordering reflects the project's default preference as documented in SKILL.md.
Can I force OpenAI Whisper even if I have a Groq API key configured?
Yes. Pass the --whisper openai command-line argument when running watch.py. This forces the OpenAI backend regardless of the automatic priority order or which keys exist in your environment.
Where does the skill look for API keys?
The load_api_key() function checks both system environment variables and a local .env file. It searches for GROQ_API_KEY and OPENAI_API_KEY in that order, returning the first valid key found according to the hard-coded priority sequence.
What happens if neither API key is configured?
If neither GROQ_API_KEY nor OPENAI_API_KEY is found in the environment or .env file, the load_api_key() function will fail to return a valid backend, typically resulting in an error that prevents the transcription process from proceeding.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →