Skip to content

feat(demo): add OrcaRouter as a first-class demo AI provider - #1573

Open
bangla24bdrang-lab wants to merge 1 commit into
prisma:mainfrom
bangla24bdrang-lab:feat/orcarouter-demo-provider
Open

feat(demo): add OrcaRouter as a first-class demo AI provider#1573
bangla24bdrang-lab wants to merge 1 commit into
prisma:mainfrom
bangla24bdrang-lab:feat/orcarouter-demo-provider

Conversation

@bangla24bdrang-lab

Copy link
Copy Markdown

Motivation

Prisma Studio is Prisma's visual editor for exploring and editing your database, and the ppg-dev demo in this repo powers all of its AI-assisted flows (table filtering, SQL generation, SQL result visualization, and Query Insights recommendations) through one shared llm hook. Today the demo server only supports Anthropic: it reads ANTHROPIC_API_KEY and 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. Adding orcarouter as 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-compatible https://api.orcarouter.ai/v1/chat/completions endpoint with the orcarouter/auto routing model, mirroring runAnthropicLlmRequest'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/ai handler now prefers OrcaRouter when ORCAROUTER_API_KEY is set, and falls back to the Anthropic path otherwise. The StudioLlmRequest/StudioLlmResponse contract is unchanged, so the embeddable Studio surface is unaffected.
  • demo/ppg-dev/config.ts β€” resolveDemoAiEnabled now treats either ANTHROPIC_API_KEY or ORCAROUTER_API_KEY as configuring the demo's AI, with the existing STUDIO_DEMO_AI_ENABLED override intact.
  • demo/ppg-dev/orcarouter.test.ts β€” unit tests mirroring anthropic.test.ts (request shape, auth header, log sanitization, API errors, output-limit error).
  • .env.example / README.md / FEATURES.md β€” document the new ORCAROUTER_API_KEY option 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.
  • Live test β€” a temporary test wired the real runOrcaRouterLlmRequest to https://api.orcarouter.ai/v1/chat/completions with the container-injected ORCAROUTER_API_KEY and confirmed a successful 200 response from the orcarouter/auto model. (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.

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>
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9e03ab49-c545-4c20-b088-06316222d311

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between c522665 and 8963e26.

πŸ“’ Files selected for processing (8)
  • .env.example
  • FEATURES.md
  • README.md
  • demo/ppg-dev/config.test.ts
  • demo/ppg-dev/config.ts
  • demo/ppg-dev/orcarouter.test.ts
  • demo/ppg-dev/orcarouter.ts
  • demo/ppg-dev/server.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Summary by CodeRabbit

  • New Features

    • Added OrcaRouter as an alternative AI provider for the demo.
    • AI is enabled when either Anthropic or OrcaRouter credentials are configured.
    • OrcaRouter is preferred when both providers are available.
    • Added clear handling for authentication failures, missing responses, and output-limit errors.
  • Documentation

    • Updated setup documentation and environment examples with OrcaRouter configuration instructions.

Walkthrough

The 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 llm hook contract remains unchanged. AI enablement checks both provider keys, and explicit environment values still override the default. The new client handles authentication, response errors, missing content, request logging, and output limits. Tests and setup documentation cover the new provider behavior.

Merge Risk: βšͺ Minimal Β· up to 8963e

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly and concisely identifies the main change: adding OrcaRouter as a first-class AI provider for the demo.
Description check βœ… Passed The description directly explains the OrcaRouter integration, provider preference behavior, tests, documentation updates, and validation results.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request has been flagged as potential spam (promotional) by CodeRabbit slop detection and should be reviewed carefully.

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