Cannot send base64 images to Gemini in Mastra v1.0 Beta [Solved]

I scaffolded a new project with pnpm create mastra@beta.
"dependencies": {
"@mastra/core": "1.0.0-beta.2",
"@mastra/evals": "1.0.0-beta.0",
"@mastra/libsql": "1.0.0-beta.0",
"@mastra/loggers": "1.0.0-beta.0",
"@mastra/memory": "1.0.0-beta.0",
"@mastra/observability": "1.0.0-beta.0",
"dotenv": "^17.2.3",
"zod": "^4.1.12"
},
"dependencies": {
"@mastra/core": "1.0.0-beta.2",
"@mastra/evals": "1.0.0-beta.0",
"@mastra/libsql": "1.0.0-beta.0",
"@mastra/loggers": "1.0.0-beta.0",
"@mastra/memory": "1.0.0-beta.0",
"@mastra/observability": "1.0.0-beta.0",
"dotenv": "^17.2.3",
"zod": "^4.1.12"
},
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:
error: `Error: Invalid value at 'contents[0].parts[1].inline_data.data' (TYPE_BYTES), Base64 decoding failed for "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACuAAAAdYCAYAAADLvJ3zAAAKsWlDQ1BJQ
error: `Error: Invalid value at 'contents[0].parts[1].inline_data.data' (TYPE_BYTES), Base64 decoding failed for "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACuAAAAdYCAYAAADLvJ3zAAAKsWlDQ1BJQ
execute: async ({ inputData, mastra }) => {
const { screenshots } = inputData;

const agent = mastra.getAgent("gameExtractorAgent");

const imageParts: any[] = screenshots.map(({ base64, mimeType }) => ({
type: "image",
image: base64,
mimeType,
}));

const justOneImage = imageParts.slice(0, 1);

const content: any[] = [
{
type: "text",
text: "Analyze these screenshots and extract all available statistics.",
},
// ...imageParts,
...justOneImage,
];

const result = await agent.generate([{ role: "user", content }], {
structuredOutput: {
schema: gameStatsSchema,
},
});
execute: async ({ inputData, mastra }) => {
const { screenshots } = inputData;

const agent = mastra.getAgent("gameExtractorAgent");

const imageParts: any[] = screenshots.map(({ base64, mimeType }) => ({
type: "image",
image: base64,
mimeType,
}));

const justOneImage = imageParts.slice(0, 1);

const content: any[] = [
{
type: "text",
text: "Analyze these screenshots and extract all available statistics.",
},
// ...imageParts,
...justOneImage,
];

const result = await agent.generate([{ role: "user", content }], {
structuredOutput: {
schema: gameStatsSchema,
},
});
I'm able to use @google/genai directly, but I'm trying to learn how to use Mastra.
19 Replies
PaulMest
PaulMestOP4w ago
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:
"image_url": "data:image/png;base64,data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACuAAAAdYCAYAAADLvJ3zAAAKsWlDQ1BJQ0M
"image_url": "data:image/png;base64,data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACuAAAAdYCAYAAADLvJ3zAAAKsWlDQ1BJQ0M
ERROR [2025-11-17 00:27:58.237 -0800] (Mastra): Error in agent stream
runId: "5039d3b5-84e0-4b0b-af7b-6f3c25810894"
error: {
"message": "Invalid 'input[1].content[0].image_url'. Expected a base64-encoded data URL with an image MIME type (e.g. 'data:image/png;base64,aW1nIGJ5dGVzIGhlcmU='), but got an invalid base64-encoded value.",
"name": "AI_APICallError",
"stack":
AI_APICallError: Invalid 'input[1].content[0].image_url'. Expected a base64-encoded data URL with an image MIME type (e.g. 'data:image/png;base64,aW1nIGJ5dGVzIGhlcmU='), but got an invalid base64-encoded value.
ERROR [2025-11-17 00:27:58.237 -0800] (Mastra): Error in agent stream
runId: "5039d3b5-84e0-4b0b-af7b-6f3c25810894"
error: {
"message": "Invalid 'input[1].content[0].image_url'. Expected a base64-encoded data URL with an image MIME type (e.g. 'data:image/png;base64,aW1nIGJ5dGVzIGhlcmU='), but got an invalid base64-encoded value.",
"name": "AI_APICallError",
"stack":
AI_APICallError: Invalid 'input[1].content[0].image_url'. Expected a base64-encoded data URL with an image MIME type (e.g. 'data:image/png;base64,aW1nIGJ5dGVzIGhlcmU='), but got an invalid base64-encoded value.
My code is only supplying the base64 string: iVBORw0KGgoAAAANSUhEUgAACuAAAAdYCAYAAADLvJ3zAAAKsWlDQ1BJQ0M. I've also tried just supplying bytes. But that did not work either.
Mastra Triager
📝 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
paul_validity
paul_validity4w ago
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
_roamin_
_roamin_4w ago
Hi @paul_validity & @PaulMest ! Could you share a small repro example with us? Thanks!
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
PaulMest
PaulMestOP4w ago
Minimum repro:
1. pnpm create mastra@beta (select Google/Gemini)
2. pnpm dev
3. Attach any local image to the Weather Agent via the Mastra UI
4. See error in UI (attached)
1. pnpm create mastra@beta (select Google/Gemini)
2. pnpm dev
3. Attach any local image to the Weather Agent via the Mastra UI
4. See error in UI (attached)
No description
PaulMest
PaulMestOP4w ago
And this is what it looks like when you use OpenAI
No description
kessiler
kessiler4w ago
@Romain would you be able to prioritize this? Or suggest any workarounds in the meantime?
kessiler
kessiler4w ago
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
Abhi Aiyer
Abhi Aiyer4w ago
Hi @paul_validity we'll work on a fix!
Abhi Aiyer
Abhi Aiyer4w ago
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 tomorrow
GitHub
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'...
PaulMest
PaulMestOP4w ago
Is there an easy command to run pnpm create mastra for main?
Abhi Aiyer
Abhi Aiyer4w ago
Hi this was released in 0.x and .beta versions today!
paul_validity
paul_validity4w ago
Thank you @Abhi Aiyer !!
PaulMest
PaulMestOP4w ago
I have confirmed that after running pnpm update that the issue no longer repros. Thanks!
kessiler
kessiler4w ago
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
Ward
Ward4w ago
can you share your message maybe?
kessiler
kessiler4w ago
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.
Ward
Ward4w ago
No worries, thanks for verifying
Abhi Aiyer
Abhi Aiyer4w ago
@kessiler AWESOME!!!

Did you find this page helpful?