1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "typst": """#set page(paper: \"a4\", margin: 2.2cm, numbering: \"1\")
10#set text(font: \"Libertinus Serif\", size: 11pt)
11#set heading(numbering: \"1.\")
12#set math.equation(numbering: \"(1)\")
13#set par(justify: true)
14
15#align(center)[
16 #text(18pt, weight: \"bold\")[Compiling Typst in the Cloud]
17 #v(4pt)
18 An AI Agent · October 2026
19]
20
21= Results
22The roots of $a x^2 + b x + c = 0$ are
23$ x = (-b plus.minus sqrt(b^2 - 4 a c)) / (2 a). $ <quadratic>
24By @quadratic, there are two real roots when $b^2 > 4 a c$, as @cases shows.
25
26#figure(
27 table(
28 columns: 3,
29 align: (left, center, center),
30 stroke: none,
31 table.hline(),
32 table.header([*Case*], [*Discriminant*], [*Real roots*]),
33 table.hline(stroke: 0.5pt),
34 [Two roots], [$b^2 - 4 a c > 0$], [2],
35 [One root], [$b^2 - 4 a c = 0$], [1],
36 [None], [$b^2 - 4 a c < 0$], [0],
37 table.hline(),
38 ),
39 caption: [Roots of a quadratic equation.],
40) <cases>
41
42#import \"@preview/cetz:0.5.3\": canvas, draw
43#figure(
44 canvas({
45 import draw: *
46 line((-2.5, 0), (2.5, 0), mark: (end: \">\"))
47 line((0, -1.5), (0, 4), mark: (end: \">\"))
48 content((2.75, 0), $x$)
49 content((0, 4.3), $y$)
50 line(..range(-22, 23).map(i => (i / 10, calc.pow(i / 10, 2) - 1)), stroke: blue + 1pt)
51 circle((-1, 0), radius: 0.07, fill: red, stroke: none)
52 circle((1, 0), radius: 0.07, fill: red, stroke: none)
53 }),
54 caption: [$y = x^2 - 1$ crosses the $x$-axis twice.],
55)
56
57= Why Typst
58Typst compiles in milliseconds and its errors point to the exact line, which makes it a good fit for documents
59written by programs and AI agents: reports, invoices, resumes, letters and slides.
60""",
61 "files": [],
62}
63
64
65run = client.actor("jumblemog/typst-to-pdf").call(run_input=run_input)
66
67
68print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
69for item in client.dataset(run.default_dataset_id).iterate_items():
70 print(item)
71
72