
Runtime
The GenAIScript runtime provides additional helpers and allows to use the runtime in any Node.JS application.
In order to use the runtime, you will need to install GenAIScript in your project.
npm i -D @genaiscript/runtime
pnpm add -D @genaiscript/runtime
yarn add -D @genaiscript/runtime
Initialization
Section titled “Initialization”If you are using GenAIScript without the CLI or Visual Studio Code extension, you need to initialize the runtime before using any global types or functions.
import { initialize } from "@genaiscript/runtime";
// runs this before using any global typesawait initialize();
Importing the runtime
Section titled “Importing the runtime”The runtime is available as a module. You can import it using the following code:
import { cast } from "@genaiscript/runtime";
Globals
Section titled “Globals”The runtime installs global parsers and inline prompt types. However, the global $
, def
, etc… is not available, online inline prompts.
Helpers
Section titled “Helpers”- cast, cast any data to structured outputs
- classify, classify text
- makeItBetter, tell the LLM to improve its result
Plugins
Section titled “Plugins”The following helpers have been moved into their own packages to reduce the default installation size. They will require an additional installation step if you want to use them.
- Markdown AST parsing and manipulation @genaiscript/plugin-mdast
- ast-grep, tree sitter rule matching and modifications, @genaiscript/plugin-ast-grep
- MermaidJS diagram parsing @genaiscript/plugin-mermaid
- Pyodide Python execution in the browser @genaiscript/plugin-pyodide
- Z3 Solver execution @genaiscript/plugin-z3