Point Mistral's floating Large aliases at Large 4, apply its GA price and cap its output (#4623)

* Point Mistral's floating Large aliases at Large 4 and apply its GA price

Mistral made Large 4 generally available on 2026-11-05, moved
`mistral-large-latest` to it, and deprecated Large 3 and Medium 3.5,
which both retire on 2027-04-30.

- `mistral-large-latest`, `mistral-large` and
  `mistralai/mistral-large-latest` resolve to `mistral-large-4`. They
  resolved to `mistral-large-2512`, which stays callable by its own id
  until Mistral retires it.
- Large 4 uses Mistral's current rates: $0.70 input, $0.07 cached input
  and $2.10 output per million tokens, in place of the preview rates.
  It is marked open-weight.
- The Large 3 and Medium 3.5 entries carry their retirement date.

* Cap Mistral Large 4 output at the 262,144 tokens Mistral accepts

The catalog listed `mistral-large-4` with a 1,000,000-token output
limit, equal to its context window. Mistral rejects a request for more
than 262,144 completion tokens, so a request that left `max_tokens`
unset, or set it higher, failed with a 400 whenever the account's
credit covered more than 262,144 output tokens.

- `max_tokens` for `mistral-large-4` is 262,144. The context window
  stays at 1,000,000 tokens.
- A test sends `mistral-large-4` and `mistral-large-latest` through the
  chat driver with ample credit and checks the cap that reaches
  Mistral.

---------

Co-authored-by: Daniel Salazar <daniel.salazar@puter.com>
This commit is contained in:
Filip KujundžićandDaniel Salazar authored and GitHub committed 2026-11-14 00:23:05 -07:00
1 parent 4ec125bbc6
commit 651a303bb0
2 files changed
+83 -25

No files matched your search

