Anthropic SDK for Python 1.3
Last reviewed Sep 12, 2026
Prompt Details
Prompt Composition
2prompts
- Python 3155 lines · 3.8K tokens
- Anthropic SDK for Python 1.3131 lines · 3.7K tokens
Total286 lines · 7.5K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 78
- 79
- 89
- 95
- 117
- 208
- 209
- 214
- 250
- 295
- 319
- 328
- 338
- 347
- 367
- 379
- 409
- 416
- 426
- 427
- 459
- 470
- 488
- 502
- 532
- 611
- 639
- 674
- 732
- 770
- 772
- 776
- 798
- 807
- 829
- 862
- 916
- 918
- 922
- 1104
- 1333
- 1395
- 1426
- 1427
Prompt Preview
Apply the Python 3 baseline first, then these rules for applications built on the anthropic package 1.3 release line. The 1.x line requires Python 3.10 or later and sends requests through httpx2 rather than httpx. Confirm each rule against the exact 1.3 release you deploy, and treat every model output — text, tool arguments, and generated files — as untrusted data produced from a context an attacker may have influenced.
Version scope and upgrade from 0.x
- Pin
anthropicto a 1.3 release and run it on Python 3.10 or later, which the 1.x line requires. - Import transports, timeouts, and custom clients from
httpx2; passing a client from the separatehttpxpackage tohttp_clientraisesTypeError. - Remove
temperature,top_p, andtop_kfrom Messages calls, because 1.x deleted those parameters instead of ignoring them. - Replace the removed schema-dict
output_formatargument withoutput_config={"format": {...}}when moving structured-output code onto 1.x; typed helpers still acceptoutput_format=MyModel. - Delete every
client.completions.create()path, since 1.x removed the legacy Text Completions API entirely. - Await
.parse(),.read(),.text(), and.json()on anAsyncAPIResponse, and use.text()for text and.read()for bytes rather than reading them as properties. - Send header values as
strwith one casing per name, because 1.x matches header names case-insensitively and no longer acceptsbytesvalues. - Pass an explicit region to
AnthropicBedrockandAsyncAnthropicBedrock, which raiseValueErrorat construction when