feat(models): add GPT-5 series, Gemini, and Deepseek models with Routeway discount - #925
Conversation
…i 2.5 Pro - Add routeway-discount provider option to GPT-5 Mini with same pricing and capabilities - Add routeway-discount provider option to Gemini 2.5 Pro with same pricing and capabilities - Both models apply ROUTEWAY_PAID_DISCOUNT environment variable for pricing discounts - Fix testing.ts import to use relative paths instead of alias imports 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
❌ Preview Environment deleted from BunnyshellAvailable commands (reply to this comment):
|
WalkthroughAdds Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Prep as prepare-request-body
Note right of Prep: Model provider metadata updated across models (routeway-discount entries)
Client->>Prep: build request (includes response_format, usedModel, provider)
alt provider == "routeway-discount" && response_format.type == "json_object"
alt usedModel startsWith "claude-"
Prep->>Prep: set response_format.type = "json"
Prep-->>Client: return prepared body (json)
else
Prep-->>Client: return prepared body (json_object) unchanged
end
else
Prep-->>Client: return prepared body (other branches)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2){apps/api,apps/gateway,apps/ui,apps/docs,packages}/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/models/src/models/openai.ts (1)
400-423: Guard ROUTWAY_PAID_DISCOUNT and apply to all routeway-discount entries
- Replace parseFloat(...) with a finite-number check that defaults to 1:
- discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"), + discount: (() => { + const v = Number(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"); + return Number.isFinite(v) && v > 0 ? v : 1; + })(),
- Occurrences to update: packages/models/src/models/openai.ts, packages/models/src/models/google.ts, and multiple entries in packages/models/src/models/anthropic.ts — apply the same guard everywhere.
- Ensure the provider/model type includes a
discountfield (or update the type) to avoid TypeScript errors.packages/models/src/models/google.ts (1)
23-35: Types already includediscount; validate ROUTEWAY_PAID_DISCOUNT parsing across models.
- No type change required:
ProviderModelMapping/ModelDefinitionalready declarediscount?: number(packages/models/src/models.ts, packages/models/src/types.ts).- Harden env parsing: replace
parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1")with a validated parse that returns a finite, positive number and falls back to1; apply to occurrences in packages/models/src/models/google.ts, packages/models/src/models/openai.ts, packages/models/src/models/anthropic.ts (and any other files using ROUTEWAY_PAID_DISCOUNT).Suggested inline hardening:
- discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"), + discount: (() => { + const v = Number(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"); + return Number.isFinite(v) && v > 0 ? v : 1; + })(),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/models/src/models/google.ts(1 hunks)packages/models/src/models/openai.ts(1 hunks)packages/models/src/testing.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
{apps/api,apps/gateway,apps/ui,apps/docs,packages}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Always use top-level import; never use require() or dynamic imports (e.g., import(), next/dynamic)
Files:
packages/models/src/models/openai.tspackages/models/src/models/google.tspackages/models/src/testing.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Never useanyoras anyin this TypeScript project unless absolutely necessary
Always use top-levelimport; never userequireor dynamic imports
Files:
packages/models/src/models/openai.tspackages/models/src/models/google.tspackages/models/src/testing.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: e2e-shards (2)
- GitHub Check: e2e-shards (3)
- GitHub Check: e2e-shards (1)
🔇 Additional comments (1)
packages/models/src/testing.ts (1)
1-1: Import change OK — TS ESM resolution verified; confirm runtime JS outputpackages/models/src/models.ts exports
models. Root tsconfig uses module: "NodeNext" / moduleResolution: "NodeNext" and apps' tsconfigs use moduleResolution: "bundler" — TypeScript accepts explicit .js imports in these modes. Could not verify emitted JS in the repo; ensure your build emits ./models.js at runtime.
- Add routeway-discount provider to GPT-5 with same pricing and capabilities - Add routeway-discount provider to GPT-5 Nano with same pricing and capabilities - Add routeway-discount provider to Gemini 2.5 Flash with same pricing and capabilities - Add routeway-discount provider to Gemini 2.5 Flash Lite with same pricing and capabilities - Add routeway-discount provider to DeepSeek V3.1 Chat with same pricing and capabilities - Add routeway-discount provider to DeepSeek R1 Reasoner with same pricing and capabilities - All models apply ROUTEWAY_PAID_DISCOUNT environment variable for pricing discounts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/models/src/models/openai.ts (1)
367-390: Optional: parse once and reuse.Minor DRY+hardening: parse discount once per module and reuse; also guard against NaN. Example:
// top-of-file (after imports) const ROUTEWAY_DISCOUNT = (() => { const v = process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"; const n = Number(v); return Number.isFinite(n) ? n : 1; })();Then use
discount: ROUTEWAY_DISCOUNTin providers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/models/src/models/deepseek.ts(2 hunks)packages/models/src/models/google.ts(3 hunks)packages/models/src/models/openai.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
{apps/api,apps/gateway,apps/ui,apps/docs,packages}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Always use top-level import; never use require() or dynamic imports (e.g., import(), next/dynamic)
Files:
packages/models/src/models/google.tspackages/models/src/models/deepseek.tspackages/models/src/models/openai.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Never useanyoras anyin this TypeScript project unless absolutely necessary
Always use top-levelimport; never userequireor dynamic imports
Files:
packages/models/src/models/google.tspackages/models/src/models/deepseek.tspackages/models/src/models/openai.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build / run
- GitHub Check: test / run
- GitHub Check: lint / run
- GitHub Check: generate / run
- GitHub Check: e2e-shards (4)
- GitHub Check: e2e-shards (2)
- GitHub Check: e2e-shards (5)
- GitHub Check: e2e-shards (3)
- GitHub Check: e2e-shards (1)
- GitHub Check: autofix
| modelName: "deepseek-reasoner", | ||
| inputPrice: 0.55 / 1e6, | ||
| outputPrice: 2.19 / 1e6, | ||
| discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"), |
There was a problem hiding this comment.
Fix discount fallback: use ?? not ||.
Ensure "0" is not coerced to default.
Apply:
- discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
+ discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"),Also applies to: 170-170
🤖 Prompt for AI Agents
In packages/models/src/models/deepseek.ts around lines 62 and 170, the discount
parseFloat fallback currently uses || which treats the string "0" as falsy and
incorrectly falls back; change the fallback to the nullish coalescing operator
(??) so you call parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1") (and the
analogous environment variable at line 170) to preserve explicit "0" while still
defaulting when the env var is undefined or null.
| modelName: "gemini-2.5-pro", | ||
| inputPrice: 1.25 / 1e6, | ||
| outputPrice: 10.0 / 1e6, | ||
| discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"), |
There was a problem hiding this comment.
Fix discount fallback: respect "0" values.
Same issue as above: replace || "1" with ?? "1" to avoid overriding "0" discounts.
Apply:
- discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
+ discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"),Also applies to: 150-150, 186-186
🤖 Prompt for AI Agents
In packages/models/src/models/google.ts around lines 28, 150, and 186 the
discount fallback uses the logical OR operator (|| "1"), which incorrectly
treats a valid "0" discount as falsy and overrides it; update each occurrence to
use the nullish coalescing operator (?? "1") so that only null/undefined
fallbacks to "1" while legitimate "0" values are preserved.
| inputPrice: 1.25 / 1e6, | ||
| outputPrice: 10.0 / 1e6, | ||
| cachedInputPrice: 0.125 / 1e6, | ||
| discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"), |
There was a problem hiding this comment.
🧩 Analysis chain
Use nullish coalescing for ROUTEWAY_PAID_DISCOUNT (avoid breaking on "0").
|| "1" treats "0" as falsy → silently forces discount to 1. Use ?? "1" so "0" is respected.
Apply:
- discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
+ discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"),Run to find other occurrences project-wide:
Also applies to: 430-430, 487-487
🏁 Script executed:
#!/bin/bash
rg -nP 'ROUTEWAY_PAID_DISCOUNT\s*\|\|\s*["'\'']1["'\'']' -C2Length of output: 5073
Replace || "1" with ?? "1" for ROUTEWAY_PAID_DISCOUNT (preserve "0")
|| treats "0" as falsy; use ?? so parseFloat respects "0".
Files/locations:
- packages/models/src/models/openai.ts:373, 430, 487
- packages/models/src/models/deepseek.ts:62, 170
- packages/models/src/models/google.ts:28, 150, 186
- packages/models/src/models/anthropic.ts:53, 90, 173, 213, 254
Apply:
- discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
+ discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"), | |
| discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT ?? "1"), |
🤖 Prompt for AI Agents
In packages/models/src/models/openai.ts lines ~373, 430, 487 and
packages/models/src/models/deepseek.ts lines ~62, 170 and
packages/models/src/models/google.ts lines ~28, 150, 186 and
packages/models/src/models/anthropic.ts lines ~53, 90, 173, 213, 254, replace
usages of process.env.VAR || "1" (or similar) with the nullish coalescing
operator process.env.VAR ?? "1" so that legitimate values like "0" are preserved
before passing into parseFloat; update each occurrence to use ?? with the same
fallback string and keep existing parseFloat logic unchanged.
- Add environment variable check for concurrent test execution - Update response_format override to apply only to Claude models
Added `reasoningOutput: "omit"` property to multiple model configurations to enhance flexibility and align with reasoning constraints.
Added `stability: "unstable"` to Alibaba model configurations to indicate their current reliability status.
Summary
gpt-5,gpt-5-mini,gpt-5-nano,gemini-2.5-pro,gemini-2.5-flash,gemini-2.5-flash-lite, anddeepseek-reasoneranddeepseek-chatwith Routeway discount pricingChanges
Model Additions
Google Models: Added
gemini-2.5-pro,gemini-2.5-flash, andgemini-2.5-flash-liteunderrouteway-discountprovider with:ROUTEWAY_PAID_DISCOUNTenvironment variableOpenAI Models: Added
gpt-5,gpt-5-mini, andgpt-5-nanounderrouteway-discountprovider with:ROUTEWAY_PAID_DISCOUNTenvironment variableDeepseek Models: Added
deepseek-reasoneranddeepseek-chatunderrouteway-discountprovider with:deepseek-chatdeepseek-chatROUTEWAY_PAID_DISCOUNTenvironment variableTesting
packages/models/src/testing.tsto use relative importsTest plan
This update enables usage of advanced models with discounted pricing for Routeway users, enhancing model variety and cost efficiency.
🌿 Generated by Terry
ℹ️ Tag @terragon-labs to ask questions and address PR feedback
📎 Task: https://www.terragonlabs.com/task/05ea1955-8492-4aa9-9233-019ee45b1e50
Summary by CodeRabbit
New Features
Bug Fixes / Behavior Changes
Chores