feat: add OrcaRouter as a dedicated model platform#4048
Conversation
OrcaRouter (https://orcarouter.ai) is an OpenAI-compatible LLM gateway that routes each request to the cheapest or fastest provider across 40+ upstream model providers (OpenAI, Anthropic, Google, Azure, AWS Bedrock, DeepSeek, etc.). This change mirrors the existing OpenRouter integration so users can select OrcaRouter via ModelPlatformType.ORCAROUTER instead of having to fall back to OPENAI_COMPATIBLE_MODEL with a manually filled base URL. - camel/types/enums.py: add ORCAROUTER platform enum + is_orcarouter property - camel/configs/orcarouter_config.py: new OrcaRouterConfig (mirrors OpenRouterConfig) - camel/models/orcarouter_model.py: new OrcaRouterModel (mirrors OpenRouterModel) - camel/models/model_factory.py: register ORCAROUTER -> OrcaRouterModel - examples/models/orcarouter_example.py: usage example - test/models/test_orcarouter_model.py: unit tests Model types are accepted as free-form strings since OrcaRouter routes across 40+ providers with a continuously evolving model catalog; no ORCAROUTER_* ModelType enum entries are predefined. Default base URL: https://api.orcarouter.ai/v1 Default API key env: ORCAROUTER_API_KEY
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
6794563 to
8e1dd7e
Compare
fengju0213
left a comment
There was a problem hiding this comment.
thanks for this pr!@zhenjunchen-png
left a comment
| ''' | ||
| =============================================================================== | ||
| This example demonstrates how to use OrcaRouter with the CAMEL framework. | ||
|
|
||
| OrcaRouter (https://orcarouter.ai) is an OpenAI-compatible LLM gateway that | ||
| sits between your application and 40+ upstream model providers. Each request | ||
| is routed to the cheapest or fastest provider that can serve the requested | ||
| model. | ||
|
|
||
| Before running this example, set the ORCAROUTER_API_KEY environment variable | ||
| with an API key from https://orcarouter.ai. | ||
| =============================================================================== | ||
| ''' |
There was a problem hiding this comment.
Here we usually put the actual results from running the model.
There was a problem hiding this comment.
Good catch — thanks! Added the live output from running the example against the OrcaRouter API to the trailing docstring (matches the convention in cometapi_model_example.py). Updated in 6c261f0.
Builds on the initial OrcaRouter platform integration to address model discoverability — CAMEL users targeting the dedicated platform now have both IDE autocomplete and a smart-routing default, without locking the catalog to a static list. Predefined `ModelType` entries (mirroring the OpenRouter / CometAPI pattern): `ORCAROUTER_AUTO`, `ORCAROUTER_GPT_5`, `ORCAROUTER_GPT_4O`, `ORCAROUTER_CLAUDE_OPUS_4_7`, `ORCAROUTER_CLAUDE_OPUS_4_6`, `ORCAROUTER_CLAUDE_SONNET_4_6`, `ORCAROUTER_GEMINI_2_5_PRO`. Any model id from the full catalog at https://docs.orcarouter.ai/ remains usable as a free-form `Union[ModelType, str]` value — predefined entries are just a curated subset for autocomplete. `ORCAROUTER_AUTO` ("orcarouter/auto") is OrcaRouter's smart-routing sentinel that picks the cheapest / fastest upstream provider per request. Documented as the recommended starting point in the model class docstring, the example file, and the mintlify model docs page. - camel/types/enums.py: 7 ModelType entries, `ModelType.is_orcarouter` property, registration in `support_native_tool_calling`, and `token_limit` entries covering all 7 (128K / 400K / 1M / 1_048_576) - camel/types/unified_model_type.py: `is_orcarouter` property (returns True) for string-based model_type usage - camel/models/orcarouter_model.py: docstring rewritten to lead with `ORCAROUTER_AUTO` + catalog link - camel/utils/commons.py: `ORCAROUTER_API_KEY` entry in `env_key_urls` so the missing-key error points users to https://orcarouter.ai/ - examples/models/orcarouter_example.py: three scenarios — AUTO, predefined enum, free-form string - docs/mintlify/key_modules/models.mdx: new `<Tab title="OrcaRouter">` mirroring the CometAPI structure, with an `<Note>` callout for the smart-routing flow; "API & Connector Platforms" table row - docs/key_modules/models.md: plain-text table row - docs/mintlify/docs.json: nav entries for the auto-generated `camel.models.orcarouter_model` / `camel.configs.orcarouter_config` reference pages - test/models/test_orcarouter_model.py: parametrized tests over the 7 predefined enums (token limit / tool-call capability / OrcaRouter membership at ModelType level) + free-form string regression cases + `from_name("orcarouter")` round-trip
Per review feedback from @fengju0213 on camel-ai#4048, attach the live output from running the example against the OrcaRouter API to the trailing docstring (matches the convention used in cometapi_model_example.py).
…ting
Predefined `ModelType.ORCAROUTER_*` set replaced to match the current
flagship lineup at OrcaRouter:
Removed: ORCAROUTER_GPT_4O, ORCAROUTER_CLAUDE_OPUS_4_6,
ORCAROUTER_CLAUDE_SONNET_4_6, ORCAROUTER_GEMINI_2_5_PRO
Added: ORCAROUTER_GEMINI_3_FLASH_PREVIEW, ORCAROUTER_GROK_4_3
Final five (in priority order): ORCAROUTER_AUTO, ORCAROUTER_GPT_5,
ORCAROUTER_CLAUDE_OPUS_4_7, ORCAROUTER_GEMINI_3_FLASH_PREVIEW,
ORCAROUTER_GROK_4_3. `ModelType.is_orcarouter` and the `token_limit`
buckets (128K / 400K / 1M / 1_048_576) updated to match.
Documentation: the `<Tab title="OrcaRouter">` in
docs/mintlify/key_modules/models.mdx now leads with a "How
orcarouter/auto works" section that describes the five router
strategies (cheapest / balanced / quality / adaptive (LinUCB) /
gated_adaptive), the reward signal that drives the adaptive
strategies, and the differentiator over fixed-model gateways. The
console URL for configuring routers is linked.
URL audit: split usages by intent — homepage `www.orcarouter.ai`,
model catalog `www.orcarouter.ai/models`, API/routing reference
`docs.orcarouter.ai`. `commons.py` env_key_urls + model docstring
catalog reference updated to match.
Example: scenario 2 now pins `ORCAROUTER_CLAUDE_OPUS_4_7` (was 4.6)
without an `OrcaRouterConfig(temperature=...)` because Claude Opus
4.7 is a reasoning model that rejects `temperature`. The trailing
"Sample output" docstring is refreshed from a live run against the
OrcaRouter API.
| # (cheapest / balanced / quality / adaptive / gated_adaptive) is | ||
| # configurable from the OrcaRouter console — the adaptive strategies | ||
| # learn the best upstream per workload from production traffic. | ||
| ORCAROUTER_AUTO = "orcarouter/auto" |
There was a problem hiding this comment.
We usually don’t use auto as the model name, because users won’t know which model is actually being used, and it also makes the token limit difficult to set.
There was a problem hiding this comment.
okay,then this PR should be fine.
Related Issue
Closes #4047
Description
Adds
ModelPlatformType.ORCAROUTERas a dedicated model platform, mirroring the existingOpenRouter/ModelScopeintegrations. OrcaRouter (https://www.orcarouter.ai) is an OpenAI-compatible LLM gateway with an adaptive routing engine that picks the upstream model per request.Why a dedicated platform rather than
OPENAI_COMPATIBLE_MODELThis is the question raised on #3282 (n1n.ai). The reason OrcaRouter falls on the OpenRouter / CometAPI side of that line:
orcarouter/autois a router, not a model id. It dispatches each request via one of five configurable strategies —cheapest,balanced,quality,adaptive(LinUCB contextual bandit; learns from production traffic), orgated_adaptive(adaptive plus a difficulty pre-filter that routes mundane prompts to a "weak" model pool and hard prompts to a "strong" one). The dedicatedModelType.ORCAROUTER_AUTOenum surfaces this as a first-class entry —OPENAI_COMPATIBLE_MODELcan only present it as an opaque string.OrcaRouterConfig.extra_bodycarries OrcaRouter-specific routing preferences and fallback model lists through to the API — encoded as a typed config field on this provider's class rather than polluting the generic OpenAI surface.Union[ModelType, str]is still accepted for the full catalog at https://www.orcarouter.ai/models, but a curated set ofModelType.ORCAROUTER_*enums (AUTO, GPT_5, CLAUDE_OPUS_4_7, GEMINI_3_FLASH_PREVIEW, GROK_4_3) shows up in autocomplete and is wired intotoken_limit/support_native_tool_callinglike other dedicated platforms.The mintlify docs section under
docs/mintlify/key_modules/models.mdxwalks through howorcarouter/autoworks, including the reward signal that drives the adaptive strategies (success / cost / latency / rate-limit / structured-output format).What is the purpose of this pull request?
Checklist
test/models/test_orcarouter_model.py— 14 cases covering predefined enums + free-form strings + platformfrom_nameround-trip +extra_bodyconfig)docs/mintlify/key_modules/models.mdx(<Tab title="OrcaRouter">with adaptive-routing explainer + table row),docs/key_modules/models.md(synced),docs/mintlify/docs.json(nav entries)examples/models/orcarouter_example.py, three scenarios — AUTO / predefined enum / free-form string — with live output captured in the trailing docstring)Files
camel/types/enums.pyModelPlatformType.ORCAROUTER = "orcarouter"+is_orcarouterproperty; 5ModelType.ORCAROUTER_*entries +is_orcarouterModelType property; registered insupport_native_tool_calling;token_limitcovered for all 5camel/types/unified_model_type.pyis_orcarouterproperty (returns True) for free-form string usagecamel/configs/orcarouter_config.py(new)OrcaRouterConfig(BaseConfig)with standard OpenAI-compat params plusextra_bodyfor OrcaRouter-specific routing pass-throughcamel/configs/__init__.pyOrcaRouterConfig,ORCAROUTER_API_PARAMScamel/models/orcarouter_model.py(new)OrcaRouterModel(OpenAICompatibleModel)— base URLhttps://api.orcarouter.ai/v1, envORCAROUTER_API_KEY; docstring leads withORCAROUTER_AUTOquickstartcamel/models/__init__.pyOrcaRouterModelcamel/models/model_factory.pyORCAROUTER -> OrcaRouterModelcamel/utils/commons.pyenv_key_urlsentry pointing to https://www.orcarouter.ai/examples/models/orcarouter_example.py(new)test/models/test_orcarouter_model.py(new)docs/mintlify/key_modules/models.mdx<Tab title="OrcaRouter">with adaptive-routing explainer +<Note>callout + table rowdocs/key_modules/models.mddocs/mintlify/docs.jsoncamel.models.orcarouter_model/camel.configs.orcarouter_configTesting evidence
Live run against the OrcaRouter API (also captured in
examples/models/orcarouter_example.pydocstring):Disclosure
I'm an engineer on the OrcaRouter team.