Back Home

AI 開發者平台

Anthropic Python SDK 1.0 Switches to httpx2, Potentially Silently Breaking Existing Tracing and Mocks

The new release raises the minimum Python version to 3.10 and removes Text Completions, several sampling parameters, and the client-side compaction interface. Most standard API calls require no changes, but monitoring, testing, and custom transport layers that depend directly on httpx must be migrated.

Bernou, Claude (b. 16..–d. 17..), Abbot · Public domain · Image source
zh-Hant

Anthropic released version 1.0 of its Python SDK on August 20. The most significant underlying change is the replacement of the httpx HTTP client with httpx2, a compatible fork maintained by the Pydantic team. Applications that only pass ordinary values such as numeric timeouts and retry counts should generally continue to work. Code that constructs its own Client, Timeout, transport, proxy, or event hooks must instead use httpx2 classes. Passing a legacy httpx.Client to the SDK immediately raises a TypeError. However, tools such as OpenTelemetry, Sentry, RESPX, pytest-httpx, or VCR that intercept traffic by patching httpx may continue running without seeing any Claude requests, creating a harder-to-detect observability gap. The official compatibility option is httpx2.alias_httpx(), which applies process-wide, but it must be called before any module imports httpx, and libraries should not enable it on behalf of downstream applications.

This major release also removes several legacy interfaces. The minimum supported runtime has been raised from Python 3.9 to 3.10. client.completions.create(), the legacy Text Completions types, HUMAN_PROMPT, and AI_PROMPT have all been removed. The temperature, top_p, and top_k parameters no longer appear in the formal signatures of Messages methods; when these controls are still required for older models, they can only be sent through extra_body. For asynchronous .with_raw_response calls, parse(), text(), and read() must now be awaited. The tool runner’s client-side compaction_control has also been replaced by server-side context management. Bedrock users who do not configure an AWS Region will now receive an error instead of defaulting to us-east-1.

Engineering teams should not treat this upgrade as a routine dependency update. A safer approach is to remain pinned to 0.x initially, upgrade on a separate branch, and then run type checking, HTTP mock tests, APM trace verification, proxy tests, and enterprise CA tests before validating structured outputs and asynchronous raw-response paths. The official migration guide is comprehensive, but support for httpx2 must still be verified individually across third-party monitoring packages.

Sources

  1. Claude Platform release notes — August 20, 2026
  2. Release v1.0.0 · anthropics/anthropic-sdk-python
  3. anthropic 1.0.0