# Fallback Providers (/sdk/v5_3_x/advanced/fallback-providers)

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



<VersionWarning version="5.3.x" />

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

When you use ZeroDev, you can pick [a specific infrastructure provider](/api-and-toolings/infrastructure/rpcs#bundler-rpc).  If you don't pick one, we pick one for you.

However, sometimes an infra provider may experience downtime.  We have developed a "fallbacks" feature that allows you to set up multiple providers, so that when one 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),
    middleware: {
        sponsorUserOperation: async ({ userOperation }) => {
            const zeroDevPaymasterClient = createZeroDevPaymasterClient({
                chain,
                transport: http(PAYMASTER_RPC_ALCHEMY),
                entryPoint
            })
            return zeroDevPaymasterClient.sponsorUserOperation({
                userOperation,
                entryPoint
            })
        }
    },
    entryPoint
})

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

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](/sdk/v5_3_x/infra/pimlico).

Then combine them with `createFallbackKernelAccountClient`:

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