Skip to main content
Zai provides methods for generating and transforming text. Each method handles prompting and output formatting.

Generate text

zai.text() generates content from a prompt:

Rewrite text

zai.rewrite() transforms text based on instructions:

Summarize

zai.summarize() condenses long content. It handles documents from a few paragraphs up to entire books by chunking and merging automatically:

Answer with citations

zai.answer() answers a question from a set of documents and tells you which documents backed the answer. It doesn’t always return a direct answer: if the question is ambiguous, off-topic, or the documents don’t cover it, the result carries that information instead.
Branch on result.type to handle the other cases (ambiguous questions, off-topic, etc.):

Patch files

zai.patch() makes surgical edits to code or text files based on natural language instructions. It produces minimal diffs rather than regenerating entire files:
Last modified on April 27, 2026