GPT-6.1 Sol function calling to start a Sume Agent Completion safely

Expose one function that starts an Agent Completion. Let GPT-6.1 Sol fill instruction and input, and keep the spend cap and idempotency key out of its args.

5 min readSume
All posts

Give the model a function whose parameters are only the creative fields, and add the money fields yourself. OpenAI's model page lists function calling as supported for GPT-6.1 Sol. The function schema should hold instruction and input. Your handler adds generation_spend_cap_usd, which Agent Completions require, and an Idempotency-Key that you derive.

Which side owns which field

Keep untrusted text in input, since Sume gives input to the agent as caller data, not as instructions. Put only your own wording in instruction.

Function arguments and handler fields (read 2026-10-05)
FieldOwnerNote
instructionModel, from your templateShort and specific
inputModelCaller data from the user
generation_spend_cap_usdHandlerRequired, no default
Idempotency-Key headerHandlerOne per tool call id
import os
import requests


def start_completion(call_id: str, args: dict, cap_usd: float) -> str:
    r = requests.post(
        "https://api.sume.com/v1/agent/completions",
        headers={"Authorization": f"Bearer {os.environ['SUME_API_KEY']}",
                 "Idempotency-Key": f"call-{call_id}"},
        json={"instruction": args["instruction"], "input": args.get("input", {}),
              "generation_spend_cap_usd": cap_usd},
        timeout=30,
    )
    r.raise_for_status()
    return r.json()["data"]["status_url"]

Return a pointer, not the media

Return the status_url to the model as the tool result, and poll it in your own loop. Do not let the model poll in a tight loop, since each turn has its own cost.

Check the docs before you ship

Sume's limits and field names change faster than blog posts do. Read the linked docs pages for the current request fields before you ship, and send a dry_run or a low spend cap on your first real call.

Sources

Related posts

More in Integrations

All Integrations posts

Written by Sume