Skip to content

feat(models): add GPT-5 series, Gemini, and Deepseek models with Routeway discount - #925

Merged
steebchen merged 5 commits into
mainfrom
terragon/add-gpt5-mini-gemini25pro-routeway-discount
Sep 23, 2025
Merged

steebchen merged 5 commits into
mainfrom
terragon/add-gpt5-mini-gemini25pro-routeway-discount

Conversation

@steebchen

@steebchen steebchen commented Sep 23, 2025

Copy link
Copy Markdown
Member

Summary

  • Introduces new AI models gpt-5, gpt-5-mini, gpt-5-nano, gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, and deepseek-reasoner and deepseek-chat with Routeway discount pricing
  • Adds support for Routeway provider with discounted input/output pricing and extended context sizes
  • Updates model configurations in Google, OpenAI, and Deepseek model packages
  • Fixes import paths in testing utilities

Changes

Model Additions

  • Google Models: Added gemini-2.5-pro, gemini-2.5-flash, and gemini-2.5-flash-lite under routeway-discount provider with:

    • Input prices ranging from $0.10 to $1.25 per million tokens
    • Output prices ranging from $0.40 to $10.0 per million tokens
    • Context size: 1,000,000 tokens
    • Streaming, vision, and tools enabled
    • Discount configurable via ROUTEWAY_PAID_DISCOUNT environment variable
  • OpenAI Models: Added gpt-5, gpt-5-mini, and gpt-5-nano under routeway-discount provider with:

    • Input prices ranging from $0.05 to $1.25 per million tokens
    • Output prices ranging from $0.40 to $10.0 per million tokens
    • Cached input prices for some models
    • Context size: 400,000 tokens
    • Max output tokens: 128,000
    • Supports reasoning, streaming, vision, and tools
    • Supports parameters like temperature, top_p, frequency_penalty, presence_penalty, response_format, tools, and tool_choice
    • Discount configurable via ROUTEWAY_PAID_DISCOUNT environment variable
  • Deepseek Models: Added deepseek-reasoner and deepseek-chat under routeway-discount provider with:

    • Input prices around $0.55 per million tokens
    • Output prices around $1.68 to $2.19 per million tokens
    • Cached input price for deepseek-chat
    • Context sizes of 64,000 and 128,000 tokens
    • Streaming enabled; vision and tools enabled for deepseek-chat
    • Discount configurable via ROUTEWAY_PAID_DISCOUNT environment variable

Testing

  • Fixed import paths in packages/models/src/testing.ts to use relative imports

Test plan

  • Verify new models appear correctly in model listings
  • Confirm pricing and discount values are applied from environment variables
  • Test model capabilities including streaming, vision, and tool support
  • Run existing tests to ensure no regressions
  • Validate import path fixes in testing utilities

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

    • Added a configurable discounted provider option for multiple Gemini 2.5, GPT‑5 variants, DeepSeek models, and an Alibaba model stability flag; discounts are driven by an environment variable and retain streaming, vision, and tool support.
  • Bug Fixes / Behavior Changes

    • Response-format override for the discounted provider now applies only to Claude models (was previously unconditional).
  • Chores

    • Updated test import paths and made concurrent test runs controllable via an environment variable.

…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>
@bunnyshell

bunnyshell Bot commented Sep 23, 2025

Copy link
Copy Markdown

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@coderabbitai

coderabbitai Bot commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds routeway-discount provider entries (pricing and discount from ROUTEWAY_PAID_DISCOUNT) to Google Gemini, OpenAI GPT‑5 variants, and DeepSeek model definitions; updates a testing import path and concurrent flag; and narrows a routeway-discount branch in request-body preparation so response_format override (json_object → json) only applies for models starting with "claude-".

Changes

