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.

Input
{
  "threshold_days": 14
}
Succeededrun_140400c56f2633ed9b2e58f2b62a6e23$0.004414 of $0.03
  1. Queuedbudget $0.03 reserved
  2. MicroVMmicroVM ready
  3. MicroVMworker started · shell off · web off
  4. Connectionops GET /inventory
  5. Resultops GET → 200
  6. MicroVMmicroVM destroyed
  7. Succeeded2 model calls, 4,167 tokensRecorded output (English)
    SKUStockDaily rate (units/day)Days of coverReorder quantity
    TEE-BLK-M645.8610.9230
    CAP-NVY-0191.297.070
    NTBK-A5-0103.540.00

    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.
  8. Worker destroyed$0.004414 charged, $0.025586 released
Model $0.000814 · Web $0.00 · Compute $0.0036

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.

SettingAllowed
Connections
ops: GET only, at ephemer.al/api/samples/ops-api
WebOff
ShellOff
FilesNone
Zero data retentionOff: the record is kept for 30 days
Budget$0.03, a hard cap
Timeout60 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.json
Full request body workflow.json

The same body, with the files inline.

workflow.json
{
  "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.

Read more

Related samples

esc

Nothing matches “”.