Skip to content

test(decisions): bill the OpenAI-format openrouter case from provider-reported cost - #45853

Merged
mateo-berri merged 1 commit into
mainfrom
litellm_circleci_heal_openrouter_decisions_cost
Oct 10, 2026
Merged

mateo-berri merged 1 commit into
mainfrom
litellm_circleci_heal_openrouter_decisions_cost

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • CircleCI integration-providers is red on main in every scheduled run
  • The OpenAI-format decisions wire test still reads a deleted cost-map row

How it solves it:

User Flow

Before: a maintainer reading the scheduled CircleCI run on main sees integration-providers red with a KeyError

  1. They open the scheduled integration workflow, for example pipeline 91107 or pipeline 91085
  2. test_decisions_openai_format_wire.py::test_each_provider_gets_its_own_path_key_and_body_and_is_billed_from_the_cost_map[openrouter] fails with KeyError: 'openrouter/typesafe/jev-1.13'

After: the same job runs the openrouter case against the billing OpenRouter actually uses and it passes

  1. They open the integration workflow triggered on this branch, linked under Proof of Fix
  2. test_each_provider_gets_its_own_path_key_and_body_and_is_billed[openrouter] passes and asserts the spend equals the reported usage.cost

Pre-Submission checklist

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

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • 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

The culprit is ed22fd9 from #45667, which removed 139 openrouter/* rows from the cost map, openrouter/typesafe/jev-1.13 among them. #45640 had already moved OpenRouter decisions billing to the provider-reported usage.cost and updated test_decisions_wire.py, but the OpenAI-format sibling kept cost_map_key="openrouter/typesafe/jev-1.13", so _expected_spend raised KeyError before the request was even sent

The fix gives the OpenAI-format _Provider a provider_reported_cost, has the fake upstream return it in usage.cost, and asserts the gateway bills exactly that amount. The client-facing response shape is unchanged. Mutation check: reading a nonexistent usage key in OpenRouterDecisionsConfig.provider_reported_cost makes the test fail with isclose(0.0, 1.5834e-05)

This is a test-only change, so the proof is CircleCI on this branch, triggered manually since CircleCI does not run on PRs. Pipeline 91128 at 30c4f8f is running

Type

✅ Test

Caveats (if any)

Medium

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
  • 30c4f8f passes /live-pr-risk

Link to Devin session: https://app.devin.ai/sessions/5076c6a4aaa74a2e88f5402c2b54b8c2
Open in Devin Desktop: https://app.devin.ai/desktop/session/5076c6a4aaa74a2e88f5402c2b54b8c2?variant=devin


Note

Low Risk
Test-only change to integration expectations; no production billing or gateway logic modified.

Overview
Fixes failing OpenAI-format decisions integration billing for OpenRouter after openrouter/* rows were removed from the cost map.

The wire test’s _Provider helper now supports provider_reported_cost: mocked upstream usage can include cost, and _expected_spend prefers that value over the cost-map lookup. The OpenRouter case sets cost_map_key to None, uses provider_reported_cost=1.5834e-5, and the parametrized billing test asserts gateway spend matches that reported cost—matching test_decisions_wire.py.

Reviewed by Cursor Bugbot for commit 30c4f8f. Bugbot is set up for automated code reviews on this repo. Configure here.

…-reported cost

PR #45667 removed openrouter/typesafe/jev-1.13 from the cost map after #45640 moved OpenRouter decisions billing to usage.cost. The OpenAI-format wire test still read the removed row and raised KeyError on CircleCI integration-providers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge.

Summary

Updates the OpenAI-format decisions test to bill the OpenRouter case from provider-reported usage.cost.

  • The OpenRouter Decisions test bills its case from the reported cost.

Reviews (1) · Last reviewed commit: "test(decisions): bill the OpenAI-format ..." · Reviewed by Greptile

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 30c4f8f. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit 5894968 into main Oct 10, 2026
140 of 144 checks passed
@mateo-berri
mateo-berri deleted the litellm_circleci_heal_openrouter_decisions_cost branch October 10, 2026 21:47
DeoLeung pushed a commit to aiyou178/litellm that referenced this pull request Oct 11, 2026
…-reported cost (BerriAI#45853)

PR BerriAI#45667 removed openrouter/typesafe/jev-1.13 from the cost map after BerriAI#45640 moved OpenRouter decisions billing to usage.cost. The OpenAI-format wire test still read the removed row and raised KeyError on CircleCI integration-providers

Co-authored-by: mateo <mateo@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 5894968)
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.

1 participant