Cohort / File(s) Summary
Providers: routeway-discount — Google models
packages/models/src/models/google.ts
Added routeway-discount provider entries for gemini-2.5-pro, gemini-2.5-flash, and gemini-2.5-flash-lite with input/output/(cached) prices, contextSize, streaming/vision/tools flags, requestPrice, and discount parsed from process.env.ROUTEWAY_PAID_DISCOUNT.
Providers: routeway-discount — OpenAI GPT‑5 models
packages/models/src/models/openai.ts
Added routeway-discount provider entries for gpt-5, gpt-5-mini, and gpt-5-nano (and mirrored variants) including pricing, cachedInputPrice where applicable, supportedParameters, requestPrice/contextSize/maxOutput, and discount from process.env.ROUTEWAY_PAID_DISCOUNT.
Providers: routeway-discount — DeepSeek models
packages/models/src/models/deepseek.ts
Added routeway-discount provider entries to deepseek-r1, deepseek-v3.1, and deepseek-r1-0528 with input/output/(cached) prices, contextSize, streaming/vision/tools flags, requestPrice, and discount parsed from process.env.ROUTEWAY_PAID_DISCOUNT.
Request preparation: response_format guard
packages/models/src/prepare-request-body.ts
Tightened routeway-discount branch: when response_format.type === "json_object", override to "json" only if usedModel.startsWith("claude-"); previously the override applied unconditionally for json_object.
Testing import path & concurrency
packages/models/src/testing.ts
Changed imports from alias to relative (@/models.js./models.js) and derive concurrent from process.env.CONCURRENT_TESTS (truthy unless "false"); no other logic changes.
Provider metadata field addition — Alibaba
packages/models/src/models/alibaba.ts
Added stability: "unstable" field to the provider object for qwen3-235b-a22b-thinking-2507.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • smakosh

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change: adding GPT-5 series, Gemini, and Deepseek models along with Routeway discount pricing; it is concise, specific, and directly related to the modifications in model definitions and pricing. It is clear enough for a teammate scanning history to understand the main change without extraneous details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch terragon/add-gpt5-mini-gemini25pro-routeway-discount

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf2bf6e and b1b23ff.

📒 Files selected for processing (1)
  • packages/models/src/models/alibaba.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/alibaba.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Never use any or as any in this TypeScript project unless absolutely necessary
Always use top-level import; never use require or dynamic imports

Files:

  • packages/models/src/models/alibaba.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: test / run
  • GitHub Check: build / run
  • GitHub Check: lint / run
  • GitHub Check: generate / run
  • GitHub Check: e2e-shards (5)
  • GitHub Check: e2e-shards (3)
  • GitHub Check: e2e-shards (4)
  • GitHub Check: e2e-shards (2)
  • GitHub Check: e2e-shards (1)
  • GitHub Check: autofix
🔇 Additional comments (1)
packages/models/src/models/alibaba.ts (1)

267-267: No change required — provider stability is typed. ProviderModelMapping declares stability?: StabilityLevel and ModelDefinition also has stability?: StabilityLevel (packages/models/src/models.ts), so stability: "unstable" on a provider is valid.


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.

❤️ Share

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

@github-actions github-actions Bot changed the title Add GPT-5 Mini and Gemini 2.5 Pro Models with Routeway Discount feat(models): add GPT-5 & Gemini Sep 23, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 discount field (or update the type) to avoid TypeScript errors.
packages/models/src/models/google.ts (1)

23-35: Types already include discount; validate ROUTEWAY_PAID_DISCOUNT parsing across models.

  • No type change required: ProviderModelMapping / ModelDefinition already declare discount?: 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 to 1; 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

📥 Commits

Reviewing files that changed from the base of the PR and between de7d082 and d7d8c30.

📒 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.ts
  • packages/models/src/models/google.ts
  • packages/models/src/testing.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Never use any or as any in this TypeScript project unless absolutely necessary
Always use top-level import; never use require or dynamic imports

Files:

  • packages/models/src/models/openai.ts
  • packages/models/src/models/google.ts
  • packages/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 output

packages/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>
@steebchen steebchen changed the title feat(models): add GPT-5 & Gemini feat(models): add GPT-5 series, Gemini, and Deepseek models with Routeway discount Sep 23, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_DISCOUNT in providers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7d8c30 and ebbafac.

📒 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.ts
  • packages/models/src/models/deepseek.ts
  • packages/models/src/models/openai.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Never use any or as any in this TypeScript project unless absolutely necessary
Always use top-level import; never use require or dynamic imports

Files:

  • packages/models/src/models/google.ts
  • packages/models/src/models/deepseek.ts
  • packages/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"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 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["'\'']' -C2

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

Suggested change
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.
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