Safe automation for AI agents that call paid APIs
Keep agents read-only by default, keep secrets out of logs, and on hosted MCP send an idempotency_key, preview with dry_run, and cap with max_spend_usd.

To let an AI agent call Sume's paid APIs safely, keep exploration read-only, make every credit-spending action explicit, and keep API keys, OAuth tokens, and signed URLs out of logs and chat. On Sume's hosted MCP server, that also means an idempotency_key on each write or paid call, a dry_run cost preview before an expensive burst, and max_spend_usd when you want a cap.
The rules below come from Sume's Safe automation, MCP tools and gates, and MCP OAuth and API keys docs pages.
How should an agent authenticate?
Generation and analysis creation can spend credits, so agent tools should make those actions explicit and keep read-only operations separate. Sume's hosted MCP server accepts OAuth access tokens or Sume API keys, and they are not interchangeable credentials.
Prefer OAuth mcp:read for read-only exploration. Write is a toggle on the consent screen, off by default; grant mcp:write (or use an API key) before paid tools such as generate_image or avatars_create. There is no mcp:paid scope: spend is wallet/admission. Client setup is in Connect Claude Code, Cursor, or Codex to Sume.
| Session auth | What the agent sees and can call |
|---|---|
OAuth mcp:read only | Read-only tools. Mutating and paid calls return insufficient_scope. |
OAuth mcp:read + mcp:write | Full hosted tool set. Paid submits still need idempotency_key and wallet/admission. |
| API key | Full hosted tool set. Same idempotency_key / admission rules. |
Which safety gates apply to paid calls?
Mutating and paid tools stay hidden until the session has mcp:write or an API key. Once they are visible, these gates apply. See also Idempotency keys for AI video APIs and Spend caps for unattended AI agents.
| Gate | Required? | Meaning |
|---|---|---|
idempotency_key | Required on write and paid tools | Stable key for transport/dedup, not human approval. |
dry_run=true | Optional | Admission/cost preview only; the job is not submitted. |
max_spend_usd | Optional | Enforced only when provided. |
allow_write / allow_paid | Optional (legacy) | Accepted for back-compat, not required. Cannot bypass a missing mcp:write scope. |
How do I preview cost before an agent spends?
Before expensive bursts, call generation_admission_preview or the paid tool with dry_run=true; ordinary single creates do not need that step. The docs playbook for inspecting a tool before paying:
- Call
tools_schemawithname: "generate_image"(oravatars_create). Always discover the live contract; do not assume HTTP API parity. - Call
generation_admission_preview, or the paid tool withdry_run=true. - Confirm the estimate, balance, and queue behavior.
- Submit with a fresh
idempotency_keyon a session that hasmcp:writeor an API key. Addmax_spend_usdwhen you want a cap.
What does a paid call look like?
This payload follows the docs playbook for a paid avatar create, which is for use only when the user explicitly confirms spend. Call first with dry_run: true and review the preview, then repeat with dry_run omitted or false to submit. Poll with jobs_status / jobs_wait, then read jobs_result.
{
"idempotency_key": "avatar-create-001",
"dry_run": true,
"max_spend_usd": 2,
"payload": {
"avatar_handle": "studio_presenter",
"input": {
"type": "prompt",
"prompt": "A friendly studio presenter in neutral lighting"
}
}
}Can an agent batch paid calls under the same gates?
Yes, with script_run. It runs a short JavaScript program on the Sume side that calls tools in a loop, in parallel, or conditionally, and returns one value. Each call inside it has the same gates, redaction and errors as a direct call, and paid creates still need their own idempotency_key. The run is bounded by timeout_seconds (5–55), max_calls, and max_paid_calls.
How do I keep secrets and workspaces safe?
API keys and app sessions determine the workspace. Tools should not accept user-supplied workspace ids unless the product explicitly supports switching workspaces. In agent reports, prefer Sume public ids and media.sume.com URLs.
- An MCP OAuth token is not a Sume API key.
- Do not store OAuth tokens in CLI config, paste them into prompts, or forward them to third-party providers.
- Do not mint API keys for hosted OAuth clients as a workaround.
- Do not paste signed URLs, OAuth tokens, or API keys into chat logs. Rotate API keys if they appear in logs or chat history.
| Safe logs include | Unsafe logs include |
|---|---|
| Request ids | API keys |
| Job ids, when needed | Signed URLs |
| High-level status | Raw private media URLs |
| Sanitized media metadata | Excessive user content or transcripts |
Sources
Related posts
More in Agents
- Scheduled AI video agent runs: cron, API triggers, and receipts
A Sume schedule is a saved Agents automation that runs on a cron cadence and returns a run receipt. Author it in the dashboard; start and monitor runs by API.
- What is a video agent? How Sume defines and runs one
In Sume's docs, a video agent is a sandbox Agent that composes generation tools into a post-ready video. Brief it in chat, or call it over HTTP.
- Sume Agent Completions vs Format vs Scheduled runs: request body diff
Sume Format runs, Scheduled runs, and Agent Completions share field names, not rules: spend-cap defaults, null, on_active_run, attachments, and scopes differ.
- MCP tool call timeouts on long-running video jobs: use jobs_wait
On Sume's hosted MCP server, one jobs_wait call holds at most 55 seconds. Wait out long video jobs in slices, batch up to 20 ids, and never resubmit.
Written by Sume