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