Skip to content

fix(actions): pricing auto update action - #33073

Closed
oskarkocol wants to merge 16 commits into
BerriAI:mainfrom
oskarkocol:fix/auto-update-action
Closed

oskarkocol wants to merge 16 commits into
BerriAI:mainfrom
oskarkocol:fix/auto-update-action

Conversation

@oskarkocol

@oskarkocol oskarkocol commented Jul 13, 2026 •

Copy link
Copy Markdown

Relevant issues

This PR brings back to life the automated refresh for Vercel AI gateway and OpenRouter gateway.

Fixes:

Context

This action refreshes models and their prices from OpenRouter and Vercel AI SDK: https://github.com/BerriAI/litellm/blob/litellm_internal_staging/.github/workflows/auto_update_price_and_context_window.yml

However, it was failing silently. Example of a failed run: https://github.com/BerriAI/litellm/actions/runs/29173737985/job/86599055076

I reproduced the error on my fork:

Traceback (most recent call last):
  File "/workspaces/litellm-contrib/.github/workflows/auto_update_price_and_context_window_file.py", line 159, in <module>
    main()
  File "/workspaces/litellm-contrib/.github/workflows/auto_update_price_and_context_window_file.py", line 145, in main
    vercel_data = transform_vercel_ai_gateway_data(vercel_data)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/litellm-contrib/.github/workflows/auto_update_price_and_context_window_file.py", line 91, in transform_vercel_ai_gateway_data

The reason is that it fails for models that have no output pricing. For example, alibaba/qwen3-embedding-0.6b only has input pricing. Missing pricing.output (embeddings, video models) makes float(row["pricing"]["output"]) throw.

Screenshot from Vercel AI gateway of a model that has no output pricing:
image

Works on the fork: https://github.com/oskarkocol/litellm-contrib/actions/runs/29249385824/job/86813935404

Note: I followed the repo convention of using ${{ secrets.GITHUB_TOKEN }} If you see an error like “GitHub Actions is not permitted to create or approve pull requests (createPullRequest)” due to repo permissions, use a PAT stored as custom secret, like ${{ secrets.GH_TOKEN }}

Follow-up PRs (stacked)

This PR fixes the workflow only. Provider additions are split out and stacked on this branch:

  • Novita pricing source: BerriAI/litellm#XXXX (base: fix/auto-update-action). Draft PR.
  • Cerebras via Narev: BerriAI/litellm#YYYY (base: Novita PR branch). Draft PR

Please merge this PR first; the follow-ups will be retargeted to litellm_internal_staging after it lands.

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • 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 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Type

🐛 Bug Fix
✅ Test

Changes

QA runbook

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@oskarkocol

Copy link
Copy Markdown
Author

@greptileai

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silently-failing weekly workflow that auto-updates model_prices_and_context_window.json with fresh pricing from OpenRouter and Vercel AI Gateway. The root cause was an unconditional float(row["pricing"]["output"]) call that crashed for embedding/video models that carry no output price.

  • Python script: transform_vercel_ai_gateway_data now guards every field access (context_window, pricing.input, pricing.output, max_tokens) with existence and non-null checks before writing to the output object.
  • Workflow: git config, branch creation, script invocation, commit, push, and gh pr create are now in a single correctly-ordered step; gh pr create is gated behind the commit/push path; BASE_BRANCH gains a || github.ref_name fallback; the BerriAI/litellm repository guard is restored; GITHUB_TOKEN replaces the custom GH_TOKEN secret.

Confidence Score: 5/5

Safe to merge — the change is confined to a scheduled maintenance workflow and its helper script, with no impact on the production request path.

Both changed files are part of an offline maintenance workflow. The Python fix is minimal and targeted: it converts hard field accesses into guarded lookups, directly matching the crash shown in the error trace. The workflow restructuring follows standard GitHub Actions patterns, restores the repository guard that was removed for testing, and correctly gates PR creation behind a successful push. No production code, SDK surface, or database logic is touched.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/auto_update_price_and_context_window_file.py Core bug fix: made pricing and context_window fields optional in transform_vercel_ai_gateway_data to handle embedding/video models that lack output pricing; whitespace-only cleanup elsewhere.
.github/workflows/auto_update_price_and_context_window.yml Workflow restructured: git config, branching, script run, and PR creation consolidated into one step with correct conditional guards; BASE_BRANCH fallback added; repo guard restored; GITHUB_TOKEN used instead of GH_TOKEN secret.

Reviews (3): Last reviewed commit: "revert repo guard" | Re-trigger Greptile

@oskarkocol oskarkocol changed the title fix: pricing auto update action fix(actions): pricing auto update action Jul 13, 2026
@oskarkocol

Copy link
Copy Markdown
Author

@greptileai

@codspeed

codspeed Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing oskarkocol:fix/auto-update-action (e5fea47) with litellm_internal_staging (c2141b1)

Open in CodSpeed

@oskarkocol
oskarkocol marked this pull request as ready for review July 13, 2026 14:36
@oskarkocol
oskarkocol requested a review from a team July 13, 2026 14:36
@yuneng-berri
yuneng-berri deleted the branch BerriAI:main September 13, 2026 04:30
@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 15:43
@mateo-berri

Copy link
Copy Markdown
Contributor

Thanks for finding the Vercel crash first. Closing, since #48473 removed this workflow and its script from main

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.

3 participants