Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/types/src/providers/xai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ export const xaiModels = {
cacheReadsPrice: 0.75,
description: "xAI's Grok-4 model with 256K context window",
},
"grok-4-fast": {
maxTokens: 8192,
contextWindow: 2_000_000,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.2,
outputPrice: 0.5,
description: "xAI's Grok-4 Fast model with 2M context window",
},
"grok-3": {
maxTokens: 8192,
contextWindow: 131072,
Expand Down
11 changes: 11 additions & 0 deletions src/api/providers/__tests__/xai.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ describe("XAIHandler", () => {
expect(model.info).toEqual(xaiModels[testModelId])
})

test("should return grok-4-fast model when specified", () => {
const testModelId = "grok-4-fast"
const handlerWithModel = new XAIHandler({ apiModelId: testModelId })
const model = handlerWithModel.getModel()

expect(model.id).toBe(testModelId)
expect(model.info).toEqual(xaiModels[testModelId])
expect(model.info.contextWindow).toBe(2_000_000)
expect(model.info.maxTokens).toBe(30_000)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test expects maxTokens to be 30_000 but the model configuration (line 32 in xai.ts) defines it as 8192. This mismatch was introduced when the second commit updated the pricing and maxTokens but didn't update the test. The test will fail when run.

Suggested change
expect(model.info.maxTokens).toBe(30_000)
expect(model.id).toBe(testModelId)
expect(model.info).toEqual(xaiModels[testModelId])
expect(model.info.contextWindow).toBe(2_000_000)
expect(model.info.maxTokens).toBe(8192)

})

it("should include reasoning_effort parameter for mini models", async () => {
const miniModelHandler = new XAIHandler({
apiModelId: "grok-3-mini",
Expand Down
Loading