Ai-fy
Ai-fy3mo ago

Convex ai-agent with Gemini?

Hi, i just wanted to convert my convex ai-agent to use Gemini instead of openai, but it seems that this is not supported, am i right? Can't find anything in the documentation.
3 Replies
Convex Bot
Convex Bot3mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Emil
Emil2mo ago
Hey. did you find a solution?
Sara
Sara2mo ago
It should work just fine with any AI supported by the AI SDK, just do something like this (this is not latest, but it does the trick)
import { google } from '@ai-sdk/google';
// don't forget the Agent imports
export const mainAgent = new Agent(components.agent, {
chat: google.chat('gemini-2.0-flash-001'),
textEmbedding: google.textEmbeddingModel(`text-embedding-004`),
contextOptions: {
recentMessages: 20,
searchOtherThreads: true,
},
storageOptions: {
saveAllInputMessages: true,
saveAnyInputMessages: true,
saveOutputMessages: true,
},
maxSteps: 10,
});
import { google } from '@ai-sdk/google';
// don't forget the Agent imports
export const mainAgent = new Agent(components.agent, {
chat: google.chat('gemini-2.0-flash-001'),
textEmbedding: google.textEmbeddingModel(`text-embedding-004`),
contextOptions: {
recentMessages: 20,
searchOtherThreads: true,
},
storageOptions: {
saveAllInputMessages: true,
saveAnyInputMessages: true,
saveOutputMessages: true,
},
maxSteps: 10,
});

Did you find this page helpful?