Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/models/src/models/alibaba.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export const alibabaModels = [
streaming: true,
vision: false,
tools: true,
stability: "unstable",
},
],
jsonOutput: true,
Expand Down
27 changes: 27 additions & 0 deletions packages/models/src/models/deepseek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ export const deepseekModels = [
vision: false,
tools: false,
},
{
providerId: "routeway-discount",
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.

requestPrice: 0,
contextSize: 64000,
maxOutput: undefined,
streaming: true,
vision: false,
tools: false,
},
],
jsonOutput: false,
},
Expand Down Expand Up @@ -148,6 +161,20 @@ export const deepseekModels = [
vision: true,
tools: true,
},
{
providerId: "routeway-discount",
modelName: "deepseek-chat",
inputPrice: 0.56 / 1e6,
outputPrice: 1.68 / 1e6,
cachedInputPrice: 0.07 / 1e6,
discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
requestPrice: 0,
contextSize: 128000,
maxOutput: undefined,
streaming: true,
vision: true,
tools: true,
},
],
jsonOutput: false,
},
Expand Down
41 changes: 41 additions & 0 deletions packages/models/src/models/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ export const googleModels = [
vision: true,
tools: true,
},
{
providerId: "routeway-discount",
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.

requestPrice: 0,
contextSize: 1000000,
maxOutput: undefined,
streaming: true,
vision: true,
tools: true,
},
],
},
{
Expand Down Expand Up @@ -128,6 +141,20 @@ export const googleModels = [
vision: true,
tools: true,
},
{
providerId: "routeway-discount",
modelName: "gemini-2.5-flash",
inputPrice: 0.3 / 1e6,
outputPrice: 2.5 / 1e6,
cachedInputPrice: 0.075 / 1e6,
discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
requestPrice: 0,
contextSize: 1000000,
maxOutput: undefined,
streaming: true,
vision: true,
tools: true,
},
],
},
{
Expand All @@ -150,6 +177,20 @@ export const googleModels = [
vision: true,
tools: true,
},
{
providerId: "routeway-discount",
modelName: "gemini-2.5-flash-lite",
inputPrice: 0.1 / 1e6,
outputPrice: 0.4 / 1e6,
cachedInputPrice: 0.025 / 1e6,
discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
requestPrice: 0,
contextSize: 1000000,
maxOutput: undefined,
streaming: true,
vision: true,
tools: true,
},
],
},
{
Expand Down
75 changes: 75 additions & 0 deletions packages/models/src/models/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,31 @@ export const openaiModels = [
"tool_choice",
],
},
{
providerId: "routeway-discount",
modelName: "gpt-5",
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.

requestPrice: 0,
contextSize: 400000,
maxOutput: 128000,
reasoning: true,
reasoningOutput: "omit",
streaming: true,
vision: true,
tools: true,
supportedParameters: [
"temperature",
"top_p",
"frequency_penalty",
"presence_penalty",
"response_format",
"tools",
"tool_choice",
],
},
],
jsonOutput: true,
},
Expand Down Expand Up @@ -397,6 +422,31 @@ export const openaiModels = [
"tool_choice",
],
},
{
providerId: "routeway-discount",
modelName: "gpt-5-mini",
inputPrice: 0.25 / 1e6,
outputPrice: 2 / 1e6,
cachedInputPrice: 0.025 / 1e6,
discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
requestPrice: 0,
contextSize: 400000,
maxOutput: 128000,
reasoning: true,
reasoningOutput: "omit",
streaming: true,
vision: true,
tools: true,
supportedParameters: [
"temperature",
"top_p",
"frequency_penalty",
"presence_penalty",
"response_format",
"tools",
"tool_choice",
],
},
],
jsonOutput: true,
},
Expand Down Expand Up @@ -430,6 +480,31 @@ export const openaiModels = [
"tool_choice",
],
},
{
providerId: "routeway-discount",
modelName: "gpt-5-nano",
inputPrice: 0.05 / 1e6,
outputPrice: 0.4 / 1e6,
cachedInputPrice: 0.005 / 1e6,
discount: parseFloat(process.env.ROUTEWAY_PAID_DISCOUNT || "1"),
requestPrice: 0,
contextSize: 400000,
maxOutput: 128000,
reasoning: true,
reasoningOutput: "omit",
streaming: true,
vision: false,
tools: true,
supportedParameters: [
"temperature",
"top_p",
"frequency_penalty",
"presence_penalty",
"response_format",
"tools",
"tool_choice",
],
},
],
jsonOutput: true,
},
Expand Down
7 changes: 5 additions & 2 deletions packages/models/src/prepare-request-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ export async function prepareRequestBody(
};
}
if (response_format) {
// Override json_object to json for routeway-discount
if (response_format.type === "json_object") {
// Override json_object to json for routeway-discount only for claude models
if (
response_format.type === "json_object" &&
usedModel.startsWith("claude-")
) {
requestBody.response_format = {
...response_format,
type: "json",
Expand Down
9 changes: 6 additions & 3 deletions packages/models/src/testing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { models } from "@/models.js";
import { models } from "./models.js";

import type { ProviderModelMapping } from "@/models.js";
import type { ProviderModelMapping } from "./models.js";
import type { TestOptions } from "vitest";

/**
Expand Down Expand Up @@ -28,5 +28,8 @@ export function getTestOptions(
export function getConcurrentTestOptions(opts?: {
completions?: boolean;
}): TestOptions {
return { concurrent: true, ...getTestOptions(opts) };
return {
concurrent: process.env.CONCURRENT_TESTS !== "false",
...getTestOptions(opts),
};
}
Loading