# Fallback Providers (/advanced/fallback-providers)

> For the complete documentation index, see [llms.txt](/llms.txt)



<Callout type="info">
  Impatient?  Check out [a complete example here](https://github.com/zerodevapp/zerodev-examples/blob/main/fallback-clients/main.ts).
</Callout>

ZeroDev aggregates multiple bundler and paymaster services to provide the highest possible reliability to our users.  You can set up "fallbacks" so that when one of the services fails, another takes over.

## API [#api]

Start by creating multiple account clients:

```ts
// Get these from your ZeroDev dashboard
const PAYMASTER_RPC = 'your ZeroDev paymaster RPC'
const BUNDLER_RPC = 'your ZeroDev bundler RPC'

const PAYMASTER_RPC_ALCHEMY = PAYMASTER_RPC + '?provider=ALCHEMY'
const BUNDLER_RPC_ALCHEMY = BUNDLER_RPC + '?provider=ALCHEMY'

const PAYMASTER_RPC_PIMLICO = PAYMASTER_RPC + '?provider=PIMLICO'
const BUNDLER_RPC_PIMLICO = BUNDLER_RPC + '?provider=PIMLICO'

// Create an account client with alchemy as provider
const kernelClient1 = createKernelAccountClient({
    account,
    chain,
    bundlerTransport: http(BUNDLER_RPC_ALCHEMY),
    client: publicClient,
    paymaster: {
        getPaymasterData: ( userOperation ) => {
            const zeroDevPaymasterClient = createZeroDevPaymasterClient({
                chain,
                transport: http(PAYMASTER_RPC_ALCHEMY),
            })
            return zeroDevPaymasterClient.sponsorUserOperation({
                userOperation,
            })
        }
    },
    entryPoint
})

// Create an account client with pimlico as provider
const kernelClient2 = createKernelAccountClient({
    account,
    chain,
    bundlerTransport: http(BUNDLER_RPC_PIMLICO),
    client: publicClient,
    paymaster: {
        getPaymasterData: ( userOperation ) => {
            const zeroDevPaymasterClient = createZeroDevPaymasterClient({
                chain,
                transport: http(PAYMASTER_RPC_PIMLICO),
            })
            return zeroDevPaymasterClient.sponsorUserOperation({
                userOperation,
            })
        }
    },
})
```

Then combine the Kernel clients with the `createFallbackKernelAccountClient` function:

```ts
const kernelClient = createFallbackKernelAccountClient([
    kernelClient1,
    kernelClient2,
])
```

Now you can use `kernelClient` as usual.  Your `kernelClient` will use `kernelClient1` by default, and if it runs into any issues with it, it will fallback to `kernelClient2`.

## Using non-ZeroDev infra as fallbacks [#using-non-zerodev-infra-as-fallbacks]

In the previous example, we used different providers as fallbacks through ZeroDev.  If you are worried that ZeroDev itself might go down, you can also sign up directly with providers like Pimlico and set them up as fallback providers.

To do that, simply:

* [Set up a Kernel account client with Pimlico](/api-and-toolings/infrastructure/pimlico).

Then combine them with `createFallbackKernelAccountClient`:

```ts
const kernelClient = createFallbackKernelAccountClient([
    zerodevKernelClient,
    pimlicoKernelClient,
])
```
