Skip to content

ProAndMax/anthropic-compat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Support

If this saved you time, consider buying me a coffee.

→ Support on Polar.sh

About

Drop-in fix for Claude 4.6 removing assistant message prefilling

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages