Integrations/Gemini Function Calling
AI Agent

Create spreadsheets & documents with Gemini Function Calling

Declare a function for Google Gemini and the model can create shareable spreadsheets on its own. Gemini returns a function call with the arguments; your code runs the API request and feeds the URL back. Works with the Google GenAI SDK.

Gemini (google-genai, Python)
from google import genai
from google.genai import types
import requests

def create_spreadsheet(title: str, rows: list) -> str:
    """Create a shareable spreadsheet; returns a URL."""
    r = requests.post("https://openofficeai.com/api/v1/sheets",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        json={"title": title, "sheets": [{"rows": rows}]})
    return r.json()["url"]

client = genai.Client()
resp = client.models.generate_content(
    model="gemini-2.0-flash",
    contents="Make a sheet of Q3 revenue",
    config=types.GenerateContentConfig(tools=[create_spreadsheet]),
)
print(resp.text)

How to create a spreadsheet with Gemini Function Calling

  1. 1Define a typed Python function with a docstring.
  2. 2Pass it in tools= on GenerateContentConfig.
  3. 3The SDK auto-calls the function when Gemini requests it.
  4. 4Gemini incorporates the returned url into its reply.

Why use OpenOfficeAI with Gemini Function Calling

Frequently asked questions

Do I need to write a JSON schema by hand?

No. The Google GenAI SDK builds the function declaration from your Python function's type hints and docstring. Just pass the function in the tools list.

How do I control when Gemini calls it?

Use the function-calling mode in the tool config (AUTO, ANY, or NONE). AUTO lets Gemini decide; ANY forces a tool call when appropriate.

Can I run multiple tools?

Yes. Add more functions to the tools list — for example, create_spreadsheet and create_document — and Gemini will pick the right one.

Start creating documents with Gemini Function Calling

Free tier includes 500 API calls per month — no card required.