Skip to main content
Unified request interface that handles 402 Payment Required responses automatically. First attempts a direct request to the target URL. If it returns 402, automatically handles payment through the appropriate flow (relay or proxy) and returns the resource.

Signature

Parameters

  • method: HTTP method (GET, POST, PUT, DELETE, etc.).
  • url: Target API URL to access.
  • simulate: If True, only simulate payment without executing (dry-run). Defaults to False.
  • response_mode: Override response format (“text” or “json”). Uses instance default if not specified.
  • network: Override network for relay mode payments.
  • **kwargs: Additional request arguments. Common options:
    • json: JSON payload (forwarded through HTTPayer payment flow)
    • params: Query parameters (forwarded through HTTPayer)
    • headers: Custom headers (forwarded through HTTPayer)
    • timeout: Request timeout override (forwarded through HTTPayer)
    • Other kwargs (data, files, auth, cookies, etc.) are only used for the
  • initial direct request attempt and NOT forwarded through HTTPayer payment flow.

Returns

Response from the target API. If 402 is encountered, returns response after payment.

Raises

  • ValueError: If network is incompatible with wallet type or not supported.

Examples