@@ -83,7 +83,10 @@ let server: PuterServer;
let recordSpy: MockInstance<MeteringService['utilRecordUsageObject']>;
beforeAll(async () => {
server = await setupTestServer();
// The key puts Mistral on the server's own chat driver.
server = await setupTestServer({
providers: { mistral: { apiKey: 'test-key' } },
});
});
afterAll(async () => {
@@ -187,11 +190,31 @@ describe('MistralAIProvider model catalog', () => {
expect(ids).not.toContain('magistral-medium-latest');
});
it('keeps mistral-large-2512, which Mistral still serves as active', async () => {
it.each(['mistral-large-2512', 'mistral-medium-2604'])(
'keeps %s, which Mistral serves until it retires the model',
async (id) => {
const { provider } = makeProvider();
expect((await provider.models()).map((model) => model.id)).toContain(
id,
);
},
);
it('moves the floating Large aliases off the deprecated Large 3', async () => {
const { provider } = makeProvider();
const ids = modelLookupNames(await provider.models());
expect(ids).toContain('mistral-large-2512');
expect(ids).toContain('mistral-large-latest');
const models = await provider.models();
const aliasesOf = (id: string) =>
models.find((model) => model.id === id)?.aliases ?? [];
expect(aliasesOf('mistral-large-4')).toEqual(
expect.arrayContaining([
'mistral-large-latest',
'mistral-large',
'mistralai/mistral-large-latest',
]),
);
expect(aliasesOf('mistral-large-2512')).toEqual([
'mistralai/mistral-large-2512',
]);
});
it('lists Large 4 with standard pricing and multimodal tool support', async () => {
@@ -204,17 +227,47 @@ describe('MistralAIProvider model catalog', () => {
modalities: { input: ['text', 'image'], output: ['text'] },
tool_call: true,
context: 1_000_000,
max_tokens: 1_000_000,
open_weights: false,
max_tokens: 262_144,
open_weights: true,
costs_currency: 'usd-cents',
costs: {
tokens: 1_000_000,
prompt_tokens: 136,
cached_tokens: 14,
completion_tokens: 418,
prompt_tokens: 70,
cached_tokens: 7,
completion_tokens: 210,
},
});
});
it.each(['mistral-large-4', 'mistral-large-latest'])(
'asks for no more output from %s than Mistral accepts',
async (model) => {
// Credit for far more output than the context window holds.
vi.spyOn(
server.services.metering,
'getUsageHeadroom',
).mockResolvedValue({ balance: 1e12, held: 0 });
completeMock.mockResolvedValueOnce({
choices: [
{
message: { content: 'hi', role: 'assistant' },
finishReason: 'stop',
},
],
usage: { promptTokens: 1, completionTokens: 1 },
});
await withTestActor(() =>
server.drivers.aiChat.complete({
model,
provider: 'mistral',
messages: [{ role: 'user', content: 'hi' }],
}),
);
expect(completeMock.mock.calls[0]![0].maxTokens).toBe(262_144);
},
);
});
// ── Request shape (Mistral-specific quirks) ─────────────────────────
@@ -539,7 +592,11 @@ describe('MistralAIProvider model resolution', () => {
['mistral-large-4-0', 'mistral-large-4'],
['mistralai/mistral-large-4', 'mistral-large-4'],
['mistralai/mistral-large-4-0', 'mistral-large-4'],
['mistral-large-latest', 'mistral-large-2512'],
['mistral-large-latest', 'mistral-large-4'],
['mistral-large', 'mistral-large-4'],
['mistralai/mistral-large-latest', 'mistral-large-4'],
['mistral-large-2512', 'mistral-large-2512'],
['mistralai/mistral-large-2512', 'mistral-large-2512'],
['zai-glm-latest', 'zai-glm-5-3'],
['zai-glm-5', 'zai-glm-5-3'],
['mistral-code-latest', 'codestral-2508'],
@@ -588,8 +645,8 @@ describe('MistralAIProvider model resolution', () => {
describe('MistralAIProvider.complete non-stream output', () => {
it.each([
['mistral-large-4', false, 136, 14, 418],
['mistral-large-4', true, 136, 14, 418],
['mistral-large-4', false, 70, 7, 210],
['mistral-large-4', true, 70, 7, 210],
['mistral-small-2603', false, 15, 1.5, 60],
['mistral-small-2603', true, 15, 1.5, 60],
['ministral-8b-2512', false, 15, 1.5, 15],
@@ -25,19 +25,23 @@ export const MISTRAL_MODELS: IChatModel[] = [
puterId: 'mistralai:mistralai/mistral-large-4',
id: 'mistral-large-4',
modalities: { input: ['text', 'image'], output: ['text'] },
open_weights: false,
open_weights: true,
tool_call: true,
release_date: '2026-10-06',
name: 'Mistral Large 4',
aliases: [
'mistral-large-4-0',
'mistral-large-latest',
'mistral-large',
'mistralai/mistral-large-4',
'mistralai/mistral-large-4-0',
'mistralai/mistral-large-latest',
],
context: 1_000_000,
max_tokens: 1_000_000,
// Mistral rejects a request for more completion tokens than this.
max_tokens: 262_144,
description:
'Public-preview multimodal model for reasoning, coding, and agentic workflows; open weights are forthcoming.',
'State-of-the-art, open-weight, general-purpose multimodal model for reasoning, coding, and agentic workflows.',
provider: 'mistral',
costs_currency: 'usd-cents',
input_cost_key: 'prompt_tokens',
@@ -45,12 +49,13 @@ export const MISTRAL_MODELS: IChatModel[] = [
serviceSpeedRates: { fast: 1.75 },
costs: {
tokens: 1_000_000,
prompt_tokens: 136,
cached_tokens: 14,
completion_tokens: 418,
prompt_tokens: 70,
cached_tokens: 7,
completion_tokens: 210,
},
},
{
// Mistral deprecated this model on 2026-10-31 and retires it on 2027-04-30.
puterId: 'mistralai:mistralai/mistral-medium-2604',
id: 'mistral-medium-2604',
modalities: { input: ['text', 'image'], output: ['text'] },
@@ -85,6 +90,7 @@ export const MISTRAL_MODELS: IChatModel[] = [
},
},
{
// Mistral deprecated this model on 2026-10-31 and retires it on 2027-04-30.
puterId: 'mistralai:mistralai/mistral-large-2512',
id: 'mistral-large-2512',
modalities: { input: ['text', 'image'], output: ['text'] },
@@ -93,12 +99,7 @@ export const MISTRAL_MODELS: IChatModel[] = [
knowledge: '2025-12',
release_date: '2025-12-02',
name: 'Mistral Large 3',
aliases: [
'mistral-large-latest',
'mistral-large',
'mistralai/mistral-large-latest',
'mistralai/mistral-large-2512',
],
aliases: ['mistralai/mistral-large-2512'],
context: 262_144,
max_tokens: 262_144,
description: