Skip to content

data: string in an input_image message item does not work with some providers #708

@raventos

Description

@raventos

Bug for @openai/agents-extensions
Version: Introduced after 0.1.0 (works in 0.1.0, broken in newer versions)

Description:
When using input_image with a URL (e.g., Gemini Files API URI), the image fails to process with the error:
AI_APICallError: Invalid value at 'contents[0].parts[0].inline_data.data' (TYPE_BYTES), Base64 decoding failed for "https://generativelanguage.googleapis.com/v1beta/files/..."

Root Cause:
In aiSdk.js, the input_image handler changed from:

// v0.1.0 (correct)
data: url,  // passes URL object

to:

// newer version (broken)
data: url.toString(),  // converts to string

This breaks @ai-sdk/google which checks part.data instanceof URL to decide between fileData.fileUri (correct) vs inlineData.data (incorrect for URLs).

Expected: Gemini API receives fileData: { fileUri: "https://..." }
Actual: Gemini API receives inlineData: { data: "https://..." } → base64 decode fails
Workaround: Pin to @openai/[email protected]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions