feat(demo): add OrcaRouter as a first-class demo AI provider - #1573
feat(demo): add OrcaRouter as a first-class demo AI provider#1573bangla24bdrang-lab wants to merge 1 commit into
Conversation
Wire the ppg-dev demo's shared llm hook to OrcaRouter's OpenAI-compatible endpoint via ORCAROUTER_API_KEY, mirroring the existing Anthropic transport. When both keys are present, the demo prefers OrcaRouter. Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: π Files selected for processing (8)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. Summary by CodeRabbit
WalkthroughThe ppg-dev demo now supports Anthropic and OrcaRouter API keys. OrcaRouter uses an OpenAI-compatible chat completions endpoint and takes precedence when configured. The shared Merge Risk: βͺ Minimal Β· up to This PR adds an optional OrcaRouter provider with fallback to the existing path, and no actionable merge-blocking risk remains after normal checks and review. π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (3 skipped: 3 unsupported.)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
β¨ Simplify code
Comment Warning |
Motivation
Prisma Studio is Prisma's visual editor for exploring and editing your database, and the
ppg-devdemo in this repo powers all of its AI-assisted flows (table filtering, SQL generation, SQL result visualization, and Query Insights recommendations) through one sharedllmhook. Today the demo server only supports Anthropic: it readsANTHROPIC_API_KEYand calls the Messages API directly.This PR adds OrcaRouter as a first-class demo AI provider, mirroring the existing Anthropic transport in
demo/ppg-dev/anthropic.ts. OrcaRouter is an OpenAI-compatible AI gateway built for both models and agents. Like OpenRouter, it exposes a provider/model namespace across many models β but it also combines adaptive routing, automatic failover, zero-markup inference, observability, guardrails, and agent-tool governance behind the same endpoint. Addingorcarouteras a named provider means demo users can use that stack directly, without treating OrcaRouter as an anonymous custom base URL. It also runs gateway-level, zero-trust security for AI agents on the same endpoint β screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.Changes
demo/ppg-dev/orcarouter.tsβ new transport that calls OrcaRouter's OpenAI-compatiblehttps://api.orcarouter.ai/v1/chat/completionsendpoint with theorcarouter/autorouting model, mirroringrunAnthropicLlmRequest's structure, logging behavior (no key/prompt leakage), error surfacing, and output-limit handling (finish_reason: "length"βoutput-limit-exceeded).demo/ppg-dev/server.tsβ the/api/aihandler now prefers OrcaRouter whenORCAROUTER_API_KEYis set, and falls back to the Anthropic path otherwise. TheStudioLlmRequest/StudioLlmResponsecontract is unchanged, so the embeddable Studio surface is unaffected.demo/ppg-dev/config.tsβresolveDemoAiEnablednow treats eitherANTHROPIC_API_KEYorORCAROUTER_API_KEYas configuring the demo's AI, with the existingSTUDIO_DEMO_AI_ENABLEDoverride intact.demo/ppg-dev/orcarouter.test.tsβ unit tests mirroringanthropic.test.ts(request shape, auth header, log sanitization, API errors, output-limit error)..env.example/README.md/FEATURES.mdβ document the newORCAROUTER_API_KEYoption and the preference order.Validation
pnpm typecheckβ clean.pnpm lintβ 0 errors on the changed files.pnpm test:demoβ 55/55 passing, including the 4 new OrcaRouter unit tests and the updated config tests.runOrcaRouterLlmRequesttohttps://api.orcarouter.ai/v1/chat/completionswith the container-injectedORCAROUTER_API_KEYand confirmed a successful 200 response from theorcarouter/automodel. (The temp test was removed before submitting.)Feedback and contributions welcome β happy to adjust the demo transport naming or preference behavior to match Prisma's conventions.
Discord: discord.gg/YEubt8enRA Β· X: https://x.com/OrcaRouter
I'm an engineer on the OrcaRouter team.