Clients¶
The two top-level entry points. Construct one per API key and reuse it
for the lifetime of your process — both classes hold an httpx
connection pool and a rate limiter that need to live across requests.
ComplianceClient¶
ComplianceClient ¶
Synchronous client for the Anthropic Compliance API.
Construct a single client per API key and reuse it across calls. The client holds a connection pool and a rate limiter, both of which need to live across requests for full benefit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
A Compliance Access Key ( |
None
|
base_url
|
str
|
Override the API host. Defaults to the Anthropic production host. Useful for testing against a recorded fixture server. |
DEFAULT_BASE_URL
|
timeout
|
float
|
Per-request timeout in seconds. Default 30. |
DEFAULT_TIMEOUT_SECONDS
|
max_download_bytes
|
int
|
Maximum size, in bytes, that the eager
|
DEFAULT_MAX_DOWNLOAD_BYTES
|
max_retries
|
int
|
Maximum retry attempts for 429 and 5xx responses.
Default 3. Set to |
DEFAULT_MAX_RETRIES
|
rate_limit_rpm
|
int
|
Proactive client-side requests-per-minute cap.
Defaults to |
DEFAULT_RATE_LIMIT_RPM
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no API key is supplied through |
Example
close ¶
Close the underlying HTTP connection pool.
Safe to call multiple times. After close() is invoked, the
client must not be reused.
AsyncComplianceClient¶
AsyncComplianceClient ¶
Asynchronous client for the Anthropic Compliance API.
Construct a single client per API key and reuse it across awaits.
Designed to be used as an async context manager so the underlying
httpx.AsyncClient is closed cleanly on exit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
A Compliance Access Key ( |
None
|
base_url
|
str
|
Override the API host. Defaults to the Anthropic production host. |
DEFAULT_BASE_URL
|
timeout
|
float
|
Per-request timeout in seconds. Default 30. |
DEFAULT_TIMEOUT_SECONDS
|
max_download_bytes
|
int
|
Maximum size, in bytes, that the eager
|
DEFAULT_MAX_DOWNLOAD_BYTES
|
max_retries
|
int
|
Maximum retry attempts for 429 and 5xx responses.
Default 3. Set to |
DEFAULT_MAX_RETRIES
|
rate_limit_rpm
|
int
|
Proactive client-side requests-per-minute cap.
Defaults to |
DEFAULT_RATE_LIMIT_RPM
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no API key is supplied through |
Example
aclose
async
¶
Close the underlying async HTTP connection pool.
Safe to await multiple times. After aclose() is awaited, the
client must not be reused.