vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
9.98k stars 1.48k forks source link

feat: ability to define fallback model / provider #2636

Open nicoalbanese opened 2 months ago

nicoalbanese commented 2 months ago

Feature Description

It would be helpful to be able to define "fallback" models / providers when building AI applications.

ie. if primary provider (x) errors out, revert to provider (y).

Use Case

No response

Additional context

No response

namanyayg commented 2 months ago

+1, need this as well.

I coded it myself in the meanwhile tho.

JimmyLv commented 2 months ago

+1

sylviangth commented 1 month ago

+1

john-dw commented 1 month ago

+1

aviramroi commented 1 month ago

+!

wong2 commented 1 week ago

@lgrammel Any plan to implement this? I think it would be great to integrate it into the AI SDK.

sahanatvessel commented 3 days ago

@namanyayg keen to know what you did

lgrammel commented 2 days ago

@wong2 unsure when/how we are going to add this. the ideal solution imo requires a proxy layer bc you wan to monitor ai provider uptime across many requests in a potentially distributed system and switch more intelligently. the solution I would suggest in the interim is to use a custom middleware.