## TL;DR

Upgrade to ai21 SDK v4.0.0 or later, which added Python 3.13 support, per the maintainers. The situation: On Python 3.13, pip install ai21 (or uv add ai21) failed because one of the SDK's pinned dependencies, sentencepiece==0.2.0, did not support Python 3.13 yet.

## Steps

1. On Python 3.13, pip install ai21 (or uv add ai21) failed because one of the SDK's pinned dependencies, sentencepiece==0.2.0, did not support Python 3.13 yet. The reporter hit this on Windows 11, but the dependency pin was the cause regardless of OS. The AI21 maintainers shipped Python 3.13 support in SDK v4.0.0.

2. What actually fixes it (verified in the thread):

3. This was fixed upstream. The blocker was the sentencepiece==0.2.0 pin, which had no Python 3.13 support. Upgrade to ai21 SDK v4.0.0 or later, which added Python 3.13 support, per the maintainers. Source: https://github.com/AI21Labs/ai21-python/issues/293

## When to use

You are seeing this: The blocker was the sentencepiece==0.2.0 pin, which had no Python 3.13 support. Use this skill when you run into "ai21 SDK installation fails on Python 3.13 (sentencepiece==0.2.0 has no 3.13 support)".

## 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: sentencepiece 0.2.0, SDK v4.0.0. 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.

## Sources

- https://github.com/AI21Labs/ai21-python/issues/293
