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