Genkit JS API reference
    Preparing search index...

    Variable fallbackConst

    fallback: GenerateMiddleware<typeof FallbackOptionsSchema> = ...

    Creates a middleware that falls back to a different model on specific error statuses.

    const { text } = await ai.generate({
    model: googleAI.model('gemini-2.5-pro'),
    prompt: 'You are a helpful AI assistant named Walt, say hello',
    use: [
    fallback({
    models: [googleAI.model('gemini-2.5-flash')],
    statuses: ['RESOURCE_EXHAUSTED'],
    }),
    ],
    });