Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix: use correct MIME type for images in Google serializer

Saurav Panda221d85744e1e
diff --git a/browser_use/llm/google/serializer.py b/browser_use/llm/google/serializer.py
index ff8dce6d0..56622dc91 100644
--- a/browser_use/llm/google/serializer.py
+++ b/browser_use/llm/google/serializer.py
@@ -106,8 +106,11 @@ class GoogleMessageSerializer:
# Decode base64 to bytes
image_bytes = base64.b64decode(data)
+ # Use the media_type from ImageURL, which correctly identifies the image format
+ mime_type = part.image_url.media_type
+
# Add image part
- image_part = Part.from_bytes(data=image_bytes, mime_type='image/jpeg')
+ image_part = Part.from_bytes(data=image_bytes, mime_type=mime_type)
message_parts.append(image_part)