Skip to content

feat: add named OrcaRouter provider for chat streaming - #572

Open
Marc-oss-hub wants to merge 1 commit into
AsyncFuncAI:mainfrom
Marc-oss-hub:feat/orcarouter-provider
Open

feat: add named OrcaRouter provider for chat streaming#572
Marc-oss-hub wants to merge 1 commit into
AsyncFuncAI:mainfrom
Marc-oss-hub:feat/orcarouter-provider

Conversation

@Marc-oss-hub

Copy link
Copy Markdown

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) — reads ORCAROUTER_API_KEY / ORCAROUTER_BASE_URL, default base URL https://api.orcarouter.ai/v1, OpenAI-compatible sync/async clients.
  • api/clients/__init__.py + api/config.py: register OrcaRouterClient in __all__, CLIENT_CLASSES, and _DEFAULT_PROVIDER_MAP ("orcarouter": OrcaRouterClient); forward ORCAROUTER_API_KEY env.
  • api/chat/_stream.py: OrcaRouterChatStreamer(_OpenAICompatStreamer) with provider="orcarouter".
  • api/config/generator.json: orcarouter provider block — default openai/gpt-5.5, plus openai/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 / orcaRouterModel keys after the OpenRouter keys — the UserSelector provider dropdown and i18n display name pick these up automatically.

Tests & docs

  • tests/unit/test_chat.py: ("orcarouter", OrcaRouterChatStreamer) cases in the registry and create() parametrized tests.
  • api/README.md: env example, key acquisition, provider list, generator.json description.

Usage

ORCAROUTER_API_KEY=sk-orca-...

Select OrcaRouter in the model dropdown (default model openai/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). Full tests/unit/ 32 passed / 7 failed — the 7 failures are identical on the clean baseline (test_all_embedders.py, environment-related, not introduced here).
  • L4 live via ChatStreamer.create('orcarouter')OrcaRouterChatStreamerOrcaRouterClienthttps://api.orcarouter.ai/v1; chat.completions with openai/gpt-4.1 → 200, finish=stop.

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-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown

Greptile Summary

Adds OrcaRouter as an OpenAI-compatible chat-streaming provider across backend configuration, client construction, frontend model selection, tests, and documentation.

  • Registers the OrcaRouter client and streamer with API-key and base-URL configuration.
  • Adds default and selectable OrcaRouter models, including custom-model support.
  • Exposes localized provider labels and documents setup and usage.

Confidence Score: 4/5

The 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

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "Add named OrcaRouter provider for chat s..." | Re-trigger Greptile

Comment thread src/messages/es.json
Comment on lines 52 to 54
"useOpenRouter": "Usar API de OpenRouter",
"useOrcaRouter": "Use OrcaRouter API",
"openRouterModel": "Modelo OpenRouter",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

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.

1 participant