Skip to main content

Example: an Ask AI function that summarises a small table

Synced from bicycle-studio-api

Source: studio_guide("example-ask-ai") (GET /api/studio/v1/guide/example-ask-ai) rendered at origin/platform (1afd83f), synced 2026-09-28. Do not edit this page here; change the source and run yarn sync:studio.

Build this when an app or a workflow has a few rows of numbers and a person wants one headline and a few bullets. One model call, a strict output shape, a cost cap per call.

Person-only stops: the first publish. A person with publish rights on functions (the owner or an admin) opens the Studio link that function_publish answers and confirms it. A token cannot confirm.

Files​

function.json

{
"schema": "bicycle.function/v1",
"name": "demo_summary",
"kind": "llm",
"title": "Summarise a small table",
"mode": "sync",
"timeout_ms": 30000,
"input_schema": {
"type": "object",
"required": [
"rows"
],
"properties": {
"rows": {
"type": "array",
"maxItems": 50,
"items": {
"type": "object"
}
}
}
},
"output_schema": {
"type": "object",
"required": [
"headline",
"bullets"
],
"additionalProperties": false,
"properties": {
"headline": {
"type": "string"
},
"bullets": {
"type": "array",
"maxItems": 4,
"items": {
"type": "string"
}
}
}
},
"llm": {
"model": "claude-haiku-4-5",
"prompt": "prompts/summary.md",
"effort": "low",
"max_cost_usd": 0.05
},
"visibility": {
"audience": "private",
"expose": {
"apps": true,
"workflows": true,
"agents": false,
"mcp": false
}
},
"docs": {
"summary": "Turns a small table of numbers into a headline and up to four bullets."
},
"capabilities": []
}

prompts/summary.md

You write a short summary of a small table of numbers for a busy manager.

Rows (JSON):
{{input/rows}}

Return:
- `headline`: one sentence, at most 15 words, with the single most important number.
- `bullets`: two to four short bullets. Each names a row and a number from the table.

Use only numbers that appear in the rows. Do not guess causes.

{{input/rows}} is a JSON pointer into the input. capabilities is required even when it is empty.

Calls, in order​

  1. function_models(): the model ids you may name, with a cost column. Pick the cheapest one (claude-haiku-4-5 here).
  2. function_create(name="demo_summary", title="Summarise a small table"): the function exists, with no version yet.
  3. function_put_files(name="demo_summary", files={"function.json": ..., "prompts/summary.md": ...}): version 1, state validated.
  4. function_try(name="demo_summary", n=1, input={"rows": [{"region": "North", "bookings": 1240, "last_week": 1180}, {"region": "South", "bookings": 860, "last_week": 990}, {"region": "East", "bookings": 1510, "last_week": 1495}, {"region": "West", "bookings": 430, "last_week": 610}]}): status succeeded, cost about $0.001, and {"headline": "East leads with 1,510 bookings; ...", "bullets": ["East: 1,510 bookings, up 15 from last week", ...]}. Show the person this answer and ask whether it reads right.
  5. function_publish(name="demo_summary", n=1): "A person must confirm this in Studio before v1 of demo_summary goes live": a link to /<company>/apps/functions/demo_summary?publish=v1, and who may confirm (the owner or an admin, signed in; a token cannot). Give the person the link and stop.

Switch it off​

function_disable(name="demo_summary", reason="no longer needed")

Verified on preview 2026-09-28: function_models, function_create, function_put_files, function_try, function_publish (refusal captured), function_disable ran; invocation ids inv_01M3J6M2CB4VKEJ2PNA9ZNJVZQ.

guide_version bb2461328de4