Cannot send base64 images to Gemini in Mastra v1.0 Beta [Solved]
I scaffolded a new project with
pnpm create mastra@beta.
When I try to use gemini-2.5-flash to analyze images (that are local to my machine and submitted via base64), I get the following error:
I'm able to use @google/genai directly, but I'm trying to learn how to use Mastra.19 Replies
There also seems to be a problem with OpenAI as well. You can see here that there is a duplication of the base64 metadata in the request:
My code is only supplying the base64 string:
iVBORw0KGgoAAAANSUhEUgAACuAAAAdYCAYAAADLvJ3zAAAKsWlDQ1BJQ0M. I've also tried just supplying bytes. But that did not work either.📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10154
🔍 If you're experiencing an error, please provide a minimal reproducible example to help us resolve it quickly.
🙏 Thank you @PaulMest for helping us improve Mastra!
GitHub
Cannot send base64 images to Gemini in Mastra v1.0 Beta · Issue #1...
This issue was created from Discord post 1439883026518507532: I scaffolded a new project with pnpm create mastra@beta. "dependencies": { "@mastra/core": "1.0.0-beta.2"...
Stack Overflow
How to create a Minimal, Reproducible Example - Help Center
Stack Overflow | The World’s Largest Online Community for Developers
I also noticed this issue in my workflows (attempting to communicate with gemini 2.5 flash/pro and sonnet 4.5). I wonder if it's related to the improved support for files in models that was added in the beta. https://github.com/mastra-ai/mastra/releases
GitHub
Releases · mastra-ai/mastra
The TypeScript AI agent framework. ⚡ Assistants, RAG, observability. Supports any LLM: GPT-4, Claude, Gemini, Llama. - mastra-ai/mastra
GitHub
mastra/CONTRIBUTING.md at main · mastra-ai/mastra
The TypeScript AI agent framework. ⚡ Assistants, RAG, observability. Supports any LLM: GPT-4, Claude, Gemini, Llama. - mastra-ai/mastra
Minimum repro:

And this is what it looks like when you use OpenAI

@Romain would you be able to prioritize this? Or suggest any workarounds in the meantime?
It's something here: https://github.com/mastra-ai/mastra/blob/main/packages/core/src/agent/message-list/index.ts#L270C50-L270C83
https://github.com/mastra-ai/mastra/blob/75306f0e0e56861d0fd0c5a90b6c06d00ac8606d/packages/core/src/agent/message-list/index.ts#L2083
Because AI SDK v5 does the transformation internally too: https://github.com/vercel/ai/blob/ce4e273d77573872c0e4ed03202b1b63f85a63ea/packages/openai/src/responses/convert-to-openai-responses-input.ts#L85
GitHub
mastra/packages/core/src/agent/message-list/index.ts at 75306f0e0e5...
The TypeScript AI agent framework. ⚡ Assistants, RAG, observability. Supports any LLM: GPT-4, Claude, Gemini, Llama. - mastra-ai/mastra
GitHub
mastra/packages/core/src/agent/message-list/index.ts at main · mas...
The TypeScript AI agent framework. ⚡ Assistants, RAG, observability. Supports any LLM: GPT-4, Claude, Gemini, Llama. - mastra-ai/mastra
GitHub
ai/packages/openai/src/responses/convert-to-openai-responses-input....
The AI Toolkit for TypeScript. From the creators of Next.js, the AI SDK is a free open-source library for building AI-powered applications and agents - vercel/ai
Hi @paul_validity we'll work on a fix!
I reproduce this on beta.2 but I do not reproduce this on latest
main. I believe we fixed this in https://github.com/mastra-ai/mastra/pull/10122/files and we'll do another beta release tomorrowGitHub
fix(core): download assets by DanielSLew · Pull Request #10122 · ...
Description
We removed the check in a previous PR that would check if there were any assets to be downloaded. Instead of running this logic for all messages always, we only run it if there'...
Is there an easy command to run pnpm create mastra for main?
Hi this was released in 0.x and .beta versions today!
Thank you @Abhi Aiyer !!
I have confirmed that after running
pnpm update that the issue no longer repros. Thanks!It worked for me, @Abhi Aiyer. Thanks for the quick fix
Actually, it seems there's still an issue for images. I got it working for files, but not for images itself
can you share your message maybe?
I think I was probably doing something wrong, or the dev server didn't restart it. Just tried again, and it worked. Sorry @Ward .
Tried passing URL, ArrayBuffer, and all of them worked.
No worries, thanks for verifying
@kessiler AWESOME!!!