Skip to content

Commit acc795e

Browse files
authored
Fix pricing and token counting for Xai Provider for the new Grok 3 family of models (RooCodeInc#3956)
1 parent 1aaa30e commit acc795e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/api/providers/xai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ export class XAIHandler implements ApiHandler {
5858
if (chunk.usage) {
5959
yield {
6060
type: "usage",
61-
inputTokens: 0,
61+
inputTokens: chunk.usage.prompt_tokens || 0,
6262
outputTokens: chunk.usage.completion_tokens || 0,
6363
// @ts-ignore-next-line
64-
cacheReadTokens: chunk.usage.prompt_cache_hit_tokens || 0,
64+
cacheReadTokens: chunk.usage.prompt_tokens_details?.cached_tokens || 0,
6565
// @ts-ignore-next-line
6666
cacheWriteTokens: chunk.usage.prompt_cache_miss_tokens || 0,
6767
}

src/shared/api.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ export const xaiModels = {
17611761
maxTokens: 8192,
17621762
contextWindow: 131072,
17631763
supportsImages: false,
1764-
supportsPromptCache: false,
1764+
supportsPromptCache: true,
17651765
inputPrice: 3.0,
17661766
outputPrice: 15.0,
17671767
description: "X AI's Grok-3 beta model with 131K context window",
@@ -1770,7 +1770,7 @@ export const xaiModels = {
17701770
maxTokens: 8192,
17711771
contextWindow: 131072,
17721772
supportsImages: false,
1773-
supportsPromptCache: false,
1773+
supportsPromptCache: true,
17741774
inputPrice: 5.0,
17751775
outputPrice: 25.0,
17761776
description: "X AI's Grok-3 fast beta model with 131K context window",
@@ -1779,7 +1779,7 @@ export const xaiModels = {
17791779
maxTokens: 8192,
17801780
contextWindow: 131072,
17811781
supportsImages: false,
1782-
supportsPromptCache: false,
1782+
supportsPromptCache: true,
17831783
inputPrice: 0.3,
17841784
outputPrice: 0.5,
17851785
description: "X AI's Grok-3 mini beta model with 131K context window",
@@ -1788,7 +1788,7 @@ export const xaiModels = {
17881788
maxTokens: 8192,
17891789
contextWindow: 131072,
17901790
supportsImages: false,
1791-
supportsPromptCache: false,
1791+
supportsPromptCache: true,
17921792
inputPrice: 0.6,
17931793
outputPrice: 4.0,
17941794
description: "X AI's Grok-3 mini fast beta model with 131K context window",
@@ -1797,7 +1797,7 @@ export const xaiModels = {
17971797
maxTokens: 8192,
17981798
contextWindow: 131072,
17991799
supportsImages: false,
1800-
supportsPromptCache: false,
1800+
supportsPromptCache: true,
18011801
inputPrice: 3.0,
18021802
outputPrice: 15.0,
18031803
description: "X AI's Grok-3 model with 131K context window",
@@ -1806,7 +1806,7 @@ export const xaiModels = {
18061806
maxTokens: 8192,
18071807
contextWindow: 131072,
18081808
supportsImages: false,
1809-
supportsPromptCache: false,
1809+
supportsPromptCache: true,
18101810
inputPrice: 5.0,
18111811
outputPrice: 25.0,
18121812
description: "X AI's Grok-3 fast model with 131K context window",
@@ -1815,7 +1815,7 @@ export const xaiModels = {
18151815
maxTokens: 8192,
18161816
contextWindow: 131072,
18171817
supportsImages: false,
1818-
supportsPromptCache: false,
1818+
supportsPromptCache: true,
18191819
inputPrice: 0.3,
18201820
outputPrice: 0.5,
18211821
description: "X AI's Grok-3 mini model with 131K context window",
@@ -1824,7 +1824,7 @@ export const xaiModels = {
18241824
maxTokens: 8192,
18251825
contextWindow: 131072,
18261826
supportsImages: false,
1827-
supportsPromptCache: false,
1827+
supportsPromptCache: true,
18281828
inputPrice: 0.6,
18291829
outputPrice: 4.0,
18301830
description: "X AI's Grok-3 mini fast model with 131K context window",

0 commit comments

Comments
 (0)