aider
aider copied to clipboard
feat: add OrcaRouter (orcarouter/) as a first-class provider
PR Description
## Summary
This PR adds [OrcaRouter](https://www.orcarouter.ai) — an OpenAI-compatible LLM
meta-router — as a first-class provider in aider, parallel to the existing
OpenRouter integration. Users can run any of OrcaRouter's 150+ upstream models
(OpenAI / Anthropic / Google / DeepSeek / xAI / Qwen / MiniMax / Kimi / Z.ai /
…) with a single API key:
```bash
export ORCAROUTER_API_KEY=<key>
aider --model orcarouter/openai/gpt-4o
aider --model orcarouter/anthropic/claude-opus-4.7
aider --model orcarouter-auto # alias for the adaptive router
I'm an engineer on the OrcaRouter team.
What's added
aider/orcarouter.py—OrcaRouterModelManagerthat fetches the public pricing/catalog feed athttps://www.orcarouter.ai/api/pricing(no auth) and exposes per-modelmax_input_tokens/max_output_tokens/input_cost_per_token/output_cost_per_tokenin the litellmget_model_infoshape. Computed from OrcaRouter's published quota formula (model_ratio * 2 USD/1Mfor input,× completion_ratiofor output). 24h on-disk cache at~/.aider/caches/orcarouter_models.json, mirroring the OpenRouter manager.aider/models.py—ModelInfoManagerdelegates toOrcaRouterModelManagerfororcarouter/-prefixed models when litellm has no built-in info.Model.send_completionauto-routesorcarouter/<vendor>/<model>tohttps://api.orcarouter.ai/v1via litellm's OpenAI-compatible client, usingORCAROUTER_API_KEYfrom the environment.HTTP-Referer/X-Titleattribution headers are injected so OrcaRouter's console can credit traffic to aider (users can override viaextra_params.extra_headers).ORCAROUTER_API_KEYadded tofast_validate_environmentkeymap so aider's startup env check recognises it.orcarouter-autoalias added toMODEL_ALIASESfor OrcaRouter's adaptive router.
aider/website/docs/llms/orcarouter.md— new docs page (parallel toopenrouter.md) covering setup, the adaptiveorcarouter/autorouter, the tool-calling caveat, andextra_bodyprovider-routing config.tests/basic/test_orcarouter.py— unit tests mirroring the OpenRouter test pattern: pricing formula on a flat-array payload, pricing formula on the wrapped{"data": [...]}payload, empty-result handling, and theModelInfoManagerdelegation.
Design notes
- No litellm upstream changes needed. The
orcarouter/prefix is rewritten toopenai/<rest>for the underlying litellm call, withapi_baseandapi_keyinjected, so litellm's existing OpenAI-compatible client handles the request. The user-facing model name keeps theorcarouter/prefix so aider's per-provider hooks (alias resolution, metadata lookup) work uniformly. - Closely follows the OpenRouter integration shape so it's easy to review side-by-side and maintains the same caching / fallback behaviour.
How verified
- Unit tests added (
pytest tests/basic/test_orcarouter.py). - Manual smoke test against
https://www.orcarouter.ai/api/pricingconfirms the pricing formula matches published per-model rates (e.g.openai/gpt-4o:model_ratio=1.25, completion_ratio=4→$2.50 / $10.00 per 1M tokens). - Linted with the project's pre-commit config (Black / isort).
Happy to iterate on naming, doc tone, or scope. Thanks for maintaining aider!
Hi @paul-gauthier, gentle ping on this PR. As a first-time contributor, the required CI workflows are waiting for maintainer approval to run (4 workflows pending). Could you kindly approve them when you have a moment? Happy to address any feedback. Thanks!