Anthropic SDK for Python 2
Last reviewed Oct 24, 2026
Prompt Details
Prompt Composition
2prompts
- Python 3155 lines · 3.8K tokens
- Anthropic SDK for Python 256 lines · 3K tokens
Total211 lines · 6.8K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 73
- 78
- 79
- 89
- 95
- 117
- 201
- 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
- 807
- 829
- 862
- 916
- 918
- 1104
- 1333
- 1395
- 1426
- 1427
Prompt Preview
Apply to the anthropic Python SDK 2.x and the SDK features used by this application. Apply the included Python baseline; the SDK's Python 3.10 minimum does not establish interpreter security support. Check beta interfaces against the installed SDK before using them. Do not assume a locked SDK minor receives a separate patch stream; review current upstream release notes when assessing fixes.
Client identity and outbound requests
- Construct
AnthropicorAsyncAnthropicwith a deliberate credential source. Explicitapi_key,auth_token,credentials,config, andprofileare mutually exclusive; environment static keys precede discovered profiles and workload identity, andANTHROPIC_API_KEYwins overANTHROPIC_AUTH_TOKENwhen both are set. Remove unintended static credentials when federation or a token is intended. A credential passed tocopy()orwith_options()replaces the client's own, along with the base URL and headers its profile supplied; check the derived client's destination and identity. - The client sends
api_keyasAuthorization: Bearer, the same header asauth_token. Redact and readAuthorizationin log filters, middleware, proxies, gateways and test stubs, not onlyX-Api-Key. SettingX-Api-Keythroughextra_headersordefault_headersdoes not replace the client's key, so both credentials go out; usewith_options(api_key=...)or a separate client for a different key. - Keep
ANTHROPIC_CONFIG_DIR, profile files, credential files and identity-token files private and deployment-controlled. Never let a request select a