Create spreadsheets & documents with Ollama
Run a tool-capable model locally with Ollama and let it create shareable spreadsheets through tool calling. Define the tool, watch for tool_calls in the response, run the API request, and feed the URL back — all while the model runs on your own machine.
import ollama, requests
def create_spreadsheet(title: str, rows: list) -> str:
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"]
resp = ollama.chat(
model="llama3.1",
messages=[{"role": "user", "content": "Make a sheet of Q3 revenue"}],
tools=[create_spreadsheet],
)
for call in resp.message.tool_calls or []:
if call.function.name == "create_spreadsheet":
print(create_spreadsheet(**call.function.arguments))How to create a spreadsheet with Ollama
- 1Run a tool-capable model locally (e.g. ollama run llama3.1).
- 2Pass your Python function in tools= on ollama.chat.
- 3Iterate resp.message.tool_calls and run the matching function.
- 4POST to /api/v1/sheets and use the returned url.
Why use OpenOfficeAI with Ollama
- The model runs locally; only the document API call leaves your machine.
- The Ollama Python lib builds the tool schema from your function.
- Good for private, offline-first agent prototypes.
Frequently asked questions
Which Ollama models support tools?
Tool-capable models like Llama 3.1, Qwen2.5, and Mistral support function calling in Ollama. Check the model card for tool support before relying on it.
Does my data stay local?
The model inference is local. The only outbound call is the HTTPS request to the OpenOfficeAI API to create the shareable document — the rest of the conversation never leaves your machine.
How do I send the result back to the model?
Append a message with role "tool" containing the url, then call ollama.chat again so the model can present the link in natural language.
Start creating documents with Ollama
Free tier includes 500 API calls per month — no card required.