@absolutejs/ai 0.1.2 → 0.1.3
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/CHANGELOG.md +6 -0
- package/changelog.json +14 -0
- package/dist/ai/index.js +7 -5
- package/dist/ai/index.js.map +4 -4
- package/dist/ai/providers/openai.js +7 -5
- package/dist/ai/providers/openai.js.map +4 -4
- package/dist/ai/providers/openaiCompatible.js +7 -5
- package/dist/ai/providers/openaiCompatible.js.map +4 -4
- package/dist/ai/providers/openaiResponses.js +4 -3
- package/dist/ai/providers/openaiResponses.js.map +3 -3
- package/dist/ai/providers/openrouter.js +7 -5
- package/dist/ai/providers/openrouter.js.map +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
|
|
|
6
6
|
`changelog/`. Edit an entry, not this file — and add new ones under
|
|
7
7
|
`changelog/unreleased/`.
|
|
8
8
|
|
|
9
|
+
## 0.1.3 — 2026-09-16
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Exclude OpenAI cache-write tokens from ordinary input so cache-aware billing never charges the same tokens twice** (`openai`, `openaiResponses`)
|
|
14
|
+
|
|
9
15
|
## 0.1.2 — 2026-09-16
|
|
10
16
|
|
|
11
17
|
### Fixed
|
package/changelog.json
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
"contract": 1,
|
|
3
3
|
"name": "@absolutejs/ai",
|
|
4
4
|
"releases": [
|
|
5
|
+
{
|
|
6
|
+
"changes": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "fixed",
|
|
9
|
+
"summary": "Exclude OpenAI cache-write tokens from ordinary input so cache-aware billing never charges the same tokens twice",
|
|
10
|
+
"symbols": [
|
|
11
|
+
"openai",
|
|
12
|
+
"openaiResponses"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"date": "2026-09-16",
|
|
17
|
+
"version": "0.1.3"
|
|
18
|
+
},
|
|
5
19
|
{
|
|
6
20
|
"changes": [
|
|
7
21
|
{
|
package/dist/ai/index.js
CHANGED
|
@@ -877,11 +877,12 @@ var extractUsage = (response) => {
|
|
|
877
877
|
const outputDetails = isRecord(usage.output_tokens_details) ? usage.output_tokens_details : undefined;
|
|
878
878
|
const inputDetails = isRecord(usage.input_tokens_details) ? usage.input_tokens_details : undefined;
|
|
879
879
|
const costDetails = isRecord(usage.cost_details) ? usage.cost_details : undefined;
|
|
880
|
+
const written = inputDetails && typeof inputDetails.cache_write_tokens === "number" ? inputDetails.cache_write_tokens : 0;
|
|
880
881
|
const normalized = {
|
|
881
882
|
cacheReadInputTokens: cached,
|
|
882
|
-
cacheWriteInputTokens:
|
|
883
|
+
cacheWriteInputTokens: written || undefined,
|
|
883
884
|
costCredits: typeof usage.cost === "number" ? usage.cost : undefined,
|
|
884
|
-
inputTokens: Math.max(0, input - cached),
|
|
885
|
+
inputTokens: Math.max(0, input - cached - written),
|
|
885
886
|
outputTokens: typeof usage.output_tokens === "number" ? usage.output_tokens : 0,
|
|
886
887
|
reasoningTokens: outputDetails && typeof outputDetails.reasoning_tokens === "number" ? outputDetails.reasoning_tokens : undefined,
|
|
887
888
|
upstreamInferenceCostCredits: costDetails && typeof costDetails.upstream_inference_cost === "number" ? costDetails.upstream_inference_cost : undefined
|
|
@@ -1410,11 +1411,12 @@ var flushPendingToolCalls = function* (pendingToolCalls) {
|
|
|
1410
1411
|
var extractUsage2 = (parsedUsage) => {
|
|
1411
1412
|
const prompt = parsedUsage.prompt_tokens ?? 0;
|
|
1412
1413
|
const cached = parsedUsage.cached_tokens ?? 0;
|
|
1414
|
+
const written = parsedUsage.cache_write_tokens ?? 0;
|
|
1413
1415
|
return {
|
|
1414
1416
|
cacheReadInputTokens: cached,
|
|
1415
|
-
cacheWriteInputTokens:
|
|
1417
|
+
cacheWriteInputTokens: written || undefined,
|
|
1416
1418
|
costCredits: parsedUsage.cost,
|
|
1417
|
-
inputTokens: Math.max(0, prompt - cached),
|
|
1419
|
+
inputTokens: Math.max(0, prompt - cached - written),
|
|
1418
1420
|
outputTokens: parsedUsage.completion_tokens ?? 0,
|
|
1419
1421
|
reasoningTokens: parsedUsage.reasoning_tokens || undefined,
|
|
1420
1422
|
upstreamInferenceCostCredits: parsedUsage.upstream_inference_cost || undefined
|
|
@@ -8704,5 +8706,5 @@ export {
|
|
|
8704
8706
|
xai
|
|
8705
8707
|
};
|
|
8706
8708
|
|
|
8707
|
-
//# debugId=
|
|
8709
|
+
//# debugId=7535B0C2EE1EFEA864756E2164756E21
|
|
8708
8710
|
//# sourceMappingURL=index.js.map
|