[PAID] 🧠 Gemini Extension to interact with the Gemini-pro model from Google

This is an example of how to use Gemini Vesion API with thermer chat extension

See the video :

The blocks :

New Update _gemini.aix

  1. Two old blocks of "single block response & streaming response" merged into this single block with new argument of isStreaming: boolean

  1. Two blocks were added to make it easy and fast to ask the model one single question without continuous chat, unlike the previous function GenerateGeminiContent block that enables you to create continuous chat :

Can you please provide all features in one message

All Gemini extension features

  • Text Generation :

    • Simple Chat : Provides a basic Ask function for simple text-in, text-out conversations.

    • Advanced Generation : A powerful GenerateGeminiContent function that supports both single-turn and multi-turn conversations, system instructions, and optional tools.

    • Streaming : Offers streaming versions of all major generation functions (StreamGenerateGeminiContent, StreamGenerateGroundedContent, etc.) that provide the response in real-time chunks.

  • Image Understanding (Vision) :

    • Simple Image Queries : An AskWithImage block to ask questions about a single image.

    • Multi-Modal Analysis : The ability to send multiple images, videos, audio files, PDFs, and text in a single prompt for comprehensive analysis.

    • Multiple Input Sources : Accepts files from local paths, Base64 encoded strings, content URIs, and public URLs (for PDFs and images).

    • YouTube Video Analysis : Can analyze content directly from a public YouTube URL (including Shorts) when provided with a prompt.

  • Image Generation & Editing :

    • Text-to-Image : GenerateImage function to create an image from a text description.

    • Image Editing : EditImage and EditImageFromPath functions to modify an existing image based on a text prompt.

    • Multi-Image Editing : EditMultipleImagesSimple function to process a prompt against a list of images from various sources (URLs, paths, Base64).

  • Audio Understanding :

    • Can process local audio files (e.g., MP3, WAV) as part of a prompt to be analyzed by the model.
  • Video Understanding :

    • Can process local video files as part of a prompt, allowing the AI to analyze the video's content frame-by-frame.
  • Text-to-Speech (TTS) :

    • Single Speaker : GenerateSingleSpeakerSpeech function to convert text into speech using a specified prebuilt voice.

    • Multi-Speaker : GenerateMultiSpeakerSpeech function to create dialogue with multiple distinct voices from a structured script.

Advanced Features & Tools

  • Structured Output (JSON) :

    • Users can provide a JSON Schema to force the model to return its answer in a structured JSON format, making it easy to parse and use data in the app. This is supported by multiple functions.

    • Includes a CreateJsonSchema helper block to easily build the required schema.

  • Google Search Grounding :

    • The StreamGenerateGroundedContent function can be enabled to have the model perform a Google search to ground its response in real-world information, providing source links for its claims.
  • Code Execution :

    • The model can be given the ability to generate and execute code (like Python) to solve complex problems, with the results returned in the response.
  • File API Integration :

    • Efficient File Uploads : Includes robust functions to upload large files (like videos) directly to Google's servers. This is highly efficient as the file is processed on the server and referenced by a URI, avoiding the need to send the full file with every request.

    • File Management : Provides blocks to get detailed metadata (UploadFileAndGetMetadata) and the direct download link (GetFileContentUri) for uploaded files.

    • Reusability : Uploaded files can be reused in multiple API calls by referencing their URI.

Events and Callbacks

The extension is event-driven, providing specific events to handle different outcomes:

  • General Responses : RespondedToGemini (for single responses), GotGeminiStream (for each piece of a streaming response), and StreamFinished.

  • Image & Audio Generation : GotImageResponse (returns Base64 image data and a saved file path) and GotSpeechAudio (returns Base64 audio and a saved file path).

  • File Uploads : FileUploadProgress (provides real-time progress for large uploads) and FileUploadComplete / GotFileMetadata (fires when a file is uploaded and processed, returning its URI and details).

  • Error Handling : A robust ErrorOccurred event that provides detailed error messages for easier debugging.

  • API Key Validation : APIKeyValid, APIKeyInvalid, and APIKeyCheckError events to confirm if the provided API key works.

  • Grounding Sources : GotGroundingInfo event that returns a list of source URLs and titles when using Google Search.

Utility and Helper Functions

  • File Encoding : Multiple blocks to encode various file types (images, videos, PDFs) into Base64 format.

  • Path Conversion : A GetFilePathFromURI function to handle file paths provided by components like the Activity Starter or File Picker.

  • Permission Handling : Blocks to check for and request the necessary storage permissions on Android.

  • Image Display : A DisplayBase64Image helper to easily display a Base64 string in an Image component.

  • Model Management : A GetGeminiModelNames function to retrieve a list of all available models for the user's API key.

  • Favicon Fetcher : A simple utility to get the URL for a website's favicon.

Configuration

  • Designer Properties : The extension allows setting key parameters directly in the MIT App Inventor designer, including:

    • API Key and default Model Name.

    • Generation controls: Temperature, Top P, Top K, and Max Output Tokens.

    • Safety settings: Category and Threshold for content moderation.

