feat: add named OrcaRouter provider for chat streaming - #572
Conversation
Adds a first-class OrcaRouter provider to the API surface, mirroring the existing OpenRouter/LiteLLM wiring: - New OrcaRouterClient (OpenAI-compatible) in api/clients/orcarouter.py with ORCAROUTER_API_KEY env support and base URL https://api.orcarouter.ai/v1 - OrcaRouterChatStreamer registered in api/chat/_stream.py - Wired into CLIENT_CLASSES and _DEFAULT_PROVIDER_MAP in api/config.py - orcarouter provider block in api/config/generator.json with namespaced model ids (openai/gpt-5.5, openai/gpt-4o, anthropic/claude-sonnet-4.5, etc.) - providerOrcaRouter / useOrcaRouter / orcaRouterModel i18n keys across all 10 message files - Unit tests for provider registration and ChatStreamer.create resolution - Provider docs in api/README.md Co-Authored-By: Claude <noreply@anthropic.com>
Greptile SummaryAdds OrcaRouter as an OpenAI-compatible chat-streaming provider across backend configuration, client construction, frontend model selection, tests, and documentation.
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking localization issue in the newly added OrcaRouter labels. The backend provider registration, model lookup, client construction, and streaming path are complete, but the new API and model labels remain English in every non-English message catalog. Files Needing Attention: src/messages/es.json and the other changed non-English locale files
|
| Filename | Overview |
|---|---|
| api/clients/orcarouter.py | Adds an OpenAI-compatible client with OrcaRouter API-key and base-URL resolution; no concrete defect was established. |
| api/chat/_stream.py | Adds an automatically registered OrcaRouter streamer using the existing OpenAI-compatible streaming path. |
| api/config.py | Registers OrcaRouter in client-class and default-provider mappings and loads its API key. |
| api/config/generator.json | Defines OrcaRouter defaults, selectable models, parameters, and custom-model support. |
| src/messages/es.json | Adds the required OrcaRouter keys, but two user-facing labels remain untranslated; the same issue affects the other changed non-English catalogs. |
| tests/unit/test_chat.py | Extends registry and factory coverage to the new OrcaRouter streamer. |
Sequence Diagram
sequenceDiagram
participant UI as Model Selector
participant API as Models/Chat API
participant Config as Generator Config
participant Streamer as OrcaRouterChatStreamer
participant Client as OrcaRouterClient
participant Orca as OrcaRouter API
UI->>API: Select provider and model
API->>Config: Resolve orcarouter model config
Config-->>API: OrcaRouterClient and model kwargs
API->>Streamer: Create provider streamer
Streamer->>Client: Build OpenAI-compatible client
Client->>Orca: Stream chat completion
Orca-->>Client: Completion chunks
Client-->>UI: Stream response text
Reviews (1): Last reviewed commit: "Add named OrcaRouter provider for chat s..." | Re-trigger Greptile
| "useOpenRouter": "Usar API de OpenRouter", | ||
| "useOrcaRouter": "Use OrcaRouter API", | ||
| "openRouterModel": "Modelo OpenRouter", |
There was a problem hiding this comment.
Localize the OrcaRouter labels
The new useOrcaRouter and orcaRouterModel labels remain in English in every changed non-English catalog, leaving these controls inconsistent with the surrounding localized interface.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Adds a named OrcaRouter provider to the chat streaming stack, mirroring the existing OpenRouter client/streamer wiring. OrcaRouter is an OpenAI-compatible model routing gateway that exposes models from OpenAI, Anthropic, Google, DeepSeek, Qwen and others behind a single endpoint and API key. It also provides gateway-level security controls for AI agents — screening prompts and responses and governing tool calls without application code changes.
I'm an engineer on the OrcaRouter team.
Changes
Backend
api/clients/orcarouter.py(new):OrcaRouterClient(OpenAIClient)— readsORCAROUTER_API_KEY/ORCAROUTER_BASE_URL, default base URLhttps://api.orcarouter.ai/v1, OpenAI-compatible sync/async clients.api/clients/__init__.py+api/config.py: registerOrcaRouterClientin__all__,CLIENT_CLASSES, and_DEFAULT_PROVIDER_MAP("orcarouter": OrcaRouterClient); forwardORCAROUTER_API_KEYenv.api/chat/_stream.py:OrcaRouterChatStreamer(_OpenAICompatStreamer)withprovider="orcarouter".api/config/generator.json:orcarouterprovider block — defaultopenai/gpt-5.5, plusopenai/gpt-5-nano,gpt-5-mini,gpt-4o,gpt-4.1,anthropic/claude-sonnet-4.5.Frontend
src/messages/*.json(10 locale files):providerOrcaRouter/useOrcaRouter/orcaRouterModelkeys after the OpenRouter keys — theUserSelectorprovider dropdown and i18n display name pick these up automatically.Tests & docs
tests/unit/test_chat.py:("orcarouter", OrcaRouterChatStreamer)cases in the registry andcreate()parametrized tests.api/README.md: env example, key acquisition, provider list, generator.json description.Usage
Select
OrcaRouterin the model dropdown (default modelopenai/gpt-5.5; any namespaced model id from https://www.orcarouter.ai/models works).Verification
pytest tests/unit/test_chat.py→ 21 passed (incl. 2 new orcarouter cases). Fulltests/unit/32 passed / 7 failed — the 7 failures are identical on the clean baseline (test_all_embedders.py, environment-related, not introduced here).ChatStreamer.create('orcarouter')→OrcaRouterChatStreamer→OrcaRouterClient→https://api.orcarouter.ai/v1;chat.completionswithopenai/gpt-4.1→ 200,finish=stop.