@aiusage/cli 1.8.3 → 1.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +50 -12
- package/package.json +1 -1
- package/pricing-catalog.json +49 -1
package/dist/cli.js
CHANGED
|
@@ -599,6 +599,34 @@ var openai = {
|
|
|
599
599
|
codex: {
|
|
600
600
|
models: {
|
|
601
601
|
// ── GPT-6 系列 ──
|
|
602
|
+
// https://developers.openai.com/api/docs/models/gpt-6.2-astra (2026-11-18)
|
|
603
|
+
"gpt-6.2-astra": {
|
|
604
|
+
currency: "USD",
|
|
605
|
+
effective_from: "2026-11-17",
|
|
606
|
+
notes: "prompts over 272K input tokens bill the full request at long-context rates; cache writes use the 30-minute rate",
|
|
607
|
+
input_per_million: 8,
|
|
608
|
+
cached_input_per_million: 0.4,
|
|
609
|
+
cache_write_per_million: 10,
|
|
610
|
+
output_per_million: 40,
|
|
611
|
+
tiers: [
|
|
612
|
+
{ threshold: 272e3, input_per_million: 8, cached_input_per_million: 0.4, cache_write_per_million: 10, output_per_million: 40 },
|
|
613
|
+
{ input_per_million: 16, cached_input_per_million: 0.8, cache_write_per_million: 20, output_per_million: 60 }
|
|
614
|
+
]
|
|
615
|
+
},
|
|
616
|
+
// https://developers.openai.com/api/docs/models/gpt-6.2-sol (2026-11-18)
|
|
617
|
+
"gpt-6.2-sol": {
|
|
618
|
+
currency: "USD",
|
|
619
|
+
effective_from: "2026-11-17",
|
|
620
|
+
notes: "prompts over 272K input tokens bill the full request at long-context rates; cache writes use the 30-minute rate",
|
|
621
|
+
input_per_million: 2,
|
|
622
|
+
cached_input_per_million: 0.1,
|
|
623
|
+
cache_write_per_million: 2.5,
|
|
624
|
+
output_per_million: 10,
|
|
625
|
+
tiers: [
|
|
626
|
+
{ threshold: 272e3, input_per_million: 2, cached_input_per_million: 0.1, cache_write_per_million: 2.5, output_per_million: 10 },
|
|
627
|
+
{ input_per_million: 4, cached_input_per_million: 0.2, cache_write_per_million: 5, output_per_million: 15 }
|
|
628
|
+
]
|
|
629
|
+
},
|
|
602
630
|
// https://developers.openai.com/api/docs/models/gpt-6.1-terra (2026-11-14)
|
|
603
631
|
"gpt-6.1-terra": {
|
|
604
632
|
currency: "USD",
|
|
@@ -1596,7 +1624,7 @@ var inflection = {
|
|
|
1596
1624
|
};
|
|
1597
1625
|
|
|
1598
1626
|
// ../shared/src/pricing/catalog.ts
|
|
1599
|
-
var PRICING_VERSION = "2026-11-
|
|
1627
|
+
var PRICING_VERSION = "2026-11-18-gpt-6-2-v1", aliases = {
|
|
1600
1628
|
"claude-fibre-5": "claude-fable-5",
|
|
1601
1629
|
"claude-fiber-5": "claude-fable-5",
|
|
1602
1630
|
"claude-ops-5": "claude-opus-5",
|
|
@@ -1643,7 +1671,9 @@ var FAST_MULTIPLIERS = {
|
|
|
1643
1671
|
"claude-opus-4-8": 2,
|
|
1644
1672
|
"claude-opus-4-7": 6,
|
|
1645
1673
|
"grok-4.7": 2
|
|
1646
|
-
}, OPENAI_CODEX_TIER_MULTIPLIERS = {
|
|
1674
|
+
}, GPT_6_2_ULTRAFAST_PROMOTION_END = Date.parse("2027-03-01T00:00:00-08:00"), OPENAI_CODEX_TIER_MULTIPLIERS = {
|
|
1675
|
+
"gpt-6.2-astra": 2,
|
|
1676
|
+
"gpt-6.2-sol": 2,
|
|
1647
1677
|
"gpt-6.1-sol": 2,
|
|
1648
1678
|
"gpt-6.1-terra": 2,
|
|
1649
1679
|
"gpt-6-astra": 2,
|
|
@@ -1656,10 +1686,11 @@ var FAST_MULTIPLIERS = {
|
|
|
1656
1686
|
"gpt-5.4": 2
|
|
1657
1687
|
};
|
|
1658
1688
|
function splitServiceTierSuffix(model) {
|
|
1659
|
-
|
|
1689
|
+
let gpt62 = /^(gpt-6\.2-(?:astra|sol))-(ultrafast|batch)$/.exec(model);
|
|
1690
|
+
return gpt62 ? { baseModel: gpt62[1], tier: gpt62[2] === "ultrafast" ? "ultrafast" : "batch" } : model === "gpt-6.1-sol-ultrafast" ? { baseModel: model.replace(/-ultrafast$/, ""), tier: "ultrafast" } : model.endsWith("-priority") ? { baseModel: model.replace(/-priority$/, ""), tier: "priority" } : model.endsWith("-fast") ? { baseModel: model.replace(/-fast$/, ""), tier: "fast" } : { baseModel: model, tier: null };
|
|
1660
1691
|
}
|
|
1661
1692
|
function getServiceTierMultiplier(provider, product, resolvedModel, tier) {
|
|
1662
|
-
return tier ? provider === "openai" && product === "codex" ? tier === "ultrafast"
|
|
1693
|
+
return tier ? provider === "openai" && product === "codex" ? tier === "ultrafast" ? 6 : tier === "batch" ? 0.5 : tier === "fast" && resolvedModel.startsWith("gpt-5.6-") ? 1 : OPENAI_CODEX_TIER_MULTIPLIERS[resolvedModel] ?? 1 : tier === "fast" ? FAST_MULTIPLIERS[resolvedModel] ?? 1 : 1 : 1;
|
|
1663
1694
|
}
|
|
1664
1695
|
function resolveModelPricing(catalog2, provider, product, model) {
|
|
1665
1696
|
let models2 = catalog2.providers[provider]?.[product]?.models;
|
|
@@ -1712,7 +1743,12 @@ function calculateCost(provider, product, model, tokens, options = {}) {
|
|
|
1712
1743
|
};
|
|
1713
1744
|
let cw5Rate = unit.cache_write_5m_per_million ?? pricing.cache_write_5m_per_million ?? 0, cw1hRate = unit.cache_write_1h_per_million ?? pricing.cache_write_1h_per_million ?? 0, hasGenericCacheWriteRate = unit.cache_write_per_million !== void 0 || pricing.cache_write_per_million !== void 0, genericCwRate = unit.cache_write_per_million ?? pricing.cache_write_per_million ?? 0, cachedRate = unit.cached_input_per_million ?? pricing.cached_input_per_million ?? 0, cacheWriteCost = hasGenericCacheWriteRate ? tokens.cacheWriteTokens / 1e6 * genericCwRate : (tokens.cacheWrite5mTokens ?? tokens.cacheWriteTokens) / 1e6 * cw5Rate + (tokens.cacheWrite1hTokens ?? 0) / 1e6 * cw1hRate, raw = tokens.inputTokens / 1e6 * (unit.input_per_million ?? 0) + tokens.cachedInputTokens / 1e6 * (cachedRate ?? 0) + cacheWriteCost + tokens.outputTokens / 1e6 * (unit.output_per_million ?? 0);
|
|
1714
1745
|
raw = toUsd(raw, pricing.currency, cat);
|
|
1715
|
-
let
|
|
1746
|
+
let multiplier = getServiceTierMultiplier(provider, product, resolvedModel, tier);
|
|
1747
|
+
if (provider === "openai" && product === "codex" && tier === "ultrafast" && (resolvedModel === "gpt-6.2-astra" || resolvedModel === "gpt-6.2-sol")) {
|
|
1748
|
+
let { usageTime } = options;
|
|
1749
|
+
typeof usageTime == "string" ? (multiplier = usageTime < "2027-03-01" ? 3 : 6, (usageTime === "2027-02-28" || usageTime === "2027-03-01") && (costStatus = "estimated")) : (multiplier = (usageTime ?? Date.now()) < GPT_6_2_ULTRAFAST_PROMOTION_END ? 3 : 6, usageTime === void 0 && (costStatus = "estimated"));
|
|
1750
|
+
}
|
|
1751
|
+
let finalCost = raw * multiplier;
|
|
1716
1752
|
return {
|
|
1717
1753
|
estimatedCostUsd: Math.round(finalCost * 1e4) / 1e4,
|
|
1718
1754
|
costStatus,
|
|
@@ -1814,7 +1850,7 @@ async function processCodexFile(filePath, projectAliases, serviceTier) {
|
|
|
1814
1850
|
// Reasoning is billed at the output rate, so pricing still uses the
|
|
1815
1851
|
// inclusive raw Codex output total.
|
|
1816
1852
|
outputTokens: tokens.output
|
|
1817
|
-
}), exactEventCost = eventCost.costStatus === "exact" ? eventCost.estimatedCostUsd : void 0;
|
|
1853
|
+
}, { usageTime: ts.getTime() }), exactEventCost = eventCost.costStatus === "exact" ? eventCost.estimatedCostUsd : void 0;
|
|
1818
1854
|
events.push({
|
|
1819
1855
|
usageDate,
|
|
1820
1856
|
signature,
|
|
@@ -4215,7 +4251,7 @@ async function buildLocalReport(range, options = {}) {
|
|
|
4215
4251
|
if (hasData) {
|
|
4216
4252
|
daysWithData += 1;
|
|
4217
4253
|
for (let breakdown of result.breakdowns) {
|
|
4218
|
-
let breakdownTotals = toBreakdownTotals(breakdown, pricingWarnings, options.pricingCatalog);
|
|
4254
|
+
let breakdownTotals = toBreakdownTotals(breakdown, pricingWarnings, options.pricingCatalog, usageDate);
|
|
4219
4255
|
dayTotals.estimatedCostUsd += breakdownTotals.estimatedCostUsd, mergeTotals(totals, breakdownTotals), mergeTotals(getOrCreate(bySource, `${breakdown.provider}/${breakdown.product}`), breakdownTotals), mergeTotals(
|
|
4220
4256
|
getOrCreate(byModel, `${breakdown.provider}/${breakdown.product}|${breakdown.model}`),
|
|
4221
4257
|
breakdownTotals
|
|
@@ -4628,8 +4664,8 @@ function createEmptyTotals2() {
|
|
|
4628
4664
|
function mergeTotals(target, source) {
|
|
4629
4665
|
return target.eventCount += source.eventCount, target.inputTokens += source.inputTokens, target.cachedInputTokens += source.cachedInputTokens, target.cacheWriteTokens += source.cacheWriteTokens, target.outputTokens += source.outputTokens, target.reasoningOutputTokens += source.reasoningOutputTokens, target.totalTokens += source.totalTokens, target.estimatedCostUsd += source.estimatedCostUsd, target;
|
|
4630
4666
|
}
|
|
4631
|
-
function toBreakdownTotals(breakdown, warnings, pricingCatalog) {
|
|
4632
|
-
let estimatedCostUsd = calculateBreakdownCost(breakdown, warnings, pricingCatalog);
|
|
4667
|
+
function toBreakdownTotals(breakdown, warnings, pricingCatalog, usageDate) {
|
|
4668
|
+
let estimatedCostUsd = calculateBreakdownCost(breakdown, warnings, pricingCatalog, usageDate);
|
|
4633
4669
|
return {
|
|
4634
4670
|
eventCount: breakdown.eventCount,
|
|
4635
4671
|
inputTokens: breakdown.inputTokens,
|
|
@@ -4641,7 +4677,7 @@ function toBreakdownTotals(breakdown, warnings, pricingCatalog) {
|
|
|
4641
4677
|
estimatedCostUsd
|
|
4642
4678
|
};
|
|
4643
4679
|
}
|
|
4644
|
-
function calculateBreakdownCost(breakdown, warnings, pricingCatalog) {
|
|
4680
|
+
function calculateBreakdownCost(breakdown, warnings, pricingCatalog, usageDate) {
|
|
4645
4681
|
let effectivePricingVersion = pricingCatalog?.version ?? PRICING_VERSION, sourceCostMatchesCatalog = breakdown.product === "trae-intl" || breakdown.product === "opencode" || breakdown.pricingVersion == null || breakdown.pricingVersion === effectivePricingVersion;
|
|
4646
4682
|
if (breakdown.costUSD != null && breakdown.costUSD > 0 && sourceCostMatchesCatalog)
|
|
4647
4683
|
return breakdown.costUSD;
|
|
@@ -4655,11 +4691,13 @@ function calculateBreakdownCost(breakdown, warnings, pricingCatalog) {
|
|
|
4655
4691
|
cacheWriteTokens: breakdown.cacheWriteTokens,
|
|
4656
4692
|
cacheWrite5mTokens: breakdown.cacheWrite5mTokens,
|
|
4657
4693
|
cacheWrite1hTokens: breakdown.cacheWrite1hTokens,
|
|
4658
|
-
|
|
4694
|
+
// Codex stores reasoning separately from visible output in the breakdown.
|
|
4695
|
+
outputTokens: breakdown.outputTokens + (breakdown.product === "codex" ? breakdown.reasoningOutputTokens ?? 0 : 0)
|
|
4659
4696
|
},
|
|
4660
4697
|
{
|
|
4661
4698
|
...pricingCatalog ? { catalog: pricingCatalog } : {},
|
|
4662
|
-
requestCount: breakdown.eventCount
|
|
4699
|
+
requestCount: breakdown.eventCount,
|
|
4700
|
+
usageTime: usageDate
|
|
4663
4701
|
}
|
|
4664
4702
|
);
|
|
4665
4703
|
return result.costStatus === "unavailable" ? warnings.add(`${breakdown.provider}/${breakdown.product}/${breakdown.model} \u6682\u65E0\u5B9A\u4EF7\u914D\u7F6E\uFF0C\u5DF2\u8DF3\u8FC7\u6210\u672C\u4F30\u7B97\u3002`) : result.costStatus === "estimated" && result.resolvedModel && result.resolvedModel !== breakdown.model ? warnings.add(`${breakdown.model} \u5DF2\u6309 ${result.resolvedModel} \u7684\u516C\u5F00\u5355\u4EF7\u4F30\u7B97\u3002`) : result.costStatus === "estimated" && result.matchedTierIndex !== void 0 && warnings.add(`${breakdown.model} \u7684\u9636\u68AF\u4EF7\u683C\u5DF2\u6309\u6BCF\u4E8B\u4EF6\u5E73\u5747\u8F93\u5165\u91CF\u4F30\u7B97\u3002`), result.estimatedCostUsd;
|
package/package.json
CHANGED
package/pricing-catalog.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2026-11-
|
|
2
|
+
"version": "2026-11-18-gpt-6-2-v1",
|
|
3
3
|
"fx": {
|
|
4
4
|
"CNY": 7.2
|
|
5
5
|
},
|
|
@@ -215,6 +215,54 @@
|
|
|
215
215
|
"openai": {
|
|
216
216
|
"codex": {
|
|
217
217
|
"models": {
|
|
218
|
+
"gpt-6.2-astra": {
|
|
219
|
+
"currency": "USD",
|
|
220
|
+
"effective_from": "2026-11-17",
|
|
221
|
+
"notes": "prompts over 272K input tokens bill the full request at long-context rates; cache writes use the 30-minute rate",
|
|
222
|
+
"input_per_million": 8,
|
|
223
|
+
"cached_input_per_million": 0.4,
|
|
224
|
+
"cache_write_per_million": 10,
|
|
225
|
+
"output_per_million": 40,
|
|
226
|
+
"tiers": [
|
|
227
|
+
{
|
|
228
|
+
"threshold": 272000,
|
|
229
|
+
"input_per_million": 8,
|
|
230
|
+
"cached_input_per_million": 0.4,
|
|
231
|
+
"cache_write_per_million": 10,
|
|
232
|
+
"output_per_million": 40
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"input_per_million": 16,
|
|
236
|
+
"cached_input_per_million": 0.8,
|
|
237
|
+
"cache_write_per_million": 20,
|
|
238
|
+
"output_per_million": 60
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
"gpt-6.2-sol": {
|
|
243
|
+
"currency": "USD",
|
|
244
|
+
"effective_from": "2026-11-17",
|
|
245
|
+
"notes": "prompts over 272K input tokens bill the full request at long-context rates; cache writes use the 30-minute rate",
|
|
246
|
+
"input_per_million": 2,
|
|
247
|
+
"cached_input_per_million": 0.1,
|
|
248
|
+
"cache_write_per_million": 2.5,
|
|
249
|
+
"output_per_million": 10,
|
|
250
|
+
"tiers": [
|
|
251
|
+
{
|
|
252
|
+
"threshold": 272000,
|
|
253
|
+
"input_per_million": 2,
|
|
254
|
+
"cached_input_per_million": 0.1,
|
|
255
|
+
"cache_write_per_million": 2.5,
|
|
256
|
+
"output_per_million": 10
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"input_per_million": 4,
|
|
260
|
+
"cached_input_per_million": 0.2,
|
|
261
|
+
"cache_write_per_million": 5,
|
|
262
|
+
"output_per_million": 15
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
},
|
|
218
266
|
"gpt-6.1-terra": {
|
|
219
267
|
"currency": "USD",
|
|
220
268
|
"notes": "prompts over 272K input tokens bill the full request at long-context rates; cache write uses the 30-minute rate",
|