
Mistral Large 4 Preview: Canary-Test Silent Model Updates
Summary
Mistral Large 4's preview can change without notice. Build a Python canary suite that catches it.
Mistral shipped Large 4 (nicknamed Le Chonk) on October 6, 2026 as a public API preview. It is a 1.05 trillion parameter mixture-of-experts model with 49 billion active parameters, a 1.6B vision encoder, function calling, structured outputs, and an intro price of $0.68 per million input tokens and $2.09 per million output tokens (half the list price, with no published end date). Open weights are promised for the end of October. That combination is why people are trying it today.
Buried in the launch notes is the part that should change how you integrate it: Mistral says a preview model may receive silent updates without notice, carries no general-availability guarantee, and gets one month of deprecation notice. The model behind mistral-large-4 can be different on Friday than it was on Tuesday, and your extraction prompt, your tool schema and your cost model all quietly depend on it.
This guide builds a small canary suite in Python. It checks five things on every run: structured output, forced tool calls, output fingerprint drift, prompt-cache hits, and whether the long-context claim (1M advertised, roughly 512K reported by independent evaluators) holds for your prompts. You will end up with one script you can drop into cron or CI, and a clear idea of which failures matter.
Prerequisites
- Python 3.10+ and a Mistral API key from Mistral Studio, exported as
MISTRAL_API_KEY. pip install mistralai pydantic. This guide was checked against mistralai 3.1.0, where the import isfrom mistralai.client import Mistral. Older 1.x tutorials usefrom mistralai import Mistral, which fails on 3.x.- A rough budget: the four default checks cost well under a cent. Each long-context needle check costs about the size of its prompt times $0.68 per million, so a 400K-token probe is around 27 cents.
What can go wrong with a preview model
Before writing code, decide what you are actually guarding against. A silent update can break an app in ways that never raise an exception:
| Failure | How it shows up | Which canary catches it |
|---|---|---|
| Schema adherence regresses | Fields come back null or dates change format | structured |
| Tool calling gets chattier | Model answers in prose instead of calling your function | tool_call |
| Weights or sampling changed | Same prompt at temperature 0 gives different text | fingerprint |
| Cache stops matching | Bill jumps even though prompts did not change | cache |
| Context is shorter than advertised | Facts in the middle of long inputs vanish | needle_*k |
Step 1: The structured output canary
Mistral's SDK has client.chat.parse(). You pass a Pydantic class as response_format and the SDK converts it to a JSON schema, calls chat.complete, then validates the reply back into your class at choices[0].message.parsed. The test input is a messy bilingual invoice, because that is closer to real workloads than a clean demo string.
class Invoice(BaseModel):
vendor: str
total_eur: float
due_date: str # ISO 8601
def check_structured(client):
r = client.chat.parse(model=MODEL, response_format=Invoice, temperature=0,
messages=[{"role": "system", "content": "Extract the invoice."},
{"role": "user", "content": INVOICE_TEXT}])
inv = r.choices[0].message.parsed
ok = inv is not None and inv.vendor.startswith("Brasserie") \
and abs(inv.total_eur - 101.0) < 0.01 and inv.due_date == "2026-11-15"
return ok, {"served_model": r.model, "parsed": inv.model_dump() if inv else None}
Note that I log r.model. The response echoes which model string actually served the call, and for aliases like mistral-large-latest that string is the closest thing to a version number you will get. The docs list the exact ID as mistral-large-4-0 (version v26.10), so pin that rather than the alias when you can.
Step 2: The forced tool call canary
Mistral's function calling takes tool_choice of auto, any or none, plus parallel_tool_calls. Forcing any with a single tool means a healthy model must return exactly one call. If it returns zero or two, something moved.
def check_tool_call(client):
r = client.chat.complete(model=MODEL, temperature=0, tools=TOOLS,
tool_choice="any", parallel_tool_calls=False,
messages=[{"role": "user", "content": "Where is order A-1182?"}])
calls = r.choices[0].message.tool_calls or []
if len(calls) != 1:
return False, {"n_calls": len(calls)}
args = json.loads(calls[0].function.arguments)
return (calls[0].function.name == "get_order_status"
and args.get("order_id") == "A-1182"), {"args": args}
The arguments arrive as a JSON string, not a dict, so json.loads is required. In a real agent you would then append a message with role: tool, the function name, the result as content, and the tool_call_id, and call the model again until it stops asking for tools. The canary only needs the first hop.
Step 3: Fingerprint drift
This one is blunt and useful. Run three fixed prompts at temperature=0 with a random_seed, hash the outputs, and compare against a stored baseline. Mistral documents random_seed as making calls deterministic, but treat that as best effort on a mixture-of-experts model served across many GPUs. A single mismatch is a hint. A mismatch on all three plus a changed served_models value is a real update.
def check_fingerprint(client, baseline):
prompts = ["Name three prime numbers above 100.",
"Translate 'the build is green' to French.",
"Write a Python one-liner that reverses a string."]
digests, served = [], set()
for p in prompts:
r = client.chat.complete(model=MODEL, temperature=0, random_seed=7,
max_tokens=80, messages=[{"role": "user", "content": p}])
served.add(r.model)
digests.append(hashlib.sha256(r.choices[0].message.content.encode()).hexdigest()[:12])
now = {"digests": digests, "served_models": sorted(served)}
if "fingerprint" not in baseline:
baseline["fingerprint"] = now
return True, {"note": "baseline recorded", **now}
return baseline["fingerprint"] == now, {"baseline": baseline["fingerprint"], "now": now}
The first run records the baseline into baseline.json. After that, any change fails the check. When you have looked at the diff and decided the new behavior is acceptable, delete the file and let it re-baseline.
Step 4: Does the cache actually hit?
Cached input is priced at $0.07 per million against $0.68 for fresh input, so a working cache is a roughly tenfold discount on repeated prefixes. The chat endpoint accepts a prompt_cache_key to group requests that share a prefix. Mistral's own notes say a hit is possible, not guaranteed, so this canary reports instead of failing.
def cached_tokens(usage) -> int:
# Not a typed field in SDK 3.1.0; it lands in pydantic extras as a dict.
extra = getattr(usage, "__pydantic_extra__", None) or {}
return (extra.get("prompt_tokens_details") or {}).get("cached_tokens", 0)
This helper is the one place I hit an SDK surprise. UsageInfo in 3.1.0 only declares prompt, completion and total tokens. The cached count arrives in prompt_tokens_details as an undeclared extra, so usage.prompt_tokens_details raises an attribute error on some versions. Reading it out of __pydantic_extra__ works either way. Regional endpoints also apply a 1.1x price multiplier and drop the Agents, Batch and Files APIs, which matters if you are deploying in the EU for data residency.
Step 5: Needle tests for the long-context claim
Mistral advertises 1M tokens. Independent evaluators list roughly 512K to 524K. Rather than argue, measure with your own data shape. Bury one fact in the middle of filler and ask for it back.
def check_needle(client, approx_tokens):
filler = "The quarterly report mentions routine logistics. " # ~8 tokens
n = approx_tokens // 8
pos = n // 2
body = filler * pos + "The vault code is 7392-BLUE. " + filler * (n - pos)
r = client.chat.complete(model=MODEL, temperature=0, max_tokens=20,
messages=[{"role": "user", "content": body + "\n\nWhat is the vault code?"}])
return "7392-BLUE" in (r.choices[0].message.content or ""), {
"prompt_tokens": r.usage.prompt_tokens}
Repeated filler is the easiest possible haystack, so passing it proves little about real documents. Failing it is informative: if the model cannot find a unique string in repetitive text at 600K tokens, do not send it a 600K-token contract. Swap in a paragraph sampled from your own corpus when you want a realistic number. The reported prompt_tokens also tells you how far off the 8-tokens-per-sentence estimate was.
The complete script
Here is everything together. It runs each check, treats API errors as results instead of crashes, saves the baseline, and exits non-zero on any failure so cron or CI can alert.
"""canary.py - regression canaries for a preview model that may update silently."""
import hashlib, json, os, sys, time
from pathlib import Path
from pydantic import BaseModel
from mistralai.client import Mistral
MODEL = os.environ.get("CANARY_MODEL", "mistral-large-4")
BASELINE = Path("baseline.json")
class Invoice(BaseModel):
vendor: str
total_eur: float
due_date: str # ISO 8601
INVOICE_TEXT = ("Rechnung Nr. 4471 from Brasserie Lumi, Lyon. Items: 2x menu 38.50, "
"1x wine 24.00. Total due EUR 101.00 by 2026-11-15.")
TOOLS = [{"type": "function", "function": {
"name": "get_order_status",
"description": "Look up an order by id.",
"parameters": {"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"]}}}]
def cached_tokens(usage) -> int:
# Not a typed field in SDK 3.1.0; it lands in pydantic extras as a dict.
extra = getattr(usage, "__pydantic_extra__", None) or {}
return (extra.get("prompt_tokens_details") or {}).get("cached_tokens", 0)
def check_structured(client):
r = client.chat.parse(model=MODEL, response_format=Invoice, temperature=0,
messages=[{"role": "system", "content": "Extract the invoice."},
{"role": "user", "content": INVOICE_TEXT}])
inv = r.choices[0].message.parsed
ok = inv is not None and inv.vendor.startswith("Brasserie") \
and abs(inv.total_eur - 101.0) < 0.01 and inv.due_date == "2026-11-15"
return ok, {"served_model": r.model, "parsed": inv.model_dump() if inv else None}
def check_tool_call(client):
r = client.chat.complete(model=MODEL, temperature=0, tools=TOOLS,
tool_choice="any", parallel_tool_calls=False,
messages=[{"role": "user", "content": "Where is order A-1182?"}])
calls = r.choices[0].message.tool_calls or []
if len(calls) != 1:
return False, {"n_calls": len(calls)}
args = json.loads(calls[0].function.arguments)
return (calls[0].function.name == "get_order_status"
and args.get("order_id") == "A-1182"), {"args": args}
def check_fingerprint(client, baseline):
prompts = ["Name three prime numbers above 100.",
"Translate 'the build is green' to French.",
"Write a Python one-liner that reverses a string."]
digests, served = [], set()
for p in prompts:
r = client.chat.complete(model=MODEL, temperature=0, random_seed=7,
max_tokens=80, messages=[{"role": "user", "content": p}])
served.add(r.model)
digests.append(hashlib.sha256(r.choices[0].message.content.encode()).hexdigest()[:12])
now = {"digests": digests, "served_models": sorted(served)}
if "fingerprint" not in baseline:
baseline["fingerprint"] = now
return True, {"note": "baseline recorded", **now}
same = baseline["fingerprint"] == now
return same, {"baseline": baseline["fingerprint"], "now": now}
def check_cache(client):
prefix = "Policy handbook. " + ("Refunds take 5 days. " * 700) # >1k tokens
seen = []
for _ in range(2):
r = client.chat.complete(model=MODEL, max_tokens=5,
prompt_cache_key="canary-handbook-v1",
messages=[{"role": "system", "content": prefix},
{"role": "user", "content": "How many days do refunds take?"}])
seen.append(cached_tokens(r.usage))
time.sleep(1)
# A hit is likely, never guaranteed: warn, don't fail.
return True, {"cached_tokens_per_call": seen, "hit": seen[-1] > 0}
def check_needle(client, approx_tokens):
filler = "The quarterly report mentions routine logistics. " # ~8 tokens
n = approx_tokens // 8
pos = n // 2
body = filler * pos + "The vault code is 7392-BLUE. " + filler * (n - pos)
r = client.chat.complete(model=MODEL, temperature=0, max_tokens=20,
messages=[{"role": "user", "content": body + "\n\nWhat is the vault code?"}])
return "7392-BLUE" in (r.choices[0].message.content or ""), {
"prompt_tokens": r.usage.prompt_tokens}
def main():
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
baseline = json.loads(BASELINE.read_text()) if BASELINE.exists() else {}
checks = {"structured": lambda: check_structured(client),
"tool_call": lambda: check_tool_call(client),
"fingerprint": lambda: check_fingerprint(client, baseline),
"cache": lambda: check_cache(client)}
for size in [int(x) for x in os.environ.get("NEEDLE_SIZES", "").split(",") if x]:
checks[f"needle_{size//1000}k"] = lambda s=size: check_needle(client, s)
failed = 0
for name, fn in checks.items():
try:
ok, detail = fn()
except Exception as e: # a 4xx/5xx is a canary result, not a crash
ok, detail = False, {"error": f"{type(e).__name__}: {e}"[:200]}
failed += not ok
print(f"{'PASS' if ok else 'FAIL'} {name} {json.dumps(detail)}")
BASELINE.write_text(json.dumps(baseline, indent=2))
sys.exit(1 if failed else 0)
if __name__ == "__main__":
main()
Run it with NEEDLE_SIZES=200000,400000 python canary.py. Leave the variable unset to skip the expensive probes.
What a run looks like
I verified this script offline: I ran it against the SDK's real response models (ChatCompletionResponse, and the real chat.parse code path) with a stubbed transport, because a launch-week API key was not available in the build environment. The output below shows the format. The values on your account will differ, and you should treat the first live run as the real verification.
PASS structured {"served_model": "mistral-large-4-0", "parsed": {"vendor": "Brasserie Lumi", "total_eur": 101.0, "due_date": "2026-11-15"}}
PASS tool_call {"args": {"order_id": "A-1182"}}
PASS fingerprint {"note": "baseline recorded", "digests": ["2689367b205c", "..."], "served_models": ["mistral-large-4-0"]}
PASS cache {"cached_tokens_per_call": [0, 1800], "hit": true}
PASS needle_200k {"prompt_tokens": 201344}
A failing run is where the value is. If the vendor updates the model overnight, the fingerprint line flips to FAIL with both digest lists printed side by side, and the structured line tells you whether extraction itself got worse or just got phrased differently.
Worked example: scheduling it
A canary nobody runs is decoration. Two lines of cron give you a daily check, and a failure becomes a message to a human.
# crontab -e (runs 06:15 every day, pings you only on failure)
15 6 * * * cd /srv/canary && MISTRAL_API_KEY=... python canary.py > last_run.log || curl -s -d "Large 4 canary failed" https://ntfy.sh/your-topic
For a team, put the same command in a scheduled CI job and keep baseline.json in the repo, so a baseline change shows up in review like any other behavior change.
Common pitfalls
- Pinning the alias.
mistral-large-latestwill eventually point at something else. Use the dated ID and recordresponse.modelin your own logs. - Treating one fingerprint mismatch as an incident. Non-determinism on a huge MoE model is normal at the margins. Alert on all three digests changing or the served model string changing.
- Reading usage fields by attribute. Cached tokens are an extra, as shown above. Code that does
usage.prompt_tokens_details.cached_tokenscan break on a minor SDK release. - Assuming parse() fails gracefully. In the SDK source,
chat.parsecallsjson.loadson the reply content. If the model ever returns prose, you get a JSON decode error, notparsed=None. The script wraps every check in try/except for exactly this reason. - Mixing the new and old import paths. The 3.x package moved the client under
mistralai.client. Copy-pasted 1.x snippets will not import. - Trusting the sale price. The 50% discount has no published expiry. Budget with the $1.36 / $4.18 list prices until the pricing page says otherwise.
- Ignoring the license. Weights and license terms are both listed as coming soon. Large 3 used Apache 2.0, but nothing published says Large 4 will, so do not build a self-hosting plan on that assumption yet.
Quick reference
| Item | Value |
|---|---|
| API model ID | mistral-large-4 (docs list mistral-large-4-0, version v26.10) |
| Parameters | 1.05T total, 49B active, 1.6B vision encoder |
| Context | 1M advertised; roughly 512K reported by independent evaluators |
| Max output | 256K tokens (per Vals metadata) |
| Intro price / 1M tokens | $0.68 input, $0.07 cached input, $2.09 output |
| List price / 1M tokens | $1.36 input, $0.14 cached input, $4.18 output |
| Preview terms | Silent updates allowed, one month deprecation notice |
| SDK import | from mistralai.client import Mistral (mistralai 3.1.0) |
| Structured output | client.chat.parse(response_format=PydanticModel) then .choices[0].message.parsed |
| Forced tool call | tool_choice="any", parallel_tool_calls=False |
| Cache grouping | prompt_cache_key="..." (hits not guaranteed) |
Next steps
- Replace the invoice with ten real documents from your pipeline and score field-level accuracy instead of a single pass/fail.
- Add a reasoning check: the chat endpoint accepts
reasoning_effortfrom none to xhigh, and a canary for each setting you use will tell you if the cost-quality tradeoff moves. - When the open weights land, run the same script against a self-hosted endpoint by pointing the client at your server URL and compare digests with the API version.
- Wire the exit code into whatever pages you, and re-baseline only after reading the diff.
Sources: Mistral's model overview, function calling, structured output and pricing docs at docs.mistral.ai, the mistralai 3.1.0 Python SDK source, and launch coverage from kingy.ai and RohitAI for the preview terms and independent benchmark figures.
Comments
Be the first to comment
Found this useful?
Get new AI guides for builders by email. Free.
Join 3,605 newsletter subscribers.