Repository navigation
Commit 8cb2532
fix(codex): price recorded Ultrafast requests at Ultrafast rates (#1989)
* fix(codex): price recorded Ultrafast requests at Ultrafast rates
Codex rollouts can record `service_tier: "ultrafast"` in
`thread_settings_applied` events, but ccusage left that value
unclassified, so with a Standard config fallback those requests were
priced at Standard rates.
Recognize the recorded tier and track it in its own usage bucket, so the
tier stays per request: when a thread switches back to Standard, earlier
requests keep their Ultrafast pricing and token totals are unchanged.
Ultrafast rates come from OpenAI's API pricing table, which publishes
them for GPT-6.1 Sol and GPT-6 Astra only, at exactly 6x Standard for
every input, cached input, cache write and output rate, short and long
context. The embedded models.dev snapshot's GPT-6.1 Sol Ultrafast entry
agrees. Models without a published Ultrafast rate keep Standard pricing.
Fixes #1987
Co-authored-by: Razvan Aurariu <[email protected]>
* fix(codex): keep Ultrafast through tier merges and model aliases
When copied records disagree, prefer Ultrafast over Fast and Flex so a
duplicate does not drop its 6x pricing; Standard still wins any conflict.
Resolve the Ultrafast multiplier through the same model identity that
Standard pricing uses (model aliases and `.`/`@` separator variants), so
a recorded `gpt-6-1-sol` gets the published `gpt-6.1-sol` rate instead
of falling back to Standard.
Document the `ultrafast` service-tier mapping in the adapter README.
Co-authored-by: Razvan Aurariu <[email protected]>
* fix(pricing): resolve the Ultrafast multiplier with the Standard entry
The Ultrafast multiplier was looked up from the recorded model name
separately from the Standard rates, so the two could disagree. Provider
spellings such as `openai@gpt-6-1-sol` fell back to Standard, and a model
aliased to Sol while an exact entry of its own existed (e.g. `gpt-6.1-terra`)
was billed Terra rates at Sol's 6x.
Store the published Ultrafast multiplier on each `Pricing` entry, as Fast
and Flex already are, so one `PricingMap::find`/`find_at` resolution
supplies both the Standard rates and the multiplier.
Co-authored-by: Razvan Aurariu <[email protected]>
* fix(pricing): keep the Ultrafast multiplier for user price overrides
Resolve an override's base entry through model aliases, and derive the
published Ultrafast multiplier from the override name when no base
exists. Load the Ultrafast allowlist alongside the Fast and Flex ones in
every loader, including built-in entries, instead of a lazy global.
Co-authored-by: Razvan Aurariu <[email protected]>
* test(codex): cover Ultrafast across speed policies and duplicate merges
Add Ultrafast to the rollout tier table, including forced Standard and
Fast overriding recorded Ultrafast usage, and to duplicate-compaction
tier merging. Pin that a configured ultrafast tier is not used for
unclassified usage, and document that Ultrafast only comes from
recorded rollout tiers.
Co-authored-by: Razvan Aurariu <[email protected]>
* fix(pricing): resolve published speed multipliers for unmatched overrides
When a price override has no base entry, take the published Fast, Flex
and Ultrafast multipliers for the override name or its alias target,
so an alias to a dated Sol name keeps Ultrafast pricing. Document the
alias base and the published multiplier defaults.
Co-authored-by: Razvan Aurariu <[email protected]>
* test(codex): assert duplicate copies land in exactly one tier bucket
Co-authored-by: Razvan Aurariu <[email protected]>
* fix(pricing): apply target overrides before aliases built from them
Pricing overrides arrive in key order, so an alias key sorting before
its overridden target was built from the target's pre-override entry.
Order overrides by alias dependency depth, which keeps key order for
independent entries and cycles. Test the alias-to-dated-target
multiplier fallback with only the alias overridden.
Co-authored-by: Razvan Aurariu <[email protected]>
* docs(config): note that the Ultrafast multiplier cannot be overridden
Co-authored-by: Razvan Aurariu <[email protected]>
* fix(pricing): order aliases into override cycles after the cycle
A capped dependency depth let an alias pointing into an alias cycle tie
with the cycle and apply before it. Walk each override's alias chain,
detect a revisited key, and sort looping chains after acyclic ones by
the links leading into the loop. Restore the pricing_alias doc comment
to its function.
Co-authored-by: Razvan Aurariu <[email protected]>
---------
Co-authored-by: Razvan Aurariu <[email protected]>1 parent 71e022a commit 8cb2532
15 files changed
Lines changed: 647 additions & 77 deletions
File tree
- docs/guide
- codex
- nix
- rust
- adapters/codex/src
- crates
- ccusage-core/src
- ccusage/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
446 | 447 | | |
447 | 448 | | |
448 | 449 | | |
449 | | - | |
| 450 | + | |
450 | 451 | | |
451 | 452 | | |
452 | 453 | | |
| |||
455 | 456 | | |
456 | 457 | | |
457 | 458 | | |
| 459 | + | |
| 460 | + | |
458 | 461 | | |
459 | 462 | | |
460 | 463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
505 | 508 | | |
506 | 509 | | |
507 | 510 | | |
| |||
514 | 517 | | |
515 | 518 | | |
516 | 519 | | |
| 520 | + | |
517 | 521 | | |
518 | 522 | | |
519 | 523 | | |
| |||
562 | 566 | | |
563 | 567 | | |
564 | 568 | | |
| 569 | + | |
565 | 570 | | |
566 | 571 | | |
567 | 572 | | |
| |||
574 | 579 | | |
575 | 580 | | |
576 | 581 | | |
| 582 | + | |
577 | 583 | | |
578 | 584 | | |
579 | 585 | | |
| |||
826 | 832 | | |
827 | 833 | | |
828 | 834 | | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
829 | 839 | | |
830 | 840 | | |
831 | 841 | | |
| |||
841 | 851 | | |
842 | 852 | | |
843 | 853 | | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
844 | 858 | | |
845 | 859 | | |
846 | 860 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | | - | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
250 | 291 | | |
251 | 292 | | |
252 | 293 | | |
| |||
0 commit comments