fix: prioritize OPENROUTER_API_KEY over OPENAI_API_KEY

When both OPENROUTER_API_KEY and OPENAI_API_KEY are set (e.g. OPENAI_API_KEY
in .bashrc), the wrong key was sent to OpenRouter causing auth failures.

Fixed key resolution order in cli.py and runtime_provider.py.

Fixes #289
This commit is contained in:
0xbyt4 2026-03-03 00:28:26 +03:00
parent 3c13feed4c
commit 6053236158
3 changed files with 34 additions and 2 deletions

View file

@ -74,8 +74,8 @@ def _resolve_openrouter_runtime(
api_key = (
explicit_api_key
or os.getenv("OPENAI_API_KEY")
or os.getenv("OPENROUTER_API_KEY")
or os.getenv("OPENAI_API_KEY")
or ""
)