1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "rawData": [{
10 "timestamp": "2026-02-01T10:00:00Z",
11 "model": "gpt-4o-mini",
12 "prompt_tokens": 500,
13 "completion_tokens": 200,
14 "feature": "chatbot",
15 "user_id": "user123",
16 }],
17 "priceTable": {
18 "gpt-4o": {
19 "inputPer1K": 0.0025,
20 "outputPer1K": 0.01,
21 },
22 "gpt-4o-mini": {
23 "inputPer1K": 0.00015,
24 "outputPer1K": 0.0006,
25 },
26 "claude-3-5-sonnet": {
27 "inputPer1K": 0.003,
28 "outputPer1K": 0.015,
29 },
30 },
31 "anomalyDetection": {
32 "enabled": True,
33 "thresholdMultiplier": 2.5,
34 "groupByFeature": False,
35 },
36 "enforcement": {
37 "enabled": False,
38 "maxDailyCost": 100,
39 "action": "warn",
40 },
41 "idempotency": {
42 "enabled": False,
43 "ttlHours": 168,
44 "allowedLateHours": 48,
45 },
46 "n8n": {
47 "enabled": False,
48 "source": {
49 "type": "raw",
50 "rawEvents": [],
51 },
52 "mapping": {
53 "workflowIdField": "workflowId",
54 "workflowNameField": "workflowName",
55 "nodeIdField": "nodeId",
56 "nodeNameField": "nodeName",
57 "environmentField": "env",
58 "tenantIdField": "tenantId",
59 "userIdField": "userId",
60 "runIdField": "runId",
61 "eventIdField": "eventId",
62 "timestampField": "timestamp",
63 },
64 "defaults": { "environment": "prod" },
65 "derive": {
66 "workflowNameFrom": "workflowId",
67 "nodeIdFrom": "nodeName",
68 "hashPrompt": True,
69 },
70 },
71 "privacy": {
72 "redactIdsInLogs": True,
73 "redactStrategy": "partial",
74 },
75 "retention": {
76 "rawDays": 90,
77 "aggregateDays": 365,
78 },
79 "webhookUrl": "",
80}
81
82
83run = client.actor("quantifiable_bouquet/ai-cost-audit-anomaly-detection").call(run_input=run_input)
84
85
86print("๐พ Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
87for item in client.dataset(run["defaultDatasetId"]).iterate_items():
88 print(item)
89
90