Introduction to Zai
Type-safe LLM utilities for common AI operations.
Zai is a utility library for structured LLM operations. Instead of writing raw prompts, you call typed methods like extract(), check(), summarize(), and text() that handle prompting, parsing, and validation for you.
In the ADK, Zai is available via adk.zai. It automatically uses your agent’s configured zai model from defaultModels in agent.config.ts.
import { adk } from '@botpress/runtime'
const zai = adk.zai
What you can do
| Method | What it does | Page |
|---|---|---|
extract() | Pull structured data from unstructured text | Extract structured data |
check() | Verify a Boolean condition | Classify, validate and filter |
label() | Categorize content with multiple labels | Classify, validate and filter |
filter() | Filter an array by a condition | Classify, validate and filter |
sort() | Sort items using natural language criteria | Classify, validate and filter |
rate() | Rate items on a 1-5 scale | Classify, validate and filter |
group() | Group items into categories | Classify, validate and filter |
text() | Generate text from a prompt | Generate text and summaries |
rewrite() | Transform text based on instructions | Generate text and summaries |
summarize() | Summarize long content | Generate text and summaries |
answer() | Answer questions with citations | Generate text and summaries |
patch() | Make surgical edits to files | Generate text and summaries |
Quick example
import { adk, z } from '@botpress/runtime'
const zai = adk.zai
const product = await zai.extract(
'Blueberries are $3.99 and are in stock.',
z.object({
name: z.string(),
price: z.number(),
inStock: z.boolean(),
})
)
// { name: "blueberries", price: 3.99, inStock: true }
Model configuration
Zai uses the zai model from defaultModels in agent.config.ts:
defaultModels: {
autonomous: "cerebras:gpt-oss-120b",
zai: "cerebras:gpt-oss-120b",
},
You can also change the model from the dev console under Settings > LLM Config.