Genkit JS API reference
    Preparing search index...
    • Creates a middleware that falls back to a different model on specific error statuses.

      Parameters

      • ai: HasRegistry
      • options: FallbackOptions

      Returns ModelMiddleware

      Use fallback from the @genkit-ai/middleware package instead.

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