1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "schema": {
10 "type": "object",
11 "required": [
12 "sku",
13 "name",
14 "price",
15 "inStock",
16 ],
17 "additionalProperties": False,
18 "properties": {
19 "sku": {
20 "type": "string",
21 "pattern": "^[A-Z]{3}-\\d{4}$",
22 },
23 "name": {
24 "type": "string",
25 "minLength": 1,
26 },
27 "price": {
28 "type": "number",
29 "minimum": 0,
30 },
31 "inStock": { "type": "boolean" },
32 "status": {
33 "type": "string",
34 "enum": [
35 "active",
36 "discontinued",
37 ],
38 },
39 },
40 },
41 "items": [
42 {
43 "sku": "ABC-1234",
44 "name": "Widget",
45 "price": 9.99,
46 "inStock": True,
47 "status": "active",
48 },
49 {
50 "sku": "ABC-5678",
51 "name": "Gizmo",
52 "price": "$19.99",
53 "inStock": "yes",
54 "status": "Active",
55 },
56 {
57 "sku": "nope",
58 "name": "",
59 "price": -3,
60 "hallucinatedField": "invented by the model",
61 },
62 ],
63}
64
65
66run = client.actor("broomwagon/llm-output-guard").call(run_input=run_input)
67
68
69print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
70for item in client.dataset(run.default_dataset_id).iterate_items():
71 print(item)
72
73