Repository navigation
feat: route all AI inference through OpenRouter GLM 5.3 Flash - #43
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (37)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change routes AI requests through OpenRouter with ChangesOpenRouter AI integration
Estimated code review effort: 5 (Critical) | ~90 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant AIProxy
participant ModelCatalog
participant OpenRouter
Client->>AIProxy: Submit model and reasoningEffort
AIProxy->>ModelCatalog: Validate model and resolve effort
ModelCatalog-->>AIProxy: Return limits and effective effort
AIProxy->>OpenRouter: Send chat completion request
OpenRouter-->>AIProxy: Return response and usage
AIProxy-->>Client: Return AI result
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing. Comment |
There was a problem hiding this comment.
🟡 Changes recommended
Add the missing reasoning translations, OpenRouter provider-error classification, and streaming usage option.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Routes AI inference through OpenRouter with GLM 5.3 Flash, reasoning controls, reported-cost accounting, settings migration, and localized copy updates.
Changes:
- Centralizes OpenRouter model routing and reasoning configuration.
- Adds cancellation-aware usage and cost handling.
- Updates settings, tests, documentation, and translations.
File summaries
| File | Summary |
|---|---|
supabase/README.md |
Documents OpenRouter configuration. |
supabase/functions/ai/index.ts |
Routes non-streaming inference through OpenRouter. |
supabase/functions/ai/handler-research.test.ts |
Tests routing, usage, and cancellation. |
supabase/functions/ai/generate-honesty_test.ts |
Updates provider test fixtures. |
supabase/functions/ai-stream/index.ts |
Implements streaming and cost accounting; usage option remains needed. |
supabase/functions/ai-stream/handler_test.ts |
Tests streaming behavior. |
supabase/functions/_shared/research.ts |
Propagates reasoning controls. |
supabase/functions/_shared/research.test.ts |
Updates research fixtures. |
supabase/functions/_shared/model-catalog.ts |
Defines model and reasoning policies. |
supabase/functions/_shared/model-catalog.test.ts |
Tests catalog behavior. |
supabase/functions/_shared/cost.ts |
Handles reported costs. |
supabase/functions/_shared/cost.test.ts |
Tests cost accounting. |
src/test/stores/settings-store-extended.test.ts |
Tests settings defaults. |
src/test/stores/settings-store-branches.test.ts |
Tests settings migrations. |
src/test/stores/settings-store-additional.test.ts |
Tests settings branches. |
src/test/settings-store.test.ts |
Tests canonicalization and persistence. |
src/test/security-hardening.test.ts |
Tests model allowlisting. |
src/test/providers.test.ts |
Tests the provider catalog. |
src/test/observability.test.ts |
Updates telemetry fixtures. |
src/test/components/ModelSelector.test.tsx |
Tests model and reasoning selection. |
src/test/ai/streaming.test.ts |
Updates streaming helper tests. |
src/test/ai/streaming-integration.test.ts |
Tests reasoning payload forwarding. |
src/test/ai/sparring.test.ts |
Updates sparring fixtures. |
src/test/ai/client.test.ts |
Tests client routing and reasoning. |
src/test/ai/client-branches.test.ts |
Updates client branch coverage. |
src/test/ai/client-analytics.test.ts |
Updates provider analytics expectations. |
src/pages/AskPage.tsx |
Uses OpenRouter result metadata. |
src/locales/hu.json |
Updates Hungarian copy. |
src/locales/es.json |
Updates Spanish copy. |
src/locales/en.json |
Updates English copy; reasoning labels need keys. |
src/lib/stores/settings-store.ts |
Migrates legacy settings and removes credentials. |
src/lib/ai/streaming.ts |
Updates streaming support and payloads. |
src/lib/ai/providers/types.ts |
Defines the OpenRouter provider catalog. |
src/lib/ai/client.ts |
Sends OpenRouter configuration; classifier needs OpenRouter support. |
src/components/ModelSelector.tsx |
Adds model and reasoning selectors. |
package.json |
Updates Edge test permissions. |
docs/architecture.md |
Documents routing and billing behavior. |
Review details
Suppressed comments (3)
src/components/ModelSelector.tsx:23
- The catalog declares GLM 5.3 Flash supports only
lowandhighreasoning (supabase/functions/_shared/model-catalog.ts:19), but this list exposesmediumto Pro users. Selecting it persists and sendsmedium, which the server silently coerces tolow, so the UI displays a setting that is not honored. Remove this option or derive the options from the selected model'ssupportedEfforts.
{ value: 'medium', labelKey: 'modelSelector.reasoningMedium', fallback: 'Medium' },
src/lib/ai/client.ts:372
- This change makes OpenRouter the provider reported by the client, but the existing
isProviderErrorMessageclassifier still recognizes only OpenAI, Anthropic, and Google. A backend failure such asOpenRouter error: ...has no error code and will therefore be surfaced as a generic AIError instead of AIProviderError, bypassing provider-specific handling and messaging; update the classifier/label mapping with this provider migration.
const provider = config.provider === 'mock' ? 'mock' : 'openrouter';
supabase/functions/ai-stream/index.ts:427
- OpenRouter only sends the terminal usage chunk for a streaming request when
stream_options.include_usageis enabled. With onlystream: truehere,streamUsageRawwill normally remain unset and successful Ask streams will be logged withcost_usd = null, so the new reported-cost accounting does not work for streaming. Add the usage option and assert it in the handler test.
- Files reviewed: 37/37 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const reasoningOptions: { value: ReasoningEffort; labelKey: string; fallback: string }[] = [ | ||
| { value: 'low', labelKey: 'modelSelector.reasoningLow', fallback: 'Low' }, | ||
| { value: 'medium', labelKey: 'modelSelector.reasoningMedium', fallback: 'Medium' }, | ||
| { value: 'high', labelKey: 'modelSelector.reasoningHigh', fallback: 'High' }, |
Summary
Verification
Summary by CodeRabbit
New Features
Documentation