Skip to content

messageContentDetailToGeminiPart

messageContentDetailToGeminiPart(content, client): Promise<Part>

Defined in: .build/typescript/packages/providers/google/src/utils.ts:109

Converts a MessageContentDetail object into a Google Gemini Part object.

This function handles different content types appropriately for the Gemini API:

  • Text content: Directly converts to Gemini text part
  • Image URLs: Extracts MIME type and creates part from URI
  • File/media content: Uploads to Google servers first, then creates part from uploaded URI

MessageContentDetail

The content to be converted (text, image URL, or base64 file data)

GoogleGenAI

Google GenAI client

Promise<Part>

Promise that resolves to a Gemini-compatible Part object

When MIME type cannot be extracted from image URL

When file upload fails

When upload succeeds but URI or MIME type is missing from result