morphic icon indicating copy to clipboard operation
morphic copied to clipboard

Add OrcaRouter as a selectable AI provider

Open zhenjunchen-png opened this issue 6 months ago • 2 comments

Feature Description

I'd like to add support for OrcaRouter (https://www.orcarouter.ai) as an AI provider in Morphic's model selector.

OrcaRouter is an OpenAI-compatible routing layer: a single endpoint (https://api.orcarouter.ai/v1, keys prefixed sk-orca-) that fronts 160+ models from OpenAI, Anthropic, Google, DeepSeek, xAI, Qwen, MiniMax and others.

Its main feature is request-level routing. Alongside the concrete models, OrcaRouter exposes a virtual router model id, orcarouter/auto, that selects an upstream per request according to a configurable strategy:

  • cheapest — lowest-priced upstream that can serve the request (default)
  • balanced — trades off price vs. latency vs. quality
  • quality — highest-quality upstream
  • adaptive — a contextual bandit that learns from your own traffic, routing on per-request features (prompt length, code/math/JSON density, token budget, similarity to recent requests)
  • gated_adaptive — adds a task-difficulty gate so easy prompts go to a cheaper pool, hard prompts to a stronger pool

Routing is workload-aware within a single endpoint (a short query and a long reasoning task can hit the same orcarouter/auto id and land on different upstreams), adds negligible routing latency, and the strategy/pools are tunable from the OrcaRouter console without any client change. Per-request model preferences and fallback chains can also be passed via extra_body (e.g. {"models": [...], "route": "fallback"}).

Proposal: add a dedicated orcarouter provider (in lib/utils/registry.ts via createOpenAICompatible, with a fetcher in lib/models/fetch-models.ts reading the OpenAI-shaped /v1/models list), enabled by an ORCAROUTER_API_KEY env var, so users can select OrcaRouter models — including orcarouter/auto — directly in the model selector.

Why a dedicated OrcaRouter provider:

  • The routing is the feature, and a generic label hides it. orcarouter/auto and the per-request strategies above are the reason to reach for OrcaRouter. Behind an anonymous "OpenAI Compatible" entry, a Morphic user has no way to discover them or reason about which strategy they're on.
  • One key surfaces 160+ models — which is exactly what the model selector is for. A single ORCAROUTER_API_KEY populates the selector with models across OpenAI, Anthropic, Google, DeepSeek, xAI and more, instead of the user provisioning and rotating separate keys per vendor.
  • It lines up with Quick vs. Adaptive search modes. Morphic already separates a fast mode from a higher-quality one; OrcaRouter's cheapest / quality routing maps onto that per request, so the cost/quality tradeoff follows the search mode without anyone hardcoding a model.
  • A dedicated provider coexists with the built-in ones. OrcaRouter shows up as its own entry in the selector alongside OpenAI, Anthropic, Google and the rest.

I'd be glad to send the PR — provider, model fetcher, tests, and docs (.env.local.example + docs/CONFIGURATION.md). Does a dedicated OrcaRouter provider fit Morphic's direction?

Use Case

Morphic's research agents drive every answer through an LLM, so model choice directly affects cost and answer quality. With orcarouter/auto, a Morphic user sets one API key and lets routing pick the upstream per request — cheap models for short lookups, stronger models for heavy reasoning — without hardcoding a model or managing several provider keys. Users who want explicit control can still pick any of the 160+ concrete models from the selector.

(Note: Morphic's agents rely on tool calling. Users choosing orcarouter/auto should keep their router pool restricted to tool-capable upstreams, or pin a tool-capable model such as orcarouter/openai/gpt-5.5; I'd document this caveat.)

Additional context

Disclosure: I'm an engineer on the OrcaRouter team.

  • API base: https://api.orcarouter.ai/v1 · Docs: https://docs.orcarouter.ai · Routing console: https://www.orcarouter.ai/console/routing
  • GET https://api.orcarouter.ai/v1/models returns an OpenAI-shaped list, so dynamic model detection works the same way as the other providers.

Verified locally (running Morphic with the AI pointed at OrcaRouter): the model selector lists OrcaRouter models including orcarouter/auto, and a real search returns a cited answer end-to-end — tool calling included.

Image

Model selector showing the OrcaRouter group and orcarouter/auto selected.

Image

A search answering "capital of France" with cited sources, generated via orcarouter/auto.

GET /v1/models (Bearer) -> 161 models, includes "orcarouter/auto" orcarouter/auto -> routed to a Claude model, returned a cited answer with tool calls

zhenjunchen-png avatar May 27 '26 07:05 zhenjunchen-png

Thanks for the detailed write-up, and for the disclosure that you're on the OrcaRouter team. Appreciated.

A couple of things make me hesitant to add a dedicated orcarouter provider:

1. Why OrcaRouter specifically? A single-vendor provider opens the door to maintaining one for every routing service (OpenRouter, AI/ML API in #562, and so on). I'd rather keep the provider list to first-party SDKs plus generic escape hatches, instead of curating individual third-party routers.

2. The routing/multi-model use case is already covered. Morphic ships with Vercel AI Gateway (AI_GATEWAY_API_KEY) for exactly the "one key, 200+ models with routing" story, plus a generic OpenAI-Compatible provider. We went with Vercel AI Gateway because Morphic is built on the Vercel AI SDK and deploys on Vercel, so the Gateway is the natural first-party fit: it's maintained as part of the same SDK, stays vendor-neutral, and needs no extra integration code on our side.

Since OrcaRouter exposes an OpenAI-shaped /v1 endpoint (including /v1/models), it should work today with no code changes through the existing OPENAI_COMPATIBLE_* settings. This path is the same createOpenAICompatible + /v1/models flow your proposal describes:

OPENAI_COMPATIBLE_API_KEY=sk-orca-...
OPENAI_COMPATIBLE_API_BASE_URL=https://api.orcarouter.ai/v1
OPENAI_COMPATIBLE_PROVIDER_NAME=OrcaRouter
# Optional: restrict the selector, e.g. pin a tool-capable model
OPENAI_COMPATIBLE_MODELS=orcarouter/auto,orcarouter/openai/gpt-5.5

orcarouter/auto and the per-request strategies should flow through unchanged. I haven't verified this against a live OrcaRouter key myself, so if you can confirm it works end-to-end via these env vars (tool calling included), that'd be great.

So rather than a new provider, if you'd find it useful, I'd happily accept a small docs PR adding an OrcaRouter setup example to the OpenAI-Compatible Providers section of docs/CONFIGURATION.md. That could include the tool-calling caveat you mentioned (restrict the pool to tool-capable upstreams, or pin a model like orcarouter/openai/gpt-5.5), giving OrcaRouter users a clear path without adding a single-vendor integration to the core.

miurla avatar May 28 '26 05:05 miurla

Thanks for the thoughtful response, Atsushi — understood, and happy to take the docs PR route.

Confirming the env-var path: I ran Morphic locally with OPENAI_COMPATIBLE_* pointed at OrcaRouter, and a real search returns a cited answer end-to-end including tool calling — the screenshots in the issue above are from exactly that setup (no code changes). /v1/models enumerates correctly into the selector under the "OrcaRouter" label.

I'll send the docs PR for docs/CONFIGURATION.md under OpenAI-Compatible Providers, with a worked example pinned to tool-capable models so Morphic's research agents work out of the box. I'll keep it tight and won't touch the surrounding sections.

zhenjunchen-png avatar May 28 '26 09:05 zhenjunchen-png