From de8e075842af934cbf33bd8aa51d5c95a833402c Mon Sep 17 00:00:00 2001 From: Tushar Pagar <240662211+tushardev-365@users.noreply.github.com> Date: Fri, 21 Aug 2026 10:37:58 +0000 Subject: [PATCH] fix: skip Vercel AI Gateway rows without token pricing in the price updater The weekly price update job has failed on every run since April with File ".../auto_update_price_and_context_window_file.py", line 91, in transform_vercel_ai_gateway_data KeyError: 'output' transform_vercel_ai_gateway_data indexes context_window, max_tokens, pricing["input"] and pricing["output"] on every row, but the gateway's /v1/models also lists embedding, image, video and audio models whose rows omit those fields. Against the live endpoint today, 108 of 350 rows have no pricing.output, 73 no pricing.input, and 16 no context_window at all, so the first such row kills the whole update and no price refresh has landed in months. Rows without token pricing cannot be expressed as cost-per-token entries, so they are now skipped, mirroring the guarded style the OpenRouter transform already uses for its optional fields. Verified against a snapshot of the live endpoint: before, KeyError on the first alibaba embedding row; after, 240 of 350 rows transform and the skipped rows are exactly the media and embedding models. --- ...auto_update_price_and_context_window_file.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/scripts/auto_update_price_and_context_window_file.py b/.github/scripts/auto_update_price_and_context_window_file.py index 461d8d347d9..edb7fd5f1bc 100644 --- a/.github/scripts/auto_update_price_and_context_window_file.py +++ b/.github/scripts/auto_update_price_and_context_window_file.py @@ -85,10 +85,23 @@ def transform_openrouter_data(data): def transform_vercel_ai_gateway_data(data): transformed = {} for row in data: + pricing = row.get("pricing") or {} + # Skip rows without token pricing or token limits. The gateway also + # lists embedding, image, video and audio models whose entries omit + # pricing.input/pricing.output or context_window entirely, and those + # cannot be expressed as cost-per-token entries. + if ( + row.get("context_window") is None + or row.get("max_tokens") is None + or pricing.get("input") is None + or pricing.get("output") is None + ): + continue + obj = { "max_tokens": row["context_window"], - "input_cost_per_token": float(row["pricing"]["input"]), - "output_cost_per_token": float(row["pricing"]["output"]), + "input_cost_per_token": float(pricing["input"]), + "output_cost_per_token": float(pricing["output"]), 'max_output_tokens': row['max_tokens'], 'max_input_tokens': row["context_window"], }