mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-23 22:47:19 +00:00
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:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user