Which gemini model needs to be used to access all features

There is no model that can access all features

  • For General Analysis (Text, Chat, Vision, Audio, Video):

    • Use Gemini 1.5 Pro or Gemini 2.5 Pro . This covers most of the extension's features. For a faster alternative, use Gemini 1.5 Flash .
  • For Generating and Editing Images:

    • Use an Imagen model (e.g., imagen-4).
  • For Generating Speech (Text-to-Speech):

    • Use a Gemini TTS model (e.g., gemini-2.5-flash-preview-tts).

I'm excited to share a major update to the Gemini extension!

We've just added a powerful new feature: Image Editing . To celebrate, we are also introducing our most powerful and a-peeling model yet: the Nano Bananana AKA gemini-2.5-flash-image-preview model!

Now you can perform powerful image edits directly within your App Inventor projects. Take a look:

We are very excited to see what you can create with this new functionality.

Happy Inventing

Gemini 3 pro is here this is the game changer!

Major Update: Function Calling & Files API Integration! :rocket:

Hello App Inventors!

We are thrilled to announce a game-changing update for the Gemini extension. This version transforms Gemini from a simple chatbot into a powerful AI Agent capable of controlling your app, while also giving you massive upgrades in file and image handling.

What's New?

Demo :

1. Function Calling: Turn Gemini into an Android Agent :robot:

The biggest feature in this update is Function Calling. You can now teach Gemini how to use tools within your app!

Instead of just returning text, Gemini can intelligently decide to trigger events in your app based on the user's conversation.

How it Works (The Tool Loop):

  1. Send Request: You provide a prompt ("Give me the weather in Egypt") and a list of tools your app has.
  2. Tool Needed: Gemini realizes it can't answer directly, so it asks you to run the get_weather tool.
  3. Execution: Your app runs the function (e.g., gets data from a weather API).
  4. Returning Data: You send the result (e.g., "30°C, Sunny") back to Gemini using SendFunctionResponse.
  5. Completion: Gemini uses that data to give a final natural language answer: "The weather in Egypt is 30°C and Sunny."

Example Declaration: Here is how you define a function for Gemini using the functionDeclarations parameter:

[

{

"name": "get_weather",

"description": "this function job to get weather status for specific location",

"parameters": {

"type": "object",

"properties": {

"location": {

"type": "string"

}

},

"required": [

"location"

],

"propertyOrdering": [

"location"

]

}

}

]

Key Blocks:

  • DeclareFunctions: Define the available tools (like the JSON above).
  • FunctionCallRequested (Event): Fires when Gemini wants to perform an action.
  • SendFunctionResponse: Return the action's result back to the model.

2. Files API & Hybrid Image Engine :open_file_folder:

We've completely overhauled how files and images are handled to eliminate size limits and boost performance.

:high_voltage: Hybrid Image Engine

  • Smart Switching: Small images (< 4MB) are processed instantly. Large images (> 4MB) automatically use the Files API.
  • No More Limits: Send full-resolution 20MB+ raw photos without crashing your app!

:card_index_dividers: Full Files API Control

Manage your AI's knowledge base dynamically:

  • UploadFile: Upload PDFs, Audio, Video, or Images to Gemini's cloud storage.
  • ListUploadedFiles: View what's stored in your project.
  • AskWithFile / AskWithUploadedFiles: "Read this PDF" or "Watch this video" and answer questions about it.
  • DeleteFile: Manage your storage quota programmatically.

(Add a screenshot here of the new file management blocks)


Why Update?

  • Build Agents: Create smart home assistants, personal schedulers, or data analysis bots that actually do things.
  • Stable & Fast: The new image engine prevents "Payload Too Large" and Out-Of-Memory errors.
  • Multimodal Power: Analyze huge documents and long videos with ease.

PAID_file

Price: 5.99$ not 7$ for limited period
Purchase: PayPal Link or You can pay HERE using your credit card
In both cases after payment, you'll be redirected to the download URL. Contact me for any help or issues.

Happy Coding! :robot::sparkles:

Hi everyone,
I'm working on v2 of the Gemini Extension, and I want to make sure it covers your specific use cases.
Instead of just asking for features, I want to know: What kind of AI app are you trying to build right now?
Are you building a chatbot assistant?
An educational app for homework help?
A tool to generate marketing text?
If you tell me what you are building, I can add the specific blocks or parameters to make that easier for you. Let me know in the comments!

Hi,

I am trying to convert a camera photo to Base64, I used EncodeImageToBase64 block and it always returns nothing. Could you please help me? Thank you very much!

Use block of replace part and replace this part “file://” from the path and then path it againg to the encoder block again


:rocket: Huge Update: The Gemini 3 & 3.1 Series is Now Supported!

Hello everyone!

Google has just rolled out the massive Gemini 3 and 3.1 series, and I've updated the extension's model roster so you can start integrating these cutting-edge models into your apps immediately.

Whether you need advanced reasoning, cost-efficient high-volume text generation, or lightning-fast image processing, the new lineup has you covered.

