Repository navigation
Accept an OpenRouter key wherever an OpenAI key is required - #477
Merged
Merged
Conversation
Ai2 no longer issues OpenAI API keys. Anything that needs OPENAI_API_KEY now
also accepts OPENROUTER_API_KEY. When only the OpenRouter key is set, requests
go to OpenRouter's OpenAI-compatible endpoint and OpenAI model names are sent as
OpenRouter slugs. An OpenAI key still wins when both are set.
- Add common/openai_credentials.py to resolve credentials and model names.
- Route the LLM judges, vision judges, and LiteLLM registry models through it.
- Let a {user}_OPENROUTER_API_KEY Beaker secret satisfy an OPENAI_API_KEY
requirement, and accept it in provider and harness secret validation.
- Export the OpenRouter key to external-eval sandboxes and rewrite the tau2
and DeepScholar OpenAI model names.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- Accept OPEN_ROUTER_KEY as another name for the OpenRouter key. - Pass the OpenRouter key to LiteLLM explicitly, since LiteLLM only reads OPENROUTER_API_KEY from the environment. - When routing an OpenAI model through OpenRouter, drop request params that LiteLLM's OpenAI model data marks unsupported. Logprobs are always dropped when unsupported (o3-mini rejects them); other params only with drop_params. LiteLLM does this for OpenAI's own endpoint but not for OpenRouter. - Clear OpenRouter keys in tests so a developer's key cannot reach the live API. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
donovanr
reviewed
Oct 15, 2026
- Apply the OpenRouter overrides and parameter filtering to LiteLLM loglikelihood requests, matching the generate path. - Map DeepScholar's model under test with litellm_model_name so dated OpenAI snapshots resolve on OpenRouter. - Suggest the OpenRouter secret alongside the OpenAI one when a required Beaker secret is missing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- LiteLLMProvider.get_openai_client returns an OpenRouter client when requests are routed there, and the agents and OpenHands scaffolds send the mapped model name. - DeepScholar's model under test uses the OpenRouter slug, which both litellm and upstream's raw OpenAI client accept in agentic search. - Asta passes Inspect an openrouter/<slug> model. - Loglikelihood requests fail clearly for models without logprobs instead of scoring every continuation as zero. - CharXiv stops retrying on 402, which OpenRouter returns when a key is out of credits. - Missing-secret messages, eval info and docstrings name the OpenRouter key alongside the OpenAI key. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…port # Conflicts: # src/olmo_eval/inference/providers/litellm.py
- The openai_agents harness compacts history through OpenAI's responses.compact endpoint, which OpenRouter does not serve (it returns 404). With only an OpenRouter key, the harness now skips compaction and logs a warning instead of failing once compaction triggers. - Treat HTTP 402, which OpenRouter returns when a key is out of credits, as non-retryable. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
gregorybchris
added a commit
that referenced
this pull request
Oct 17, 2026
alogprobs now reads _openai_params (added in #477), which __init__ sets. These tests build the provider with __new__, so set it explicitly. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ai2 no longer issues OpenAI API keys. With this change, anything that needs
OPENAI_API_KEYalso accepts an OpenRouter key inOPENROUTER_API_KEYorOPEN_ROUTER_KEY. When only an OpenRouter key is set, requests go to OpenRouter's OpenAI-compatible endpoint, and OpenAI model names are sent as OpenRouter slugs (gpt-4obecomesopenai/gpt-4o). If an OpenAI key is also set, it is used, so existing setups behave the same.What changed
common/openai_credentials.py. It resolves which key to use and maps model names to OpenRouter slugs. OpenRouter rejectsgpt-4-0613andgpt-5.5-2026-04-23, so these map to the undated slug of the same snapshot (openai/gpt-4,openai/gpt-5.5).o3-mini-2025-01-31maps toopenai/o3-minithe same way.build_openai_judge_fncovers SimpleQA, rubric, safety, HLE, FrontierScience, ResearchQA and citation judges. The vision judges (MathVista, CharXiv, dense caption) use the same helper. Judge caches are still keyed by the OpenAI model name, so existing caches keep working.gpt-4o,gpt-4o-mini,gpt-4-turbo,o3-mini-…). These are sent asopenrouter/openai/<model>, with the key passed explicitly. This applies to both generation and loglikelihood requests. The provider's reportedmodel_namedoes not change.drop_paramsis set.JudgedTask) create their judge throughbuild_openai_judge_fn, so they route through OpenRouter with no task-specific changes. MT-Bench's default judgegpt-5.5-2026-04-23maps toopenai/gpt-5.5, MultiChallenge'sgpt-4o-2024-08-06is served under its dated slug, and Arena-Hard'sgpt-4.1-2025-04-14resolves toopenai/gpt-4.1.get_openai_client()returns an OpenRouter client when the provider routes there, and the openai-agents and OpenHands scaffolds send the mapped model name.responses.compactendpoint. OpenRouter doesn't serve it: a live call returned 404 for bothgpt-4.1andopenai/gpt-4.1, while/responsesworked with the same key. OpenRouter's docs list onlyPOST /responses. With only an OpenRouter key, the harness now skips compaction and logs a warning. Before, the run failed once compaction triggered.OPENAI_API_KEYuses{user}_OPENROUTER_API_KEYwhen{user}_OPENAI_API_KEYdoes not exist. When neither exists, the error suggests abeaker secret writecommand for each.ProviderConfigandHarnessConfigsecret validation accept the OpenRouter key too, and missing-secret messages andolmo-eval infoname both keys.OPENROUTER_API_KEYandOPENAI_API_KEY, andOPENAI_BASE_URLis set to OpenRouter. The OpenAI model names olmo-eval passes in are rewritten: tau2's agent and user LLM, DeepScholar's model under test and judge, and Asta's model under test. DeepScholar's model under test uses the plain slug (openai/gpt-4), because upstream's agentic search passes it to a raw OpenAI client as well as to LiteLLM.Live verification against OpenRouter
These runs had only
OPEN_ROUTER_KEYset and no OpenAI key.openai/gpt-4o-miniopenai/gpt-5.5(medium reasoning)gpt-5.5-2026-04-23→openai/gpt-5.5openai/gpt-6-lunagpt-4-0613→openai/gpt-4openai/gpt-4o-2024-05-13gpt-4o-mini,gpt-4o,gpt-4-turboopenrouter/openai/…o3-mini-2025-01-31-mediumopenrouter/openai/o3-miniopenrouter/openai/gpt-4o-miniOPENAI_BASE_URL(Asta-style)gpt-4o-miniA second round of live checks covered the review fixes:
LiteLLMProvider.get_openai_client()openai/gpt-4(fromgpt-4-0613)openai/gpt-4openai/gpt-4reasoning_efforton o3-miniopenai/gpt-4o-2024-08-06responses.compact(agent compaction)gpt-4.1,openai/gpt-4.1End to end,
olmo-eval run -m gpt-4o-mini -t simpleqa:judge -o limit=3completed 3/3. Both the model and the judge ran through OpenRouter. As a positive control, the SimpleQA judge graded a correct answer 1.0 and a wrong answer 0.0.Limitations
gpt-4-0613) do not. Asta also still requires Anthropic and Google keys.--secret-envoverrides still do not satisfy the required-secret check. That was already the case before this PR.Beaker verification
After the review fixes and merges, one job reran at commit
21f0b34don 2026-10-16 in the same workspace, again mounting only the OpenRouter secret:gpt-4o-mini(LiteLLM) onsimpleqa:judgeandxstest:openai_judge, 20 eachThe
o3-miniand vLLM jobs were not rerun: nothing they exercise changed after the first round, and their judge path is the one the job above covers.The first round of jobs ran in
ai2/olmo-eval-debugat commit4cb6d4cbon 2026-10-14. The workspace has achrisg_OPENROUTER_API_KEYsecret and nochrisg_OPENAI_API_KEY, so the launcher had to fall back to OpenRouter. Each job mounted only the OpenRouter secret. Every judge request in the logs went toopenrouter.aiand returned 200, with no failed requests.gpt-4o-mini(LiteLLM) onsimpleqa:judgeandxstest:openai_judge, 20 eacho3-mini-2025-01-31-mediumon the same tasksllama3.1-8b-instructon vLLM (H100), same taskstau2_benchairline, 3 tasks,llama3.1-8b-instruct, user LLMgpt-4o-miniThe tau2 job failed before tau2 started. The sandbox container exited while bootstrapping SWE-ReX (
An executable named swe-rex is not provided by package swe-rex). tau2 uses the default sandbox config withoutinject_swerex, unlike DeepScholar and SciCode, so it hits the runtime install path that no longer works. This PR doesn't change that code, so tau2 fails the same way onmain. As a result, the tau2 and DeepScholar OpenRouter path has only been checked locally (sandbox env and LiteLLM model names, see above).Not yet tested
OPENALEX_API_KEYsecret.Testing
uv run pytest tests/ --ignore=tests/integrationafter mergingmain(through Arena-Hard v2.0, Add Arena-Hard v2.0 with pairwise judging and style control #474): 4,029 passed and 36 skipped in the default env, and 4,075 passed with theagentsandlitellmextras. An earlier run passed with a real OpenRouter key exported.ruff checkandruff format --checkare clean.ty check src/is clean, both in the default env and with CI's command from Type-check optional SDK code in CI and allow missing extras locally #484 (--extra clients --extra litellm --extra agents).🤖 Generated with Claude Code