> ## Documentation Index
> Fetch the complete documentation index at: https://botpress.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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`.

```typescript theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
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](https://botpress.com/docs/adk/zai/extract.md) |
| `check()` | Verify a Boolean condition | [Classify, validate and filter](https://botpress.com/docs/adk/zai/classify.md) |
| `label()` | Categorize content with multiple labels | [Classify, validate and filter](https://botpress.com/docs/adk/zai/classify.md) |
| `filter()` | Filter an array by a condition | [Classify, validate and filter](https://botpress.com/docs/adk/zai/classify.md) |
| `sort()` | Sort items using natural language criteria | [Classify, validate and filter](https://botpress.com/docs/adk/zai/classify.md) |
| `rate()` | Rate items on a 1-5 scale | [Classify, validate and filter](https://botpress.com/docs/adk/zai/classify.md) |
| `group()` | Group items into categories | [Classify, validate and filter](https://botpress.com/docs/adk/zai/classify.md) |
| `text()` | Generate text from a prompt | [Generate text and summaries](https://botpress.com/docs/adk/zai/generate.md) |
| `rewrite()` | Transform text based on instructions | [Generate text and summaries](https://botpress.com/docs/adk/zai/generate.md) |
| `summarize()` | Summarize long content | [Generate text and summaries](https://botpress.com/docs/adk/zai/generate.md) |
| `answer()` | Answer questions with citations | [Generate text and summaries](https://botpress.com/docs/adk/zai/generate.md) |
| `patch()` | Make surgical edits to files | [Generate text and summaries](https://botpress.com/docs/adk/zai/generate.md) |

## Quick example

```typescript theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
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`:

```typescript theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
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**.

## Method categories

> [card] [Extract structured data](https://botpress.com/docs/adk/zai/extract.md)
>
> Pull typed data from unstructured text.

> [card] [Generate text and summaries](https://botpress.com/docs/adk/zai/generate.md)
>
> Generate, rewrite, summarize, and answer with citations.

> [card] [Classify, validate and filter](https://botpress.com/docs/adk/zai/classify.md)
>
> Check conditions, label content, filter, sort, rate, and group.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.