
Overview
GenAIScript are JavaScript files named as *.genai.mjs
, or TypeScript files named as *.genai.mts
,
with a prompt creation engine designed by LLM prompting.
script({ title: "Shorten", // displayed in UI and Copilot Chat // also displayed but grayed out: description: "A prompt that shrinks the size of text without losing meaning",})
// but the variable is appropriately delimitedconst file = def("FILE", env.files)
// this appends text to the prompt$`Shorten ${file}. Limit changes to minimum.`
Script files
- GenAIScript will detect any file matching
*.genai.mjs
,*.genai.js
,*.genai.mts
in your workspace. - GenAIScript files can be placed anywhere in your workspace;
but the extension will place them in a
genaisrc
folder by default. .genai.mjs
use module JavaScript syntax and support imports..genai.js
are eval-ed and do not support imports..genai.mts
are TypeScript module files and support imports, including dynamic imports of other TypeScript files.
Directory/genaisrc
- jsconfig.json // TypeScript compiler configuration
- genaiscript.d.ts // TypeScript definitions
- myscript.genai.mjs // your script!
- …
system.*.genai.mjs
are considered system prompt templates and are unlisted by default.
Topics
Metadata Learn how to configure script metadata to enhance functionality and user experience in GenAIScript.
Prompt ($) Learn how to use the tagged template literal for dynamic prompt generation in GenAI scripts.
Context (env+def) Detailed documentation on the script execution context and environment variables in GenAIScript.
Variables Discover how to utilize and customize script variables for dynamic scripting capabilities with env.vars.
File Output Learn how to declare and manage script-generated file outputs with defFileOutput function.
Tools Learn how to define and use tools within GenAIScript to enhance answer assembly with custom logic and CLI tools.
Model Context Protocol Tools Learn how to configure and securely use Model Context Protocol (MCP) tools and servers, including tool output validation, secret detection, and security best practices for AI scripting.
Model Context Protocol Server Turns scripts into Model Context Protocol Tools
Data Schemas Learn how to define and use data schemas for structured output in JSON/YAML with LLM, including validation and repair techniques.
Agents An Agent is a tool that queries an LLM, equipped with other tools, to accomplish tasks.
DOCX Learn how to parse and extract text from DOCX files for text analysis and processing.
PDF Learn how to extract text from PDF files for prompt generation using GenAIScript's PDF parsing capabilities.
XML Discover how to automatically parse XML files and convert them to JSON objects, enabling efficient data handling, RSS feed parsing, and file processing.
Markdown Enhance your markdown capabilities with MD class helpers for parsing and managing frontmatter efficiently.
Images Learn how to add images to prompts for AI models supporting visual inputs, including image formats and usage.
Inline prompts Learn how to use inline prompts with runPrompt function for inner LLM invocations in scripting.
Retrieval Learn how to use GenAIScript's retrieval utilities for content search and prompt augmentation with RAG techniques.
Secret Scanning Learn how to detect and prevent sensitive information leaks in your codebase using automated secret scanning, customizable patterns, and configuration options.
System Prompts Learn how to utilize system prompts to enhance script execution in GenAIScript.
Vector Search Learn how to use the retrieval.vectorSearch function to index files with embeddings for efficient similarity search in vector databases.
Videos as Inputs How to use the Video in scripts
Annotations Learn how to add annotations such as errors, warnings, or notes to LLM output for integration with VSCode or CI environments.
File Merge Customize file merging in scripts with defFileMerge function to handle different file formats and merging strategies.
Tests / Evals Learn how to execute and evaluate LLM output quality with promptfoo, a tool designed for testing language model outputs.
Red Team Learn how to implement LLM red teaming to identify vulnerabilities in AI systems using PromptFoo, including configuration, plugins like OWASP Top 10, and effective strategies for adversarial testing.
Custom Output Learn how to use the defOutputProcessor function for custom file processing in script generation.
Parsers Comprehensive guide on various data format parsers including JSON5, YAML, TOML, CSV, PDF, DOCX, and token estimation for LLM.
Structured Outputs Utilize structured output in GenAIScript to generate JSON data with schema validation for precise and reliable data structuring.
Files Learn how to perform file system operations using the workspace object in your scripts.
Fetch Learn how to use fetch and fetchText in scripts to make HTTP requests and handle text responses.
Cache Learn how LLM requests are cached in scripts to optimize performance and how to manage cache settings.
Cancel Learn how to immediately stop script execution with the cancel function in your automation scripts.
Diff Learn how to create and interpret file diffs within GenAIScript.
Output Builder Learn how to build a markdown output for your script execution
TypeScript Learn how to use TypeScript for better tooling and scalability in your GenAIScript projects.
Web Search Execute web searches with the Bing API using retrieval.webSearch in scripts.
Secrets Learn how to securely access and manage environment secrets in your scripts with env.secrets object.
YAML Learn how to use YAML for data serialization, configuration, and parsing in LLM with defData, YAML class, and JSON schema validation.
CSV Learn how to parse and stringify CSV data using the CSV class in scripting.
INI Learn how to parse and stringify INI files in GenAIScript with the INI class, including methods and usage examples.
XLSX Learn how to parse and stringify Excel XLSX files with ease using our tools.
HTML Learn how to use HTML parsing functions in GenAIScript for effective content manipulation and data extraction.
ast-grep Search for patterns in the AST of a script
Choices Specify a list of preferred token choices for a script.
Containers Learn how to use containers for secure and isolated execution of untrusted code with Docker in software development.
Content Safety Learn about the built-in safety features, system prompts, and Azure AI Content Safety services to protect language model applications from harmful content, prompt injections, and prompt leaks.
Imports Learn how to enable module imports in GenAI scripts by converting them to .mjs format and using static or dynamic imports.
Logging Logging mechanism for scripts.
Diagrams Create diagrams and charts within markdown using GenAIScript and the mermaid extension for visual representation of data and processes.
Browser Automation Discover how GenAIScript integrates with Playwright for web scraping and browser automation tasks.
Audio Transcription Describe how to transcribe an audio/video file
Image Generation Use image generation like OpenAI DALL-E Stable Diffusion to generate images from text.
Chat Participants Create multi-turn chats or simulate conversations with multiple chat participants
Concurrency How to run multiple prompts concurrently
GitHub Support for querying GitHub
Import Template Learn how to import prompt templates into GenAIScript using `importTemplate` with support for mustache variable interpolation and file globs.
LogProbs Learn how to use logprobs to diagnose the performance of your scripts
Parameters Schema Parameters schema are used to define signatures of scripts, tools.
Git Git utilities for repository operations
Prompty Learn about the .prompty file format for parameterized prompts and its integration with GenAIScript for AI scripting.
Model Aliases Give friendly names to models
Pyodide Run Python code in the JavaScript environment using Pyodide.
Tokenizers Tokenizers are used to split text into tokens.
Cast Use the cast helper to convert text to structured data
Classify Use the classify helpers for your classification tasks
Prompt Caching Learn how prompt caching can reduce processing time and costs for repetitive LLM prompts, with details on configuration and provider support including OpenAI and Anthropic.
Runtime GenAIScript runtime files
Microsoft Teams Learn how to use the Microsoft Teams integration in your scripts.
User Input How to get user input in a script
Fence Formats Explore various fence formats supported by GenAIScript for optimal LLM input text formatting.
Notebook Explore the features of the Markdown Notebook for authoring documentation with script snippets and inline results.
Reasoning Models Specific information about OpenAI reasoning models.
Response Priming Learn how to prime LLM responses with specific syntax or format using the writeText function in scripts.
Z3 Z3 is a high-performance theorem prover developed at Microsoft Research. It is a built-in tool of GenAIScript.
Types TypeScript Type Definition File