Create spreadsheets & documents with OpenAI Function Calling
Define an OpenAI function (tool) and your GPT model can create real, shareable spreadsheets on its own. The model decides when to call it and supplies the data; your code executes the API request and hands back a link. This is the cleanest way to add document generation to a GPT-powered assistant or a GPT Action.
tools = [{
"type": "function",
"function": {
"name": "create_spreadsheet",
"description": "Create a shareable spreadsheet and return its URL.",
"parameters": {
"type": "object",
"properties": {
"title": {"type": "string"},
"rows": {
"type": "array",
"items": {"type": "array", "items": {"type": "string"}},
"description": "Rows; first row is the header."
}
},
"required": ["title", "rows"]
}
}
}]
# When the model calls create_spreadsheet(title, rows):
import requests
def create_spreadsheet(title, rows):
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"]How to create a spreadsheet with OpenAI Function Calling
- 1Declare a create_spreadsheet function in your tools array with a title + rows schema.
- 2Pass tools to chat.completions / responses and let the model decide to call it.
- 3When the model emits a tool call, run the matching HTTP request to /api/v1/sheets.
- 4Return the url back to the model so it can share the link in its reply.
Why use OpenOfficeAI with OpenAI Function Calling
- The JSON Schema maps 1:1 to the API body — minimal glue code.
- Works for assistants, GPT Actions, and the Responses API.
- Add a create_document function for reports, memos, and contracts.
Frequently asked questions
Can I use this as a GPT Action / custom GPT?
Yes. Expose the OpenOfficeAI endpoint in your Action schema (OpenAPI) with the Bearer auth, and your custom GPT can create spreadsheets and documents directly, returning the shareable link in the conversation.
How do I handle the API key securely with function calling?
The function executes on your server, not in the model. Store the API key in an environment variable and inject it when you run the tool call — the model never sees or needs the key.
What does the model get back?
Your function returns the url string. Feed that back as the tool result and the model will present the shareable spreadsheet link to the user in natural language.
Start creating documents with OpenAI Function Calling
Free tier includes 500 API calls per month — no card required.