AI low-stock alert with reorder suggestions
An agent reads inventory and eight weeks of sales, flags the SKUs that will run out soon and suggests what to reorder.
- Read-only connection
- Scheduled
- Callback
- Budget cap
Watch a real run
A real run on Oct 7, 2026, replayed. Model: openai/gpt-6-luna.
{
"threshold_days": 14
}- Queuedbudget $0.03 reserved
- MicroVMmicroVM ready
- MicroVMworker started · shell off · web off
- Connectionops GET /inventory
- Result
ops GET → 200 - MicroVMmicroVM destroyed
- Succeeded2 model calls, 4,167 tokensRecorded output (English)
SKU Stock Daily rate (units/day) Days of cover Reorder quantity TEE-BLK-M 64 5.86 10.9 230 CAP-NVY-01 9 1.29 7.0 70 NTBK-A5-01 0 3.54 0.0 0 Human look:
- NTBK-A5-01: Sales fell from 26 to 14 in the latest week while stock is 0; the data doesn’t establish the cause.
- BAG-CNV-01: Sales declined across the last four weeks (8, 6, 5, 4) despite stock of 250.
- Worker destroyed$0.004414 charged, $0.025586 released
Run it yourself
Open the sample in the playground with the whole request filled in. It runs on your own account, within the budget shown, against the same read-only sample systems.
Budget for this sample: $0.03
How it works
It reads stock, open orders, lead times and weekly sales from a read-only inventory API and applies the rule you give it. The answer is a short table a buyer can act on, with the numbers shown so it can be checked.
What the agent can and cannot do
The permissions are part of the request. Anything not listed here is not available to the run.
| Setting | Allowed |
|---|---|
| Connections | ops: GET only, at ephemer.al/api/samples/ops-api |
| Web | Off |
| Shell | Off |
| Files | None |
| Zero data retention | Off: the record is kept for 30 days |
| Budget | $0.03, a hard cap |
| Timeout | 60 seconds |
Credentials never enter the machine: a broker adds them to each call and enforces the methods above.
The code
This is the exact request the sample sends. Set EPHEMERAL_API_KEY to a member key of your organization.
curl -X POST $EPHEMERAL_URL/v1/runs \
-H "Authorization: Bearer $EPHEMERAL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d @request.jsonFull request body workflow.json
The same body, with the files inline.
{
"prompt": "Read GET /inventory on the ops connection. For each SKU, daily_rate is the average of the last 4 values of weekly_sales divided by 7, and days_of_cover is stock divided by daily_rate (treat a daily_rate of 0 as unlimited cover). Flag every SKU whose days_of_cover is below input.threshold_days. For each flagged SKU suggest a reorder quantity: daily_rate times (lead_time_days plus 28), minus stock, minus on_order, rounded up to the next 10, and never below 0 (when stock plus on_order already covers it, the reorder quantity is 0). Reply in Markdown: a table with SKU, stock, daily_rate, days_of_cover and reorder quantity, then one line per SKU that deserves a human look (for example a sales dip caused by a stockout). Use only what the data returns and never guess; if a call fails or a field is missing, say so.",
"connections": {
"ops": {
"type": "http",
"url": "https://ephemer.al/api/samples/ops-api",
"auth": {
"type": "bearer",
"token": "sample_read_key"
},
"allowed_methods": [
"GET"
],
"instructions": "GET /inventory returns as_of, the week start dates, and items with sku, name, stock, on_order, lead_time_days, unit_cost_usd and weekly_sales (units per week, oldest first, the last entry is the most recent week)."
}
},
"shell": false,
"timeout_seconds": 60
}This sample runs on a timetable: 0 8 * * 1-5 in Europe/Berlin. A schedule starts a saved workflow, so save the request as a workflow first, then create the schedule.