Apex Aide apexaide

Gemini AI API with LWC : File Analysis

Salesforce Diaries· ·Intermediate ·Developer ·5 min read
Summary

This piece explains how to analyze video files by integrating Google’s Gemini-2.5-flash AI model directly through Lightning Web Components (LWC) in Salesforce. It showcases a file upload component that sends video data and text prompts to the AI API, then displays the analysis results in Salesforce UI. The approach helps Salesforce teams build capabilities like video interview analysis and meeting summaries by leveraging external LLMs without relying on Agentforce Models API. It highlights security considerations and encourages use of proxies or server-side handling for production use.

Takeaways
  • Use LWC to convert and send video files as base64 to Gemini AI for analysis.
  • Implement text prompts alongside file uploads to guide AI responses.
  • Route API calls through secure proxies to avoid exposing API keys.
  • Handle loading states and error messages in the UI for better UX.
  • Leverage external LLMs in Salesforce apps for tasks like interview analysis and compliance reviews.

File Analysis using Gemini-2.5-flash REST API (Agentforce Models API not required, The API is called directly through the JS, For better security control, Please try to route the call through a proxy server e.g. node js with render or heroku) You can check a working example here about using Agentforce Models API: Agentforce Models API & LWC: File Analysis Caution: While the Agentforce Models API offers built-in security and governance, using a direct public LLM endpoint like Gemini-2.5-flash introduces potential security implications . If you choose this approach, be sure to implement your own guardrails, input validation, and data protection measures . In this tutorial, we’ll explore how to analyze file using public LLMs (like Gemini) via Lightning Web Components (LWC) . This method sends user uploaded files to an external LLM through input prompt and returns AI-generated analysis.

Lightning Web ComponentsAgentforce and AILightning Web Componentaiapijslwcsalesofrce