feat(ai-chat): add grok-4.6 model to xai provider

- Add grok-4.6 model definition with pricing and context specs
- Add aliases x-ai/grok-4.6 and grok-4.6-latest
- Add unit tests for alias resolution and metering calculation

Closes #3562
This commit is contained in:
rupesh0001-tech
2026-08-15 20:32:22 +05:30
parent 9e25ce1401
commit c88eeb3868
2 changed files with 58 additions and 0 deletions
@@ -387,6 +387,42 @@ describe('XAIProvider model resolution', () => {
);
});
it('resolves grok-4.6 aliases to grok-4.6 with correct metering overrides', async () => {
const { provider } = makeProvider();
createMock.mockResolvedValueOnce({
choices: [
{
message: { content: 'ok', role: 'assistant' },
finish_reason: 'stop',
},
],
usage: {
prompt_tokens: 1000,
completion_tokens: 500,
prompt_tokens_details: { cached_tokens: 200 },
},
});
await withTestActor(() =>
provider.complete({
model: 'grok-4.6-latest',
messages: [{ role: 'user', content: 'hi' }],
}),
);
expect(createMock.mock.calls[0]![0].model).toBe('grok-4.6');
expect(recordSpy).toHaveBeenCalledWith(
expect.any(Object),
expect.anything(),
'xai:grok-4.6',
{
prompt_tokens: 1000 * 200,
completion_tokens: 500 * 600,
cached_tokens: 200 * 50,
},
);
});
it('falls back to the default model when given an unknown id', async () => {
const { provider } = makeProvider();
createMock.mockResolvedValueOnce(baseCompletion);
@@ -21,6 +21,28 @@ import type { IChatModel } from '../../types.js';
// Hardcoded from https://models.dev/api.json
export const XAI_MODELS: IChatModel[] = [
{
puterId: 'x-ai:x-ai/grok-4.6',
id: 'grok-4.6',
modalities: { input: ['text', 'image'], output: ['text'] },
open_weights: false,
tool_call: true,
knowledge: '2026-02',
release_date: '2026-08-12',
name: 'Grok 4.6',
aliases: ['x-ai/grok-4.6', 'grok-4.6-latest'],
context: 500_000,
costs_currency: 'usd-cents',
input_cost_key: 'prompt_tokens',
output_cost_key: 'completion_tokens',
costs: {
tokens: 1_000_000,
prompt_tokens: 200,
completion_tokens: 600,
cached_tokens: 50,
},
max_tokens: 30_000,
},
{
puterId: 'x-ai:x-ai/grok-4.5',
id: 'grok-4.5',