AI による在庫不足アラートと発注の提案
エージェントが在庫と 8 週間分の販売実績を読み、まもなく在庫が切れる SKU を挙げて、発注の提案をします。
- 読み取り専用の接続
- スケジュール実行
- コールバック
- 予算の上限
実際の実行を見る
2026年10月7日 の実際の実行を再生しています。モデル: openai/gpt-6-luna。
入力
{
"threshold_days": 14
}成功run_140400c56f2633ed9b2e58f2b62a6e23$0.03 のうち $0.004414
- 待機中予算 $0.03 を確保
- MicroVMmicroVM ready
- MicroVMworker started · shell off · web off
- 接続ops GET /inventory
- 結果
ops GET → 200 - MicroVMmicroVM destroyed
- 成功モデル呼び出し 2 回、トークン 4,167記録された出力(英語)
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.
- ワーカーを破棄$0.004414 を請求、$0.025586 を解放
モデル $0.000814 · Web $0.00 · コンピュート $0.0036
自分で実行する
リクエスト全体が入力された状態で、サンプルをプレイグラウンドで開きます。実行はご自身のアカウントで、表示された予算の範囲内で、同じ読み取り専用のサンプルシステムに対して行われます。
このサンプルの予算: $0.03
仕組み
読み取り専用の在庫 API から、在庫、未処理の注文、リードタイム、週次の販売数を読み、指定されたルールを適用します。回答は購買担当者がそのまま動ける短い表で、検算できるよう数値も示されます。
エージェントにできること、できないこと
権限はリクエストの一部です。ここに挙げていないものは、実行では利用できません。
| 設定 | 許可 |
|---|---|
| 接続 | ops: GET のみ、ephemer.al/api/samples/ops-api へ |
| Web | オフ |
| シェル | オフ |
| ファイル | なし |
| ゼロデータ保持 | オフ: 記録は 30 日間保存されます |
| 予算 | $0.03、厳格な上限 |
| タイムアウト | 60 秒 |
認証情報がマシンに入ることはありません。ブローカーが各呼び出しに認証情報を付与し、上記のメソッドだけを通します。
コード
サンプルが送信する正確なリクエストです。EPHEMERAL_API_KEY には、組織のメンバーキーを設定してください。
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リクエスト本文の全体 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
}このサンプルはスケジュールで実行されます。Europe/Berlin の 0 8 * * 1-5。スケジュールは保存済みのワークフローを開始するため、まずリクエストをワークフローとして保存し、その後スケジュールを作成してください。