Skip to content

Conversation

@pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Dec 7, 2025

ai.defineMiddleware(
  'basic-fallback',
  fallback(ai, {
    models: [googleAI.model('gemini-2.5-flash')],
  })
);

ai.defineFlow('basic-hi-with-fallback', async () => {
  const { text } = await ai.generate({
    model: googleAI.model('gemini-2.5-something-that-does-not-exist'),
    prompt: 'You are a helpful AI assistant named Walt, say hello',
    use: ['basic-fallback'],
  });

  return text;
});

Checklist (if applicable):

```ts
ai.defineMiddleware(
  'basic-fallback',
  fallback(ai, {
    models: [googleAI.model('gemini-2.5-flash')],
  })
);

ai.defineFlow('basic-hi-with-fallback', async () => {
  const { text } = await ai.generate({
    model: googleAI.model('gemini-2.5-something-that-does-not-exist'),
    prompt: 'You are a helpful AI assistant named Walt, say hello',
    use: ['basic-fallback'],
  });

  return text;
});
```
@github-actions github-actions bot added go python Python labels Dec 7, 2025
@pavelgj pavelgj requested a review from apascal07 December 7, 2025 16:53
Base automatically changed from pj/middleware-with-options to main December 10, 2025 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant