zai-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ZAI CLI

ZAI CLI

Access Z.AI capabilities via
npx zai-cli
. The CLI is self-documenting - use
--help
at any level.
你可以通过
npx zai-cli
访问Z.AI的各项功能。该CLI支持自文档化——在任何层级使用
--help
查看帮助信息。

Setup

环境配置

bash
export Z_AI_API_KEY="your-api-key"
bash
export Z_AI_API_KEY="your-api-key"
前往以下地址获取API密钥:https://z.ai/manage-apikey/apikey-list

Commands

命令列表

CommandPurposeHelp
visionAnalyze images, screenshots, videos
--help
for 8 subcommands
searchReal-time web search
--help
for filtering options
readFetch web pages as markdown
--help
for format options
repoGitHub code search and reading
--help
for tree/search/read
toolsList available MCP tools
toolShow tool schema
callRaw MCP tool invocation
codeTypeScript tool chaining
doctorCheck setup and connectivity
命令用途帮助信息
vision分析图片、截图、视频使用
--help
查看8个子命令
search实时网页搜索使用
--help
查看过滤选项
read将网页内容提取为Markdown格式使用
--help
查看格式选项
repoGitHub代码搜索与阅读使用
--help
查看树状展示/搜索/阅读功能
tools列出可用的MCP工具
tool展示工具的Schema结构
call原生调用MCP工具
codeTypeScript工具链
doctor检查环境配置与连通性

Quick Start

快速上手

bash
undefined
bash
undefined

Analyze an image

分析图片

npx zai-cli vision analyze ./screenshot.png "What errors do you see?"
npx zai-cli vision analyze ./screenshot.png "What errors do you see?"

Search the web

网页搜索

npx zai-cli search "React 19 new features" --count 5
npx zai-cli search "React 19 new features" --count 5

Read a web page

读取网页内容

npx zai-cli read https://docs.example.com/api npx zai-cli read https://docs.example.com/api --with-images-summary --no-gfm
npx zai-cli read https://docs.example.com/api npx zai-cli read https://docs.example.com/api --with-images-summary --no-gfm

Explore a GitHub repo

探索GitHub代码仓库

npx zai-cli repo search facebook/react "server components" npx zai-cli repo search openai/codex "config" --language en npx zai-cli repo tree openai/codex --path codex-rs --depth 2
npx zai-cli repo search facebook/react "server components" npx zai-cli repo search openai/codex "config" --language en npx zai-cli repo tree openai/codex --path codex-rs --depth 2

Check setup

检查环境配置

npx zai-cli doctor
undefined
npx zai-cli doctor
undefined

Output

输出格式

Default: data-only (raw output for token efficiency). Use
--output-format json
for
{ success, data, timestamp }
wrapping.
默认输出为仅数据模式(原始输出以提升Token使用效率)。 使用
--output-format json
可获取包含
{ success, data, timestamp }
的结构化输出。

Advanced

进阶功能

For raw MCP tool calls (
tools
,
tool
,
call
), Code Mode, and performance tuning (cache/retries), see
references/advanced.md
.
关于MCP工具原生调用(
tools
tool
call
)、代码模式以及性能调优(缓存/重试)的详细信息,请查看
references/advanced.md
文档。