## TL;DR

The real fix shipped in mistralai 1.5.2 (PR #206 updated the client types), confirmed by the maintainer. So update to 1.5.2 or newer and the type error goes away.

## Steps

1. In the mistralai Python SDK (1.5.1), `client.files.upload(file={...}, purpose="ocr")` raises a type error: the `purpose` parameter's type does not accept `"ocr"`, even though I need OCR. The upload itself works if I bypass the type check. Is `purpose="ocr"` unsupported?

2. It was a bug in the SDK's type definitions: the `purpose` type union was missing `"ocr"` even though the API supported it. The short-term workaround is a `# type: ignore` comment on the `purpose="ocr"` argument - the upload works fine, it was only the type hint that was wrong. The real fix shipped in mistralai 1.5.2 (PR #206 updated the client types), confirmed by the maintainer. So update to 1.5.2 or newer and the type error goes away.

## When to use

You are seeing this: In the mistralai Python SDK (1.5.1), client.files.upload(file={...}, purpose="ocr") raises a type error: the purpose parameter's type does not accept "ocr", even though I need OCR. Use this skill when you run into "mistralai Python SDK: `files.upload(purpose="ocr")` fails its own type check".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: 1.5.1, mistralai 1.5.2. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
