From 17050cdf06f4ca76d312341ce47ef99a6dd919c7 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 7 Jun 2026 01:03:33 +0000 Subject: [PATCH] fix(ci): skip Vercel AI Gateway models without input pricing The Vercel AI Gateway models endpoint now returns video, image, and reranking model entries that lack the standard input/output token pricing keys (some embedding entries also omit the output key). The auto_update workflow blew up with a KeyError on row['pricing']['output'] the first time it hit one of those rows. Skip rows that don't expose an input price, default the output price to zero when only input is provided (covers embedding models), and read pricing once into a local to drop the redundant 'pricing in row' guard. Co-authored-by: Krrish Dholakia --- ...to_update_price_and_context_window_file.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/auto_update_price_and_context_window_file.py b/.github/workflows/auto_update_price_and_context_window_file.py index 461d8d347d9..9feb70981d3 100644 --- a/.github/workflows/auto_update_price_and_context_window_file.py +++ b/.github/workflows/auto_update_price_and_context_window_file.py @@ -85,21 +85,24 @@ def transform_openrouter_data(data): def transform_vercel_ai_gateway_data(data): transformed = {} for row in data: + pricing = row.get("pricing") or {} + if "input" not in pricing: + 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.get("output", 0.0)), 'max_output_tokens': row['max_tokens'], 'max_input_tokens': row["context_window"], } # Handle cache pricing if available - if "pricing" in row: - if "input_cache_read" in row["pricing"] and row["pricing"]["input_cache_read"] is not None: - obj['cache_read_input_token_cost'] = float(f"{float(row['pricing']['input_cache_read']):e}") - - if "input_cache_write" in row["pricing"] and row["pricing"]["input_cache_write"] is not None: - obj['cache_creation_input_token_cost'] = float(f"{float(row['pricing']['input_cache_write']):e}") + if "input_cache_read" in pricing and pricing["input_cache_read"] is not None: + obj['cache_read_input_token_cost'] = float(f"{float(pricing['input_cache_read']):e}") + + if "input_cache_write" in pricing and pricing["input_cache_write"] is not None: + obj['cache_creation_input_token_cost'] = float(f"{float(pricing['input_cache_write']):e}") mode = "embedding" if "embedding" in row["id"].lower() else "chat"