# Z.AI

## What it is

**Z.AI** (Zhipu AI) is the platform behind the **GLM** model family. Its chat endpoint is OpenAI-compatible, while the rest of the capabilities live on separate paths of the same API: image and video generation, web search, speech recognition and a tokenizer. The integration connects with a personal API key and lets a bot scenario hold a conversation, read images, search the web, generate pictures and video, transcribe audio and count tokens.

## Requirements

- An account at [z.ai](https://z.ai).
- A positive balance — every operation is billed.
- An API key from the **API Keys** section.

## How to connect

1. Sign up at [z.ai](https://z.ai) and top up your balance.
2. Open [API Keys](https://z.ai/manage-apikey/apikey-list) and create a key.
3. Copy the key.
4. In the constructor open **Integrations** → find the **Z.AI** card → **Connect**.
5. Paste the key into the connection field and save.
6. Click **Test connection** — the integration makes a lightweight call to the tokenizer and reports the result.

## Available operations

| Operation | What it does |
|---|---|
| Send message | Chat with the model: system prompt, conversation history, JSON mode, reasoning mode, streaming output |
| Image analysis | Answers a question about an image (URL or a Telegram file_id) using a vision model |
| Image generation | Draws a picture from a description with `glm-image` and uploads it to Telegram for a stable `file_id` |
| Reaction to a message | The model picks one emoji reaction from a given list |
| Web search | Returns the structured Z.AI search result: titles, links, text excerpts and dates |
| Video generation | Creates a clip from a description or a source image with `cogvideox-3` |
| Audio transcription | Turns a voice message or audio file into text with `glm-asr` |
| Token count | Counts how many tokens a text takes in the selected model |

## Limits

- An image sent to a vision model must be under 5 MB and no larger than 6000×6000 pixels.
- Audio for transcription must be `wav` or `mp3`, up to 25 MB and no longer than 30 seconds.
- A video prompt is capped at 512 characters; duration is 5 or 10 seconds, frame rate 30 or 60 fps.
- Sizes for `glm-image`: each side between 1024 and 2048 pixels and divisible by 32. `cogview-4` is stricter — each side divisible by 16 and no more than 2 MP in total.
- The tokenizer only accepts `glm-4.6`, `glm-4.6v` and `glm-4.5`.
- Links to generated images and videos expire after 30 days.

## Notes

> Video generation is asynchronous: the integration submits the task and waits for the result, polling Z.AI for up to 5 minutes. The block holds the scenario for that whole time — don't put it on a branch where the user is waiting for a quick reply.

> Uploading the result to Telegram is controlled by the "Don't upload to Telegram" checkbox in the block — as in every other integration, it is **on by default**. While it stays on, only `{{result.url}}` is available — a Z.AI link that stops working after 30 days, so save the file yourself if you need it long-term. Clear the checkbox to have the bot upload the result to Telegram and return a permanent `{{result.file_id}}`.

> Z.AI publishes no models-listing endpoint, so the dropdown in the block is filled from the model codes documented by the platform. If Z.AI ships a new model, its code can be typed into the "Model" field by hand.

> "Web search" is not a conversation with a model but a direct query to the search engine: it returns an array of sources (`{{result.0.title}}`, `{{result.0.link}}` and so on) rather than a finished answer. To get readable text, feed the findings into "Send message" as the next step.
