RouterClient is the main entry point in the SDK.
Constructor
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
chain | SupportedChainName | Yes | None | The chain to settle the payment on. See Supported chains. |
privateKey | 0x${string} | No | None | Builds a signer inside the SDK process. Use this only when in-process private key handling is acceptable. |
signer | PaymentSigner | No | None | A fully constructed signer object. Use this when you want more control or want to keep secrets elsewhere. |
routerUrl | string | No | https://router.selat.ai | Router base URL used to build the proxy request. |
requestTimeoutMs | number | No | 30000 | Request timeout in milliseconds for each router call. |
defaultHeaders | Record<string, string> | No | {} | Headers applied to every request before per-call overrides. |
signer or privateKey.
Returns
| Return value | Type | Description |
|---|---|---|
new RouterClient(...) | RouterClient instance | Creates a client that can send paid requests through selat-router. |
Supported chains
Thechain option selects the chain SELAT settles your payment on. Pass the chain key as a string (the SDK’s SupportedChainName), for example chain: "base".
Payments settle in USDC over Circle Gateway, so the supported set tracks the EVM chains Circle Gateway supports, plus Arc. These keys are confirmed across the SELAT stack:
| Chain | Key | Notes |
|---|---|---|
| Base | base | Default throughout the docs; most widely tested. |
| Optimism | optimism | |
| Arbitrum | arbitrum | |
| Arc | arc | Private-access mainnet (eip155:5042). Requires raw-key signing — Circle’s MPC signer can’t sign Arc yet — and gasless (eco) funding is not available. |
selat fund --method eco.
Circle Gateway supports additional EVM mainnets. For the authoritative list your runtime actually accepts, run:
Methods
fetch(input, init?)
Fetches a target URL through SELAT and returns the final response.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
input | string | Yes | None | The target URL to fetch through SELAT. |
init | RouterFetchOptions | No | {} | Request options forwarded to the router proxy call. |
preferProtocol accepts:
mppx402
Request options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
method | string | No | GET | HTTP method for the target request. |
headers | HeadersInit | No | {} | Headers added to the proxied request. |
body | BodyInit | null | No | None | Request body for POST, PUT, PATCH, or other body-bearing methods. |
signal | AbortSignal | No | None | Cancels the request and any retry flow. |
preferProtocol | "mpp" | "x402" | No | mpp | Hints which paid-rail protocol to prefer. |
Returns
| Return value | Type | Description |
|---|---|---|
client.fetch(...) | Promise<Response> | Resolves to the final upstream Response. If payment is not required, the first response is returned directly. |
createFetch({ baseUrl })
Creates a fetch-like helper for relative paths.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
baseUrl | string | Yes | None | Base URL used to resolve relative paths before routing through SELAT. |
Returns
| Return value | Type | Description |
|---|---|---|
client.createFetch(...) | (path: string, init?: RouterFetchOptions) => Promise<Response> | Returns a fetch-like function bound to the provided base URL. |
Errors
The main configuration and payment flow can raise these public errors:RouterClientConfigErrorQuoteParseError
RouterClientConfigError to catch configuration issues early, such as missing chain or missing signer input.