Skip to content

Commit 629b92f

Browse files
committed
fix(gateway): treat :free suffix models as zero-cost for budget throttle
OpenRouter models with ':free' suffix (e.g. nvidia/nemotron-3-ultra-550b-a55b:free) were falling through to unknown-model defaults ($3/M input, $15/M output), causing the daily budget throttle to penalize free model usage. Now detected at both the pricing layer (getPricingSync) and fallback entry layer (fallbackEntry) and assigned $0 pricing.
1 parent 04a8eb1 commit 629b92f

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎packages/gateway/src/cost-tracker.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ type Pricing = {
571571
* Falls back to sensible defaults (same logic as sentry.ts getPricing).
572572
*/
573573
export function getPricingSync(model: string): Pricing {
574+
// OpenRouter `:free` suffix models cost nothing — don't inflate budget.
575+
if (model.endsWith(":free")) {
576+
return { input: 0, output: 0, cache_read: 0, cache_write: 0 };
577+
}
574578
const entry = getModelEntrySync(model);
575579
const input = entry.cost?.input ?? 3;
576580
return {

‎packages/gateway/src/worker-model.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ const FALLBACK_PRICING: Array<{
125125
];
126126

127127
function fallbackEntry(modelID: string): ModelsDevEntry {
128+
// OpenRouter `:free` suffix models cost nothing — don't inflate budget.
129+
if (modelID.endsWith(":free")) {
130+
return {
131+
id: modelID,
132+
cost: { input: 0, output: 0, cache_read: 0, cache_write: 0 },
133+
limit: { context: 200_000, output: 8_192 },
134+
};
135+
}
136+
128137
for (const fb of FALLBACK_PRICING) {
129138
if (modelID.startsWith(fb.prefix)) {
130139
return {

0 commit comments

Comments
 (0)