# What Happens When Both Groq and OpenAI API Keys Are Configured in claude-video

> Discover what happens when both Groq and OpenAI API keys are set in claude-video. Learn how Groq is automatically prioritized for transcription.

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

---

**When both Groq and OpenAI API keys are configured in claude-video, the system automatically selects Groq as the transcription backend because it appears first in the priority list within the `load_api_key()` function.**

The claude-video repository provides a video transcription skill that supports multiple Whisper backends for converting speech to text. When you configure both Groq and OpenAI API keys in your environment variables or `.env` file, the application must decide which provider to use for processing audio. Understanding this automatic selection logic helps you predict costs, latency, and availability based on which API key takes precedence.

## How the Backend Selection Logic Works

According to the source code in [`skills/watch/scripts/whisper.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/whisper.py), the transcription backend is determined by a priority-based lookup in the `load_api_key()` function.

### The Candidate List Priority

At lines 65-71, the function constructs an ordered tuple of candidate providers:

```python
candidates = [
    ("GROQ_API_KEY", "groq"),
    ("OPENAI_API_KEY", "openai")
]

```

The function iterates through this list and returns the **first** key it finds in the environment or `.env` file. Because `GROQ_API_KEY` appears first in the tuple, Groq is **preferred** whenever both keys are present, making it the default transcription provider.

### Integration with the Transcription Flow

The `transcribe_video()` function invokes `load_api_key()` at lines 24-28 to discover the available backend. If no explicit `backend` argument is passed to the script, this automatic detection determines whether Groq or OpenAI handles the audio processing, and the selected backend name is reported back to the caller.

## Verifying the Active Backend

You can confirm which provider is active using the setup status command. When a Groq key is present, the JSON output from [`skills/watch/scripts/setup.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/setup.py) reports `"whisper_backend": "groq"`, as verified in the test suite at [`tests/test_setup.py`](https://github.com/bradautomates/claude-video/blob/main/tests/test_setup.py) lines 73-80.

Run the following to check your configuration:

```bash
python3 skills/watch/scripts/setup.py --json

```

Example output when both keys are configured:

```json
{
  "whisper_backend": "groq",
  "status": "ready"
}

```

## Overriding the Default Selection

If you need to use OpenAI despite having both keys configured, the script provides a command-line override. As implemented at lines 76-78 of [`skills/watch/scripts/whisper.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/whisper.py), passing the `--backend` flag bypasses the automatic detection.

**Force OpenAI when both keys exist:**

```bash
watch <video-url-or-path> --backend openai

```

This forces the transcription to use OpenAI's Whisper endpoint, ignoring the Groq key that would otherwise be selected by default.

## Summary

- When both Groq and OpenAI API keys are configured in claude-video, **Groq is automatically selected** as the transcription backend due to its position as the first item in the candidate list.
- The selection logic resides in [`skills/watch/scripts/whisper.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/whisper.py) within the `load_api_key()` function, which checks for `GROQ_API_KEY` before `OPENAI_API_KEY`.
- The active backend is reported in the setup status JSON as `"whisper_backend": "groq"` when the Groq key is present.
- Users can force OpenAI by passing the `--backend openai` command-line argument to override the automatic priority.

## Frequently Asked Questions

### Why does claude-video prefer Groq over OpenAI?

The codebase explicitly orders Groq first in the provider candidate list within the `load_api_key()` function at lines 65-71 of [`skills/watch/scripts/whisper.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/whisper.py). This design prioritizes Groq's typically faster inference and lower costs for Whisper transcription tasks, though users retain the flexibility to override this default with the `--backend` flag.

### Can I use both backends simultaneously in the same command?

No, the transcription script processes each video using a single backend. The `load_api_key()` function returns exactly one API key and backend identifier. You must run separate commands with different `--backend` flags if you need to compare outputs from both providers.

### How do I check which API key is actually being used?

Run the setup status command: `python3 skills/watch/scripts/setup.py --json`. The `whisper_backend` field indicates the active provider. Additionally, when running the `watch` command, the backend selection is reported in the output, allowing you to verify whether Groq or OpenAI is processing your request.

### 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 returns `None` for both the key and backend. The transcription will fail with an error indicating that no valid API credentials were detected, prompting you to configure at least one provider.