> Originally published on IndieSeek.
Anthropic Python SDK 1.0: migrate HTTP, raw responses, and compaction without blind spots
Quick answer
Anthropic Python SDK 1.0.0, released on August 20, 2026, is a real migration release. It requires Python 3.10 or later, moves the transport layer from httpx to httpx2, removes the legacy Text Completions surface and several deprecated arguments, changes raw-response consumption, replaces client-side tool-runner compaction with server-side context management, and stops silently choosing us-east-1 for Bedrock.
Do not begin with a package-wide find-and-replace. Inventory the exact surfaces your application uses, upgrade in a locked branch, and verify observability before traffic. The most dangerous failure is not necessarily a crash: tracing or HTTP mocks that patch httpx can silently stop seeing Anthropic requests after the SDK starts using httpx2.
Who this is for
This guide is for Python teams calling the Claude Messages API directly, using custom transports or proxies, consuming .with_raw_response, running tool loops with compaction, or routing through Amazon Bedrock. It also helps maintainers whose tests rely on respx, pytest-httpx, vcrpy, OpenTelemetry, or Sentry.
If you are also moving saved prompts away from retired Claude surfaces, use the Workbench-to-Playground migration checklist. This page focuses on the Python runtime contract.
What changed—and how it fails
| Surface | v1 behavior | Likely failure |
|---|---|---|
| Runtime | Python 3.10+ | Resolver or deployment failure on Python 3.9 |
| HTTP layer | Custom clients, transports, timeouts, request/response types come from httpx2
|
Construction TypeError, broken type checks, or invisible traces/mocks |
| Raw responses | Sync text/content are methods; async parse/read/text/json must be awaited | Coroutine leakage or runtime misuse |
| Message calls | Legacy completions and deprecated method parameters are removed | Import, attribute, or argument TypeError
|
| Tool compaction | Use server-side context_management
|
Long tool loops lose the intended compaction boundary |
| Bedrock | A region must resolve explicitly | Construction-time ValueError instead of implicit us-east-1
|
The official migration guide also changes raw byte bodies, header merging, streaming type checks, structured-output schema placement, and unknown Bedrock streaming events. Treat the table as triage, not a complete substitute for the upstream guide.
A failure-ordered migration workflow
1. Freeze a reversible baseline
Record Python, anthropic, httpx, proxy, tracing, mock, model, API route, and cloud-provider versions. Capture one successful Messages response, request ID, trace, mocked test, tool-loop checkpoint, and Bedrock region before changing the lockfile.
Upgrade with an explicit major range:
python -m pip install --upgrade "anthropic>=1,<2"
python -m pip check
Run the project on every supported Python image. A local Python 3.12 success does not prove that an older CI or serverless image meets the new 3.10 floor.
2. Inventory removed surfaces before running tests
Use a repository scan to turn runtime surprises into an edit list:
rg -n 'client\.completions|HUMAN_PROMPT|AI_PROMPT|temperature=|top_p=|top_k=|compaction_control|with_raw_response|AnthropicBedrock|import httpx'
Move legacy completions to client.messages.create(). Remove sampling arguments from generated Messages methods unless an older pinned model still needs them through extra_body. Put raw structured-output schemas under output_config; keep output_format=ModelClass only where the helper expects a model type.
3. Choose one httpx2 integration strategy
If only the Anthropic client needs HTTP customization, import httpx2 directly and construct every client, transport, timeout, proxy, request, and response type from it. This is the narrowest change.
If application-wide tracing or mocking still patches httpx, call httpx2.alias_httpx() at the very beginning of the application or an early pytest plugin—before anything imports httpx. Do not put this global alias inside a reusable library; the upstream guide explicitly assigns that decision to the application.
Then run a payload-free positive control with httpx2.MockTransport: return a synthetic Messages response, assert that exactly one request reached /v1/messages, and assert that the trace or mock recorded it. A successful API call without the expected trace is a failed migration.
4. Repair raw-response consumers
For an async client, response metadata remains ordinary attribute access, but body operations are asynchronous:
response = await client.messages.with_raw_response.create(...)
request_id = response.headers["request-id"]
message = await response.parse()
body = await response.read()
For a sync client, use response.parse(), response.text(), and response.read(). Search for stored .text or .content attributes; those old access patterns can survive type-blind tests and fail only on the affected path.
5. Move compaction and Bedrock configuration explicitly
Replace tool-runner compaction_control with the server-side compaction beta and context_management. The official example uses compact-2026-01-12 and requires an input-token trigger of at least 50,000. Re-run a long disposable tool loop and prove that the checkpoint appears, the task resumes, and no tool result is duplicated. The Claude agent memory migration guide provides a broader persistence boundary.
For Bedrock, set aws_region, AWS_REGION, AWS_DEFAULT_REGION, or a configured profile. Add a negative canary that clears all region sources and expects a ValueError; then add a positive canary that records the intended region without making a paid model call.
6. Canary the edge contracts
Before production traffic, verify seven gates:
- Python 3.10+ resolves and imports the locked SDK.
- A custom
httpx2transport receives one synthetic Messages request. - Tracing and HTTP mocks see the same request after the transport migration.
- Sync and async raw-response paths parse bodies with their new contracts.
- Removed completions, prompt constants, and method arguments are absent from the codebase.
- A long tool loop compacts and resumes without duplicate tool effects.
- Missing Bedrock region fails closed; the configured region matches the deployment.
Also verify duplicate header casing, byte-valued headers, low-level raw bodies, and any isinstance(..., anthropic.Stream) checks if your code uses those uncommon surfaces.
Decision tree
Does the app pass custom httpx objects or patch httpx globally?
no -> use SDK defaults; still verify tracing and raw responses
yes -> can only Anthropic-specific code change?
yes -> import httpx2 directly
no -> alias at the application entry point before any httpx import
Does the app use removed APIs or helper arguments?
yes -> migrate each call and replay its fixture
no -> continue
Do all seven canaries pass with evidence?
no -> keep v0 locked and repair the failed surface
yes -> canary a small traffic slice, then promote
Common mistakes
- Treating an HTTP 200 as proof that tracing, mocks, and retries still work.
- Calling
httpx2.alias_httpx()after a framework has already importedhttpx. - Preserving removed sampling parameters without checking the pinned model contract.
- Fixing async
parse()but leaving old.textor.contentattribute reads. - Replacing client compaction without replaying a long tool loop and its side effects.
- Letting Bedrock choose a region through ambient developer credentials that production does not have.
- Upgrading the lockfile and production image together without a rollback artifact.
Copyable acceptance record
python / anthropic / httpx2 / lock digest:
runtime image / provider / model / API route:
custom client / proxy / transport / alias strategy:
trace canary / mock canary / request-id captured:
sync raw response / async raw response:
removed-surface scan result:
compaction trigger / resume / duplicate-effect result:
bedrock region source / missing-region negative canary:
traffic slice / error delta / rollback artifact:
decision: hold | canary | promote | rollback
FAQ
Must every application call httpx2.alias_httpx()?
No. Use direct httpx2 objects when the change can stay inside your Anthropic integration. The global alias is mainly for application-level tooling that patches httpx and must observe the new transport.
Did the Claude API remove temperature, top_p, and top_k?
The v1 generated Messages methods removed those parameters. Anthropic's migration guide says older models that still honor them can receive them through extra_body. Verify the exact model contract instead of assuming either universal removal or universal support.
Is 1.0.0 safe because the version is stable?
The release is stable, but your integration may depend on removed or silently changed surfaces. Promote only after transport observability, raw responses, tool-loop state, and provider configuration pass in your environment.
Sources
- Claude Platform release notes: Python SDK v1.0
- Anthropic Python SDK
v1.0.0release - Official Python SDK v1 migration guide
- Anthropic Python SDK source at
v1.0.0 - PyPI metadata for
anthropic==1.0.0 - Anthropic SDK issue #1755:
httpx2migration request
Read the maintained version on IndieSeek.
Top comments (0)