AI で週次 KPI レポートを自動化する
毎週月曜日に、スケジュール実行されるエージェントが先週の登録数、アクティブユーザー、売上、解約を読み、前週比つきの短いレポートを書きます。
- 読み取り専用の接続
- スケジュール実行
- コールバック
- 予算の上限
実際の実行を見る
2026年10月7日 の実際の実行を再生しています。モデル: openai/gpt-6-luna。
入力
{
"period": "last_week"
}成功run_aed198aa926e2dba4128e136978b6768$0.025 のうち $0.002442
- 待機中予算 $0.025 を確保
- MicroVMmicroVM ready
- MicroVMworker started · shell off · web off
- 接続analytics GET /metrics?period=last_week
- 結果
analytics GET → 200 - MicroVMmicroVM destroyed
- 成功モデル呼び出し 2 回、トークン 2,479記録された出力(英語)
Weekly business report — 2026-W40
- Signups: 294 (+98)
- Active users: 2,803 (+282)
- Revenue: $22,853.85 (−$546.85)
- Churned accounts: 8 (no change)
- ワーカーを破棄$0.002442 を請求、$0.022558 を解放
モデル $0.000242 · Web $0.00 · コンピュート $0.0022
自分で実行する
リクエスト全体が入力された状態で、サンプルをプレイグラウンドで開きます。実行はご自身のアカウントで、表示された予算の範囲内で、同じ読み取り専用のサンプルシステムに対して行われます。
このサンプルの予算: $0.025
仕組み
エージェントは読み取り専用の接続で分析 API を読み、チャットやメールに投稿できる 150 語以内のレポートを書きます。スケジュールには専用のタイムゾーンを設定できます。1 回の実行にかかるコストは 1 セントの何分の一かです。
エージェントにできること、できないこと
権限はリクエストの一部です。ここに挙げていないものは、実行では利用できません。
| 設定 | 許可 |
|---|---|
| 接続 | analytics: GET のみ、ephemer.al/api/samples/analytics-api へ |
| Web | オフ |
| シェル | オフ |
| ファイル | なし |
| ゼロデータ保持 | オフ: 記録は 30 日間保存されます |
| 予算 | $0.025、厳格な上限 |
| タイムアウト | 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": "Write the weekly business report for input.period. Call GET /metrics?period=<input.period> on the analytics connection and use only what it returns. Reply in Markdown, at most 150 words: a one-line headline, then signups, active users, revenue in dollars and churned accounts, each with the change from the week before. If the call fails, say so instead of estimating.",
"connections": {
"analytics": {
"type": "http",
"url": "https://ephemer.al/api/samples/analytics-api",
"auth": {
"type": "bearer",
"token": "sample_read_key"
},
"allowed_methods": [
"GET"
],
"instructions": "GET /metrics?period=last_week or period=2026-W40 returns signups, active_users, revenue_cents and churned_accounts for that ISO week, with the same figures for the week before. Amounts are in cents."
}
},
"shell": false,
"timeout_seconds": 60
}このサンプルはスケジュールで実行されます。Asia/Tokyo の 0 9 * * 1。スケジュールは保存済みのワークフローを開始するため、まずリクエストをワークフローとして保存し、その後スケジュールを作成してください。