1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "auditCapsule": {
12 "schema": "audit-capsule/1.0",
13 "runId": "run_demo_001",
14 "durationMs": 18260,
15 "events": [
16 {
17 "schema": "runtime-event/1.0",
18 "eventId": "evt_1",
19 "runId": "run_demo_001",
20 "timestampMs": 1757000000000,
21 "type": "MODEL_CALL",
22 "nodeId": "planner",
23 "nodeType": "AGENT",
24 "provider": "anthropic",
25 "model": "claude-sonnet-5",
26 "inputTokens": 2100,
27 "cachedInputTokens": 0,
28 "cacheWriteTokens": 46000,
29 "outputTokens": 520,
30 "latencyMs": 2140,
31 "status": "SUCCESS"
32 },
33 {
34 "schema": "runtime-event/1.0",
35 "eventId": "evt_2",
36 "runId": "run_demo_001",
37 "timestampMs": 1757000004200,
38 "type": "MODEL_CALL",
39 "nodeId": "researcher",
40 "nodeType": "AGENT",
41 "provider": "anthropic",
42 "model": "claude-sonnet-5",
43 "inputTokens": 1400,
44 "cachedInputTokens": 46000,
45 "cacheWriteTokens": 0,
46 "outputTokens": 880,
47 "latencyMs": 1310,
48 "status": "SUCCESS"
49 },
50 {
51 "schema": "runtime-event/1.0",
52 "eventId": "evt_3",
53 "runId": "run_demo_001",
54 "timestampMs": 1757000009600,
55 "type": "MODEL_CALL",
56 "nodeId": "researcher",
57 "nodeType": "AGENT",
58 "provider": "anthropic",
59 "model": "claude-sonnet-5",
60 "inputTokens": 1900,
61 "cachedInputTokens": 46800,
62 "cacheWriteTokens": 0,
63 "outputTokens": 640,
64 "latencyMs": 1180,
65 "status": "SUCCESS"
66 },
67 {
68 "schema": "runtime-event/1.0",
69 "eventId": "evt_4",
70 "runId": "run_demo_001",
71 "timestampMs": 1757000014800,
72 "type": "MODEL_CALL",
73 "nodeId": "writer",
74 "nodeType": "AGENT",
75 "provider": "anthropic",
76 "model": "claude-sonnet-5",
77 "inputTokens": 49300,
78 "cachedInputTokens": 0,
79 "cacheWriteTokens": 0,
80 "outputTokens": 1240,
81 "latencyMs": 3460,
82 "status": "SUCCESS"
83 }
84 ]
85 }
86};
87
88
89const run = await client.actor("truesoft/ai-agent-cost-token-savings-auditor").call(input);
90
91
92console.log('Results from dataset');
93console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
94const { items } = await client.dataset(run.defaultDatasetId).listItems();
95items.forEach((item) => {
96 console.dir(item);
97});
98
99