# 用戶端 (https://nolantw.github.io/cwa/reference/clients/)

## `CWA`

```python
CWA(api_key: str | None = None, *, timeout: float | None = None, retries: int = 3, cache: bool | None = None, max_concurrency: int = 8, http_client: httpx2.Client | None = None)
```

同步用戶端。以 `with` 管理生命週期，授權碼由 `api_key` 參數或環境變數 `CWA_API_KEY` 提供。回應預設快取於用戶端記憶體，`cache=False` 可停用；傳入的 `http_client` 不由 SDK 快取或關閉。

### `CWA.close`

```python
def close() -> None
```

關閉用戶端並釋放 HTTP 資源。

## `AsyncCWA`

```python
AsyncCWA(api_key: str | None = None, *, timeout: float | None = None, retries: int = 3, cache: bool | None = None, max_concurrency: int = 8, http_client: httpx2.AsyncClient | None = None)
```

非同步用戶端。以 `async with` 管理生命週期，查詢時使用 `await`。回應預設快取於用戶端記憶體，`cache=False` 可停用；傳入的 `http_client` 不由 SDK 快取或關閉。

### `AsyncCWA.aclose`

```python
async def aclose() -> None
```

關閉非同步用戶端並釋放 HTTP 資源。