Skip to content

fix(actions): handle missing gateway pricing fields - #40057

Closed
Jetemple wants to merge 1 commit into
BerriAI:mainfrom
Jetemple:fix/auto-update-price-workflow
Closed

Jetemple wants to merge 1 commit into
BerriAI:mainfrom
Jetemple:fix/auto-update-price-workflow

Conversation

@Jetemple

@Jetemple Jetemple commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Importer crashes on Vercel models with no output price
  • 117 of 373 live gateway models hit this today
  • The weekly price-refresh job has been failing

How it solves it:

  • Treat pricing and token limits as optional fields
  • Omit them when the gateway sends null/nothing
  • Existing local values survive, they are not overwritten

User Flow

Before: nobody can refresh Vercel AI Gateway prices, so the shipped price list stays stale

  1. A maintainer runs the price refresh against https://ai-gateway.vercel.sh/v1/models
  2. The run dies with KeyError: 'output' on the first embedding model
  3. No prices are written, so users pricing Vercel models keep the old numbers

After: the refresh completes and writes prices for every model the gateway lists

  1. A maintainer runs the same refresh against the same URL
  2. All 373 models are processed, including embedding and video models with partial pricing
  3. Models with no published output price simply carry no output price, instead of blocking the run

Relevant issues

No issue filed. The evidence is in this repo's own Actions history: the scheduled
auto_update_price_and_context_window workflow is failing on this line.

File ".github/scripts/auto_update_price_and_context_window_file.py", line 91, in transform_vercel_ai_gateway_data
    "output_cost_per_token": float(row["pricing"]["output"]),
KeyError: 'output'

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 (5/5 on a4727400)

Screenshots / Proof of Fix

Shared setup:

curl -sS https://ai-gateway.vercel.sh/v1/models -o /tmp/vercel_models.json   # HTTP 200, 373 models

Both runs call transform_vercel_ai_gateway_data on that live payload.

Before (02522a5)

  1. Run the importer transform over the live payload
  2. Observed: CRASH: KeyError: 'output' — 117 of 373 live models are missing a field the code required

After (a472740)

  1. Run the same transform over the same live payload
  2. Observed: OK: transformed 373 models
  3. Regression tests: uv run --frozen pytest tests/test_litellm/test_auto_update_price_and_context_window.py tests/test_litellm/test_model_prices_schema.py -q -> 23 passed

Type

🐛 Bug Fix

Caveats (if any)

Low

  • Models reporting context_window: 0 keep max_tokens: 0
  • Schema allows it; 15 committed entries already do this

@Jetemple
Jetemple requested a review from a team September 6, 2026 14:14
@greptile-apps

greptile-apps Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the Vercel AI Gateway pricing importer tolerate missing or null pricing and token-limit fields while preserving existing local values for omitted fields.

  • Builds transformed records only from optional fields supplied by the gateway.
  • Reuses normalized pricing data for input, output, and cache pricing.
  • Adds regression coverage for partial payloads and merge preservation behavior.
  • Removes the redundant comments identified in the previous review.

Confidence Score: 5/5

The PR appears safe to merge; the earlier findings are resolved and no new actionable issue was identified.

The workflow changes associated with the first previous finding are absent, regression tests now cover the optional-field behavior and merged registry values, and the two redundant source comments were removed without changing behavior.

Important Files Changed

Filename Overview
.github/scripts/auto_update_price_and_context_window_file.py Safely omits unavailable Vercel pricing and token-limit values, with the previously flagged redundant comments removed.
tests/test_litellm/test_auto_update_price_and_context_window.py Adds focused offline tests for missing and null gateway fields and preservation of existing local values.

Reviews (3): Last reviewed commit: "fix: skip missing Vercel AI Gateway pric..." | Re-trigger Greptile

@veria-ai

veria-ai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@Jetemple
Jetemple force-pushed the fix/auto-update-price-workflow branch from 6282f5e to 83ac0d7 Compare September 6, 2026 15:22
@Jetemple

Jetemple commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai

The Vercel AI Gateway model list does not publish pricing or token
limits for every model. Embedding models omit the output price, and
video models omit pricing entirely, so the importer raised
KeyError: 'output' and the price refresh never completed.

Treat pricing, input, output, context_window and max_tokens as
optional and omit them from the transformed record when they are
missing or null. The model id stays required. Because the sync step
merges with dict.update, omitting a field now preserves whatever
value the local price file already holds instead of overwriting it.

On the live gateway list, 117 of 373 models are missing at least one
of these fields.
@Jetemple
Jetemple force-pushed the fix/auto-update-price-workflow branch from 83ac0d7 to a472740 Compare September 6, 2026 15:31
@Jetemple

Jetemple commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yuneng-berri
yuneng-berri deleted the branch BerriAI:main September 13, 2026 04:50
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@devin-ai-integration
devin-ai-integration Bot changed the base branch from litellm_internal_staging to main September 23, 2026 14:41
@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mateo-berri

Copy link
Copy Markdown
Contributor

#48473 removed the weekly cost map sync workflow and the script this PR patches, so this fix no longer applies. Reopen if something is missing

@mateo-berri mateo-berri closed this Nov 9, 2026
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.

4 participants