Gemini can understand and analyze images. You can send images as base64-encoded data within content parts.
Send a base64-encoded image to Gemini for analysis.
Gemini := TsgcHTTP_API_Gemini.Create(nil);
Gemini.GeminiOptions.ApiKey := 'API_KEY';
// Load image and encode to base64
oStream := TFileStream.Create('photo.jpg', fmOpenRead);
Try
oBytes := TBytesStream.Create;
Try
oBytes.CopyFrom(oStream, 0);
vImageBase64 := EncodeBase64(oBytes.Memory, oBytes.Size);
Finally
oBytes.Free;
End;
Finally
oStream.Free;
End;
WriteLn(Gemini._CreateVisionContent('gemini-2.0-flash',
'Describe this image', vImageBase64, 'image/jpeg'));