feat: add OrcaRouter as a first-class provider - #1600
Conversation
Mirror the existing OpenRouter wiring across the provider-identity and LLM-backend layers so lean-ctx treats OrcaRouter (an OpenAI-compatible AI gateway) as a named provider instead of an anonymous custom base URL: - LlmBackend gains an OrcaRouter variant: default base URL https://api.orcarouter.ai, ORCAROUTER_API_KEY env var, same OpenAI chat-completions call path as OpenRouter. - ProviderKind gains OrcaRouter; URL detection, canonical usage mapping (OpenAI dialect incl. usage.cost), display name and label parsing all mirror the OpenRouter branches. - llm.backend config enum and the generated config-keys reference include the new backend. Co-Authored-By: Claude <noreply@anthropic.com>
|
👋 Thanks for the contribution — we would love to merge it! One one-time step remains: please sign our CLA. It takes ~5 seconds, you sign once, and every future PR is then accepted automatically. The CLA keeps lean-ctx Apache-2.0 and free for individual developers (guaranteed in §8) while still allowing a hosted/commercial plane. To sign: reply to this PR with a comment containing exactly:
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
Thanks for the work — the patch itself is clean, and I checked it properly: no new dependencies, no build script, no workflow changes, the default backend stays I'm closing it anyway, for two reasons that aren't about code quality. It doesn't add a capability. Named providers are an editorial commitment. Listing a gateway next to OpenAI, Anthropic and Gemini tells users we vouch for it. The bar for that is a track record I can verify independently, and OrcaRouter doesn't have one yet — the domain and the account opening this PR are both days old. That's a "not yet", not a judgement about the service. If OrcaRouter picks up real adoption among lean-ctx users, this is an easy PR to revive — the wiring is right. One note that may be useful to you regardless: |
Summary
LeanCTX describes itself as an AI Value Gate for AI coding agents — it sits on the wire path between your agent and the model, compressing and metering every request. It is model-agnostic ("swap OpenAI/Anthropic/Gemini freely"), and its universal provider registry already treats OpenAI-compatible gateways such as OpenRouter as first-class citizens.
This PR adds OrcaRouter the same way: as a named provider that mirrors the existing OpenRouter wiring, rather than something a user has to bolt on as an anonymous custom base URL.
OrcaRouter is an OpenAI-compatible AI gateway built for both models and agents. Like OpenRouter, it exposes a provider/model namespace across many models — but it also combines adaptive routing, automatic failover, zero-markup inference, observability, guardrails, and agent-tool governance behind the same endpoint. Adding
orcarouteras a first-class provider means lean-ctx users can use that stack directly, without treating OrcaRouter as an anonymous custom base URL. It also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.Parallel to the existing OpenRouter wiring
Every change below is the OrcaRouter twin of an existing OpenRouter branch:
rust/src/core/llm_enhance.rsLlmBackend::OpenRouter→ base URLhttps://openrouter.ai/api,OPENROUTER_API_KEY, OpenAI chat-completions pathLlmBackend::OrcaRouter→ base URLhttps://api.orcarouter.ai,ORCAROUTER_API_KEY, samecall_openai_compatiblepathrust/src/core/context_kernel/token_envelope.rsProviderKind::OpenRouterProviderKind::OrcaRouter+parse_providerentryrust/src/core/context_kernel/provider_parity.rsopenrouter.ai, OpenAI-dialect usage mapping, display name "OpenRouter"orcarouter.ai, same OpenAI-dialect mapping (incl.usage.cost), display name "OrcaRouter"rust/src/core/context_kernel/provider_normalization.rscanonical_provider("openrouter")→ OpenAI shape, keeps provider labelcanonical_provider("orcarouter")→ samerust/src/proxy/usage_parity.rsProviderKind::OpenRouterProviderKind::OrcaRouterrust/src/core/config/schema/sections_advanced.rsllm.backendenum includesopenrouterorcarouterdocs/reference/generated/config-keys.mdTest plan
cd rust && cargo fmt --check— passedcd rust && cargo test -- --test-threads=1— not runnable in this container (no C toolchain / cargo network unavailable); CI will run the full suitecd rust && cargo clippy --all-targets --all-features -- -D warnings— same environment limitationGET /v1/models→ 200 (models listed invendor/modelform, e.g.anthropic/claude-fable-5,orcarouter/auto)POST /v1/chat/completions→ 200, OpenAI-shaped response whoseusagecarriescost,cost_details,prompt_tokens_details.cached_tokensandcache_write_tokens— exactly the OpenRouter usage dialect the lean-ctx OpenAI absorbers already parseNotes for reviewers
usage.includeopt-in injection stays OpenRouter-only (OrcaRouter already reports billedusage.costwithout it).ProviderKindvalues deserialize unchanged.docs/reference/generated/config-keys.mdsynced with the schema change.Contributor License Agreement
I have read the CLA Document and I hereby sign the CLA.
I'm an engineer on the OrcaRouter team.
Discord: discord.gg/YEubt8enRA · X: https://x.com/OrcaRouter