# What Determines the Preferred Whisper Backend When Both API Keys Exist in Claude Video

> Discover why Groq is the preferred Whisper backend over OpenAI in Claude Video when both API keys are configured. Learn about the hard-coded priority order.

- Repository: [bradautomates/claude-video](https://github.com/bradautomates/claude-video)
- Tags: how-to-guide
- Published: 2026-07-12

---

**Groq is preferred over OpenAI when both API keys are present, determined by a hard-coded tuple order in [`skills/watch/scripts/whisper.py`](https://github.com/bradautomates/claude-video/blob/main/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`](https://github.com/bradautomates/claude-video/blob/main/whisper.py)

Inside [`skills/watch/scripts/whisper.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/whisper.py), the `load_api_key()` function implements the backend selection logic using a statically defined tuple:

```python
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`](https://github.com/bradautomates/claude-video/blob/main/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:

```bash

# 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`](https://github.com/bradautomates/claude-video/blob/main/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_KEY` and `OPENAI_API_KEY` are present.
- The preference is determined by the order of the `candidates` tuple in [`skills/watch/scripts/whisper.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/whisper.py).
- Use the `--whisper` flag to explicitly select a backend and override the automatic priority.
- The selection logic supports both environment variables and `.env` file configuration.

## Frequently Asked Questions

### Why does Groq take precedence over OpenAI in the default configuration?

The `candidates` tuple in [`whisper.py`](https://github.com/bradautomates/claude-video/blob/main/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`](https://github.com/bradautomates/claude-video/blob/main/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`](https://github.com/bradautomates/claude-video/blob/main/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.