> ## Documentation Index
> Fetch the complete documentation index at: https://docs.httpayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTPayerClient

> Initialize HTTPayer client with automatic mode detection

Initialize HTTPayer client with automatic mode detection.
Mode is auto-detected based on credentials:

* "relay" mode: When private\_key or account is provided (self-custodial)
* "proxy" mode: When only api\_key is provided (custodial)

## Signature

```python theme={null}
HTTPayerClient(router_url: Optional = None, api_key: Optional = None, private_key: Optional = None, account: Optional = None, network: Optional = None, timeout: int = 600, use_session: bool = True, strict_networks: bool = True, response_mode: str = 'text', privacy_mode: bool = True)
```

## Parameters

* router\_url: HTTPayer router URL. Defaults to [https://api.httpayer.com](https://api.httpayer.com) or X402\_ROUTER\_URL env var.
* api\_key: API key for proxy mode. Defaults to HTTPAYER\_API\_KEY env var.
* private\_key: Private key for relay mode. Supports EVM (hex), Solana (base58/hex/JSON array).
* account: Pre-configured EVM Account object for relay mode.
* network: Default network for relay payments (e.g., "base", "solana"). Auto-detects to "base" for EVM wallets and "solana" for Solana wallets if not provided.
* timeout: Request timeout in seconds. Defaults to 600 (10 minutes).
* use\_session: Use requests.Session for connection pooling. Defaults to True.
* strict\_networks: Raise error for unsupported networks. Defaults to True.
* response\_mode: Response format - "text" (unwrapped) or "json" (wrapped). Defaults to "text".
* privacy\_mode: Route through HTTPayer relay for privacy. When False, attempts direct x402 payment. Defaults to True.

## Raises

* ValueError: If response\_mode is invalid, private\_key format is invalid, or network is incompatible with wallet type.
* ValueError: If proxy mode is detected but HTTPAYER\_API\_KEY is missing.

## Examples

```python theme={null}
>>> # Proxy mode (API key)
>>> client = HTTPayerClient(api_key="your-api-key")
>>> # Relay mode (EVM private key) - auto-detects network="base"
>>> client = HTTPayerClient(private_key="0x...")
>>> # Relay mode (Solana private key) - auto-detects network="solana"
>>> client = HTTPayerClient(private_key="base58-key")
>>> # Relay mode with explicit network override
>>> client = HTTPayerClient(private_key="0x...", network="base-sepolia")
```
