aider icon indicating copy to clipboard operation
aider copied to clipboard

feat: add OrcaRouter (orcarouter/) as a first-class provider

Open xilema2 opened this issue 6 months ago • 2 comments

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 — OrcaRouterModelManager that fetches the public pricing/catalog feed at https://www.orcarouter.ai/api/pricing (no auth) and exposes per-model max_input_tokens / max_output_tokens / input_cost_per_token / output_cost_per_token in the litellm get_model_info shape. Computed from OrcaRouter's published quota formula (model_ratio * 2 USD/1M for input, × completion_ratio for output). 24h on-disk cache at ~/.aider/caches/orcarouter_models.json, mirroring the OpenRouter manager.
  • aider/models.py —
    • ModelInfoManager delegates to OrcaRouterModelManager for orcarouter/-prefixed models when litellm has no built-in info.
    • Model.send_completion auto-routes orcarouter/<vendor>/<model> to https://api.orcarouter.ai/v1 via litellm's OpenAI-compatible client, using ORCAROUTER_API_KEY from the environment. HTTP-Referer / X-Title attribution headers are injected so OrcaRouter's console can credit traffic to aider (users can override via extra_params.extra_headers).
    • ORCAROUTER_API_KEY added to fast_validate_environment keymap so aider's startup env check recognises it.
    • orcarouter-auto alias added to MODEL_ALIASES for OrcaRouter's adaptive router.
  • aider/website/docs/llms/orcarouter.md — new docs page (parallel to openrouter.md) covering setup, the adaptive orcarouter/auto router, the tool-calling caveat, and extra_body provider-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 the ModelInfoManager delegation.

Design notes

  • No litellm upstream changes needed. The orcarouter/ prefix is rewritten to openai/<rest> for the underlying litellm call, with api_base and api_key injected, so litellm's existing OpenAI-compatible client handles the request. The user-facing model name keeps the orcarouter/ 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/pricing confirms 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!

xilema2 avatar May 19 '26 03:05 xilema2

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 19 '26 03:05 CLAassistant

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!

xilema2 avatar May 21 '26 03:05 xilema2