Skip to main content

Drop-in replacement for the Anthropic SDK that silently handles Claude 4.6 breaking changes

Project description

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_formatoutput_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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anthropic_compat-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anthropic_compat-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file anthropic_compat-0.1.0.tar.gz.

File metadata

  • Download URL: anthropic_compat-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for anthropic_compat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 94c3c8590a6534814665acff9b153fc528aa3348480a54bab6825c2bcdc350ab
MD5 a64c09cee87b7fb576c6a702a07386b0
BLAKE2b-256 6fb3d34e74f3259e394ceef7ed227a02d953a758aaa60bc48a555d5df1cdfc48

See more details on using hashes here.

File details

Details for the file anthropic_compat-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for anthropic_compat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c88215c872f83f19fb40456ef364e42535d5ffa75c5b173880fdd1569fe34b30
MD5 8c3c277f719beb35f73b8554ec680902
BLAKE2b-256 1bf9b5496b9efeee42fc8a7af2fa8e42758a28b5674b0a2543d9f6d87315d8ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page