Here are the official API model names you can now plug directly into the modelName parameter block:

  • Gemini 3.1 Pro (Preview): gemini-3.1-pro-preview
    • Best for: Complex problem-solving, advanced reasoning, and tasks requiring deep logic.
  • Gemini 3 Flash (Preview): gemini-3-flash-preview
    • Best for: Frontier-class performance rivaling larger models, but at a fraction of the cost.
  • Gemini 3.1 Flash-Lite (Preview): gemini-3.1-flash-lite-preview
    • Best for: High-volume, low-latency tasks where cost efficiency is the top priority (replaces the older 2.5 Flash-Lite).
  • Gemini 3.1 Flash Image (Preview): gemini-3.1-flash-image-preview
    • Best for: High-efficiency, production-scale image generation and editing.

:rocket: [MAJOR UPDATE] Gemini Extension: Context Caching & Real-Time Streaming! :brain::high_voltage:

Hello Kodular Community! :waving_hand:
I am super excited to announce a massive update to the Gemini Extension. We are introducing Context Caching and a Complete Streaming Workflow!

If you are building AI apps that need to process massive documents (PDFs, large System Instructions, Books), this update will make your app blazing fast and drastically reduce your API costs.

Here is the complete documentation for the new workflow:


:brain: What is Context Caching?

  • The Context: This is your massive file or huge System Instructions that you want the AI to read and answer questions from.
  • Context Caching: Instead of sending this huge text with every single question, you upload it once to Google's servers. Google gives you a unique cacheName.
  • After that, your app only sends the user's short question + the cacheName. The model answers instantly via Streaming (word-by-word) saving you time and tokens!

:counterclockwise_arrows_button: The Full Blocks Cycle (Complete Workflow)

The process consists of 4 simple stages:
[1: Init] ➔ [2: Create Cache] ➔ [3: Ask & Stream] ➔ [4: Error Handling]

:pushpin: Stage 1: Initialization (Screen Initialize)

Enable auto-caching so you don't have to manage the cache name manually:

  • set Gemini1.EnableAutoCaching to true ➔ Automatically attaches the active cache to incoming questions.
  • set Gemini1.CacheTTLMinutes to 30 ➔ Keeps the data alive on Google's servers for a specific time (e.g., 30 minutes).

:pushpin: Stage 2: Cache Creation (Upload Once)

Run this once per session to upload the huge context (Must be > 1,024 Tokens):

  • Block: call Gemini1.CreateContextCache (or CreateContextCacheWithContents for files).
  • Event: when Gemini1.GotContextCache (cacheName, expireTime)
    • What happens: Fires when Google finishes saving your data. The extension automatically saves the cacheName in the background. You can show a message to your user here: "Data is ready, ask me anything!"
      image

:pushpin: Stage 3: Asking & Real-Time Streaming

When the user sends a message:

  1. Send Request: call Gemini1.StreamGenerateGeminiContent
    • Leave systemInstructionsValue empty (it's already cached!). The extension handles the cache name automatically.
  2. Receive Stream: when Gemini1.GotGeminiStream (text)
    • What happens: This fires continuously with every new word/character! Use it to update your Label: join(Label1.Text, text).
  3. Stream Finished: when Gemini1.StreamFinished
    • Fires when the AI is completely done generating the answer.

:pushpin: Stage 4: Error Handling & Cleanup

  • when Gemini1.ErrorOccurred ➔ Catches any issues (e.g., text is less than 1024 tokens) without crashing your app.
  • call Gemini1.DeleteContextCache ➔ (Optional) Deletes the cache immediately from Google's servers when the user exits the screen.

Create the cache once (CreateContextCache) ➔ Wait for the ready event (GotContextCache) ➔ Ask & get real-time answers (StreamGenerateGeminiContent + GotGeminiStream) continuously at super speed and low cost!

You can get extension for here

I can't wait to see what you will build with this! Let me know your thoughts below. :backhand_index_pointing_down:

:rocket: [UPDATE] Next-Gen AI is Here: Welcome 3.7 Flash & 3.8 Flash! :high_voltage:

Hello AI2 Community! :waving_hand:

Following our massive Context Caching update, I am thrilled to announce that we are keeping this extension at the absolute cutting edge of AI technology.

Today, we are officially bringing the newest and fastest models directly into your blocks!

:sparkles: What’s New in this Update?

  • Added Support for 3.7 Flash: Lightning-fast responses with highly optimized token processing.
  • Added Support for 3.8 Flash: The ultimate balance of high-speed performance and advanced reasoning capabilities.

Why does this matter?
If you are building apps that require instant AI replies, real-time data processing, or utilizing our new Streaming features, these new "Flash" models will make your applications feel incredibly snappy and significantly reduce latency.

:hammer_and_wrench: How to use them:
It’s perfectly seamless! Just update your modelName text block to "3.7-flash" or "3.8-flash" (make sure to use the exact API string required), and you are good to go!
Get the Extension form here

This is the App Inventor community
Taifun

1 Like

Thanks for note :smiling_face: