Back to Blog
2025-12-15 6 min read

A One Script Guide to FileMaker and Gemini Integration

Introduction

Integrating sophisticated AI models into custom applications is no longer a complex, out-of-reach endeavor. For FileMaker developers, the platform's native support for web service integration provides a direct path to leveraging powerful large language models like Google's Gemini. This guide explains the architectural pattern and provides a practical, step-by-step example of how to connect your FileMaker solution to the Gemini API.

The goal is to empower your applications with features like text summarization, content generation, or data analysis by making a simple, secure API call.

The Architectural Concept

Before writing any code, it is crucial to understand the process. We are teaching our FileMaker application to communicate with an external web service--in this case, the Google Gemini API. This is accomplished by sending a structured request and then receiving and parsing a structured response.

The key components of this interaction are:

  1. API Endpoint: This is the specific URL provided by Google where the Gemini model is listening for requests.
  2. API Key: A unique secret key that authenticates our request, proving we have permission to use the service.
  3. JSON Payload: The data we send to the API, formatted in JavaScript Object Notation (JSON). This payload contains the text we want the model to process.
  4. cURL Options: A set of instructions for the HTTP request, specifying the method (POST), the content type (application/json), and the authentication headers.

FileMaker handles this entire exchange using the Insert from URL script step. The response from the API is also JSON, which we can easily parse using FileMaker's native JSON functions.

Implementation: A Text Summarizer

This example will demonstrate how to send a block of text to the Gemini API and receive a concise summary.

Prerequisites

You must have a Google Gemini API key. You can obtain one for free from Google AI Studio. Always treat your API key as a secure credential--never expose it on the client side in a production environment.

1. Schema Setup

In your FileMaker solution, create a table (e.g., "AI_Requests") with the following text fields:

  • InputText: To hold the source text you want to summarize.
  • Prompt: To define the task for the AI (e.g., "Summarize this text in one paragraph").
  • API_Response_Raw: To store the complete JSON response from the API.
  • API_Response_Parsed: To store the extracted, clean text from the response.

2. The Script

Create a new script, named Call Gemini API - Summarize Text. This script will orchestrate the entire process.

# Set Variables
Set Variable [ $apiKey ; Value: "YOUR_API_KEY_HERE" ]
Set Variable [ $endpoint ; Value: "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" ]

# --- Construct the JSON Payload ---
# Combine the user's prompt and input text into a single instruction.
Set Variable [ $fullPrompt ; Value: AI_Requests::Prompt & ":¶" & AI_Requests::InputText ]
Set Variable [ $jsonPayload ; Value:
    JSONSetElement ( "" ;
        [ "contents[0].parts[0].text" ; $fullPrompt ; JSONString ]
    )
]

# --- Configure cURL Options ---
Set Variable [ $curlOptions ; Value:
    "-X POST" &
    " -H \"Content-Type: application/json\"" &
    " -H \"x-goog-api-key: " & $apiKey & "\"" &
    " -d @$jsonPayload"
]

# --- Make the API Call ---
Insert from URL [ Select ; With dialog: Off ; Target: AI_Requests::API_Response_Raw ; URL: $endpoint ; cURL options: $curlOptions ]

# --- Parse the Response ---
# The response contains the summarized text nested within a few JSON keys.
Set Variable [ $parsedText ; Value:
    JSONGetElement ( AI_Requests::API_Response_Raw ; "candidates[0].content.parts[0].text" )
]

Set Field [ AI_Requests::API_Response_Parsed ; $parsedText ]
Commit Record/Requests[With Dialog: Off]

Script Explanation

  1. Variables: We first set the API Key and the endpoint URL. The URL for the Gemini Pro 2.5 model's generateContent method is used here.
  2. JSON Payload: The Gemini API expects a specific JSON structure. The JSONSetElement function builds this structure. We create a contents array containing one object, which in turn has a parts array. The text we want to process is placed inside the text key. This example combines a predefined prompt with the user's input text.
  3. cURL Options: We configure the Insert from URL step.
    • -X POST: Specifies that we are sending data.
    • -H "Content-Type: application/json": Informs the API that our data is in JSON format.
    • -H "x-goog-api-key: " & $apiKey & "\"": Passes the API Key to the endpoint.
    • -d @$jsonPayload: Sets the body of our request to the content of the $jsonPayload variable.
  4. Insert from URL: This is the core script step that executes the API call. It sends the $jsonPayload to the $endpoint using the specified $curlOptions and places the entire server response into the API_Response_Raw field.
  5. Parse Response: The API does not return just the summarized text; it returns a larger JSON object. We use JSONGetElement to drill down into the object (candidates -> content -> parts -> text) to extract the generated summary and place it in the API_Response_Parsed field.

Trade-offs and Considerations

  • Security: The API key should be stored securely, ideally not directly in a client-side script. For multi-user solutions, consider using a server-side script ("Perform Script on Server") and storing the key in a secure table or retrieving it from a key management service.
  • Cost: API calls are often metered and have an associated cost. Monitor your usage through your Google Cloud account to avoid unexpected expenses. I recommend using older or lite models if they are enough to fulfill your needs. You don't need to use Gemini 3 Pro to summarize text. Even a Gemini 1.5 Pro Lite would probably be sufficient for this example case.
  • Error Handling: The provided script is a minimal example. A production-ready script should include error handling to check for empty responses or API error codes from the Insert from URL step.
  • Performance: Direct API calls can introduce latency. If a script performs a long-running AI task, it can freeze the user interface. Use "Perform Script on Server" to run the process in the background for a better user experience. If you are on the latest FileMaker, use Perform Script on Server with Callback to streamline the user experience ever better.

Conclusion

By using native FileMaker tools, you can build a robust and seamless integration with one of the world's most powerful AI models. This architectural pattern--build JSON, send via cURL, parse JSON is not limited to Gemini. This is a fundamental technique for connecting your FileMaker applications to a vast ecosystem of external web services and APIs, opening up limitless possibilities for adding intelligent and automated features.

Resources

A One Script Guide to FileMaker and Gemini Integration | Jeffrey Henry