Skip to content

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

Open
xilema2 wants to merge 1 commit into
Aider-AI:mainfrom
xilema2:feat/orcarouter
Open

feat: add OrcaRouter (orcarouter/) as a first-class provider#5147
xilema2 wants to merge 1 commit into
Aider-AI:mainfrom
xilema2:feat/orcarouter

Conversation

@xilema2
Copy link
Copy Markdown

@xilema2 xilema2 commented May 19, 2026

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.pyOrcaRouterModelManager 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!

OrcaRouter (https://www.orcarouter.ai) is an OpenAI-compatible LLM
meta-router. This adds it as a first-class provider in aider:

- New OrcaRouterModelManager that fetches the public
  /api/pricing catalog (no auth) and exposes per-model
  context_length / pricing in litellm get_model_info shape.
  Pricing uses OrcaRouter's published quota formula
  (model_ratio * 2 USD/1M for input, * completion_ratio for output).
- ModelInfoManager delegates to it for orcarouter/-prefixed models
  when litellm has no built-in info.
- Model.send_completion auto-routes orcarouter/<vendor>/<model>
  to 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 the traffic to aider.
- ORCAROUTER_API_KEY added to fast_validate_environment keymap.
- "orcarouter-auto" alias added for the orcarouter/orcarouter/auto
  adaptive router.
- Docs page at aider/website/docs/llms/orcarouter.md.
- Unit tests in tests/basic/test_orcarouter.py mirroring the
  existing OpenRouter test pattern.

I'm an engineer on the OrcaRouter team.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 19, 2026

CLA assistant check
All committers have signed the CLA.

@xilema2
Copy link
Copy Markdown
Author

xilema2 commented May 21, 2026

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants