feat: add orcarouter llm2 extension#2206
Open
jinhaosong-source wants to merge 1 commit into
Open
Conversation
OrcaRouter is an OpenAI-compatible meta-router, so this extension reuses the OpenAI SDK and only changes defaults: base_url is https://api.orcarouter.ai/v1 and model is orcarouter/auto. It supports streaming, tool calling, reasoning output, and custom attribution headers, and passes routing controls (models + route: fallback) through request parameters. Register it in the voice-assistant example dependency list and document ORCAROUTER_* in .env.example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Adds an OrcaRouter LLM2 provider extension:
orcarouter_llm2_python.OrcaRouter is an OpenAI-compatible meta-router — a single endpoint over many upstream models that also layers gateway-level zero-trust security for AI agents (scoped keys, guardrails, tool allow-lists, audit trail) and a routing DSL for per-request upstream selection. Because it speaks the OpenAI Chat Completions protocol, the extension mirrors
gemini_llm2_python/openai_llm2_python: it reuses the OpenAI SDK and only changes the defaults (base_url→https://api.orcarouter.ai/v1,model→orcarouter/auto).Included
ai_agents/agents/ten_packages/extension/orcarouter_llm2_python/— the extension (manifest.json,property.json,addon.py,extension.py,orcarouter.py,think_parser.py,__init__.py,pyproject.toml,requirements.txt,README.md).tests/— pure-logic unit tests for the streaming<think>reasoning parser (run anywhere) and config-default tests (skipped whereten_ai_baseis unavailable), plus the standardconftest.pyharness and config fixtures.voice-assistantexample dependency list (additive — the default graph is unchanged).ORCAROUTER_*documented inai_agents/.env.example.Features
<think>blocks andreasoning_content) work unchanged via the OpenAI-compatible protocol.model="orcarouter/auto"lets OrcaRouter pick a live model per request (strategy configured in the OrcaRouter console).{"models": ["openai/gpt-4o", "anthropic/claude-haiku-4.5"], "route": "fallback"}.custom_headersforwardsHTTP-Referer/X-Titlefor console attribution.How I verified
Beyond the unit tests, I ran the extension's exact client path (OpenAI SDK with
base_url+default_headers) against the live OrcaRouter API:model="openai/gpt-4o"streamed content deltas correctly.get_weathertool was invoked as expected.extra_body={"models": [...], "route": "fallback"}resolved to a live model and returned a completion.temperatureare accepted even when a request is routed to a reasoning model), so the extension sends the standard OpenAI parameters unconditionally.Notes