Switching from Anthropic’s Claude to **Google’s Gemini AI** is super easy and FREE! Here’s how you can do it:
1. Install the Package:
Instead of `@ai-sdk/anthropic`, install `@ai-sdk/google`:
npm install @ai-sdk/google
2. Configure Gemini AI:
Use the `createGoogleGenerativeAI` function to set it up:
import { createGoogleGenerativeAI } from "@ai-sdk/google";
const google = createGoogleGenerativeAI({
apiKey: process.env.GEMINI_API_KEY,
});
3. Choose Your Model:
Select a model like this:
const model = google("gemini-2.0-flash");
4. Get Your API Key
5. That’s It!
The rest of your code stays the same -- just swap out the configurations.
If you need help, drop a comment below.