Skip to content

fix(cost): bill the fast service tier at the priority rate - #35320

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_gpt56_fast_service_tier
Jul 31, 2026
Merged

fix(cost): bill the fast service tier at the priority rate#35320
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_gpt56_fast_service_tier

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • service_tier: "fast" is billed at standard rates
  • OpenAI charges 2x for it
  • We undercount spend by half on those requests

How it solves it:

  • Add fast to the ServiceTier enum
  • Resolve it to the existing _priority cost keys
  • Regression tests over the base and above-threshold paths

Relevant issues

Linear ticket

Resolves LIT-5011

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

Real gpt-5.6-sol calls against a local proxy hitting the OpenAI API. Config used:

model_list:
  - model_name: gpt-5.6-sol
    litellm_params:
      model: openai/gpt-5.6-sol
      api_key: os.environ/OPENAI_API_KEY

general_settings:
  master_key: sk-1234

Steps, run once on the base commit and once on this branch:

  1. LITELLM_LOCAL_MODEL_COST_MAP=True uv run --no-sync python litellm/proxy/proxy_cli.py --config proof_config.yaml
  2. send the same prompt three times, as Fast mode, as Priority, and with no tier, reading the billed cost off the response headers
for tier in '"service_tier":"fast",' '"service_tier":"priority",' ''; do
  curl -s -D - -o /tmp/body.json http://localhost:4000/v1/chat/completions \
    -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" \
    -d "{\"model\":\"gpt-5.6-sol\",${tier}\"messages\":[{\"role\":\"user\",\"content\":\"reply with the single word: ok\"}],\"max_completion_tokens\":16}" \
    | grep -i "^x-litellm-response-cost:"
done

Every run below is 13 prompt / 4 completion tokens

Before, at bf1a8fe403 (base):

== service_tier=fast       (OpenAI echoed back service_tier: priority)
x-litellm-response-cost: 0.000185
== service_tier=priority
x-litellm-response-cost: 0.00037
== no service_tier         (OpenAI echoed back service_tier: default)
x-litellm-response-cost: 0.000185

The Fast mode request costs OpenAI's priority rate but is billed identically to the untiered one

After, at 18b9e90d12 (this branch):

== service_tier=fast       (OpenAI echoed back service_tier: priority)
x-litellm-response-cost: 0.00037
== service_tier=priority
x-litellm-response-cost: 0.00037
== no service_tier         (OpenAI echoed back service_tier: default)
x-litellm-response-cost: 0.000185

Fast now matches Priority at 2x, and untiered requests are untouched. Worth noting that OpenAI reports service_tier: "priority" on the Fast mode response, which is the same aliasing this PR applies on the cost side

Type

🐛 Bug Fix

Changes

The GPT-5.6 announcement replaced Priority Processing with Fast mode, which is a new service_tier value that bills at twice the standard rate. service_tier is already an allowed param on the OpenAI and Responses paths and is forwarded as an opaque string, so requests work today; only the cost side is wrong. _get_service_tier_cost_key recognized just flex and priority and returned the base key for anything else, so a Fast mode request resolved input_cost_per_token instead of input_cost_per_token_priority and landed in SpendLogs at half its real cost, silently

The tier-to-suffix decision moves out of the if chain and into a lookup, which is where the aliasing belongs:

_SERVICE_TIER_TO_COST_KEY_SUFFIX = {
    "flex": "flex",
    "priority": "priority",
    "fast": "priority",
}

suffix = _SERVICE_TIER_TO_COST_KEY_SUFFIX.get(service_tier.lower())
return base_key if suffix is None else f"{base_key}_{suffix}"

Fast and Priority share one set of *_priority cost keys rather than getting a duplicated *_fast set across every model. OpenAI kept service_tier: "priority" working as an alias for Fast mode and prices them the same, so duplicating the keys would mean two numbers to keep in sync per model per tier with no way for them to legitimately differ

Unknown tiers still fall back to standard pricing, and auto is still normalized away upstream in _normalize_service_tier, so nothing else changes. The above-threshold branch resolves its cost keys through the same helper, so it picks up Fast mode too; a test covers that path separately since it is easy to regress independently

The price cuts themselves landed separately in #35270

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

Link to Devin session: https://app.devin.ai/sessions/bdd531a0c9ce49679c29fa6a3d40fb27

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates service-tier cost resolution so Fast mode uses existing Priority pricing.

  • Adds fast to the ServiceTier enum.
  • Aliases fast to the _priority pricing-key suffix.
  • Adds regression coverage for standard, case-insensitive, cached-token, and above-threshold calculations.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
litellm/litellm_core_utils/llm_cost_calc/utils.py Adds an immutable service-tier suffix mapping and resolves Fast mode to existing Priority cost keys.
litellm/types/utils.py Extends the service-tier enum with the new Fast value.
tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py Adds focused regression tests confirming Fast and Priority pricing match across relevant calculation paths.

Reviews (2): Last reviewed commit: "fix(cost): bill the fast service tier at..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_gpt56_fast_service_tier (18b9e90) with litellm_internal_staging (81ff7cb)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (18b9e90) during the generation of this report, so 81ff7cb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the litellm_gpt56_fast_service_tier branch from 7b10784 to 18b9e90 Compare July 31, 2026 04:49
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@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. Thanks!

@mateo-berri
mateo-berri merged commit 6354182 into litellm_internal_staging Jul 31, 2026
77 checks passed
@mateo-berri
mateo-berri deleted the litellm_gpt56_fast_service_tier branch July 31, 2026 05:10
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.

2 participants