anthropic-compat
Drop-in fix for the Claude 4.6 breaking change that removed assistant message prefilling.
If your code does this and now gets a 400:
response = client.messages.create(
model="claude-opus-4-6",
messages=[
{"role": "user", "content": "What is 2+2?"},
{"role": "assistant", "content": "The answer is:"},
],
)
Change one import and it works again:
# before
import anthropic
# after
import anthropic_compat as anthropic
That's it. Everything else stays the same — client, methods, exceptions, all of it.
Install
pip install anthropic-compat
What it does
Intercepts prefilled assistant messages before they hit the API and converts them into system prompt instructions. The model still starts its response where your prefill left off.
Also handles the output_format → output_config.format rename so you don't have to.
What it doesn't do
Monkey-patch anything. It wraps the official SDK and passes everything else through untouched.
Metadata
Release files for anthropic-compat 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| anthropic_compat-0.1.0.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| anthropic_compat-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.0 kB
Release files / anthropic_compat-0.1.0.tar.gz
| Download URL | anthropic_compat-0.1.0.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94c3c8590a6534814665acff9b153fc528aa3348480a54bab6825c2bcdc350ab
|
|
BLAKE2b-256 checksum How to use checksums |
6fb3d34e74f3259e394ceef7ed227a02d953a758aaa60bc48a555d5df1cdfc48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / anthropic_compat-0.1.0-py3-none-any.whl
| Download URL | anthropic_compat-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c88215c872f83f19fb40456ef364e42535d5ffa75c5b173880fdd1569fe34b30
|
|
BLAKE2b-256 checksum How to use checksums |
1bf9b5496b9efeee42fc8a7af2fa8e42758a28b5674b0a2543d9f6d87315d8ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|