VMware Tanzu Platform - CLI 测试指南
前提条件
- 从
feat/tanzu-ai-provider分支构建的 zai CLI - 一个 Tanzu AI Services 端点和 API 密钥(单模型或多模型计划)
定位 CLI 二进制文件
macOS:
# If built from source:
export ZAI_CLI=~/claude/zai-fork/target/release/zai
# Verify:
$ZAI_CLI --version
Linux:
# If installed via .deb:
export ZAI_CLI=/usr/bin/zai
# If built from source:
export ZAI_CLI=~/zai-fork/target/release/zai
# Verify:
$ZAI_CLI --version
测试 1:配置 VMware Tanzu Platform 提供商
zai configure
- 选择 Configure Providers
- 滚动到 / 搜索 VMware Tanzu Platform
- 当提示输入 TANZU_AI_ENDPOINT 时,输入你的端点 URL:
- 单模型:
https://genai-proxy.sys.example.com/tanzu-my-model-abc1234 - 多模型:
https://genai-proxy.sys.example.com/tanzu-all-models-abc1234
- 单模型:
- 当提示输入 TANZU_AI_API_KEY 时,粘贴来自服务密钥的 JWT 令牌
- 从动态获取的列表中选择模型
**预期结果:**模型从端点获取并显示供选择。
测试 2:启动会话(单模型计划)
export TANZU_AI_ENDPOINT="https://genai-proxy.sys.tas-tdc.kuhn-labs.com/tanzu-Qwen3-Coder-30B-A3B-vllm-v1-f3b0d18"
export TANZU_AI_API_KEY="<your-jwt-token>"
zai session
输入一个简单的提示词:
> What is 2 + 2?
**预期结果:**模型返回答案。如果启用了流式传输,token 会渐进式显示。
测试 3:启动会话(多模型计划)
export TANZU_AI_ENDPOINT="https://genai-proxy.sys.tas-tdc.kuhn-labs.com/tanzu-all-models-a8a9e22"
export TANZU_AI_API_KEY="<your-jwt-token>"
zai session
**预期结果:**会话使用在 zai configure 期间选择的模型启动。
测试 4:验证流式传输
启用流式传输(supports_streaming: true)后,响应应逐个 token 显示,而不是一次性出现。
> Write a short poem about clouds
**预期结果:**文本渐进式流出,而不是延迟后一次性出现。
测试 5:验证动态模型获取
zai configure
选择 Configure Providers > VMware Tanzu Platform。
**单模型计划预期结果:**出现一个模型(例如 Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)
**多模型计划预期结果:**出现多个模型(例如 Qwen3.5-122B、Qwen3-Coder-30B、gpt-oss-120b)
测试 6:验证错误消息
缺少 API 密钥
unset TANZU_AI_API_KEY
zai session
**预期结果:**出现清晰的错误消息:"Required API key TANZU_AI_API_KEY is not set."
缺少端点
unset TANZU_AI_ENDPOINT
zai session
**预期结果:**出现关于 TANZU_AI_ENDPOINT 未设置的清晰错误消息。
错误的端点
export TANZU_AI_ENDPOINT="https://genai-proxy.sys.example.com/nonexistent"
export TANZU_AI_API_KEY="invalid-key"
zai session
**预期结果:**出现连接或身份验证错误,而不是崩溃。
测试 7:在计划之间切换
- 使用多模型端点配置,选择一个模型,启动会话,验证其正常工作
- 再次运行
zai configure - 将 TANZU_AI_ENDPOINT 更改为单模型端点
- 选择该单模型
- 启动新会话,验证其正常工作
**预期结果:**两种计划都无需重启 zai 即可正常工作。
快速 curl 验证
在使用 zai 测试之前,你可以直接验证端点:
# Test models endpoint
curl -s -H "Authorization: Bearer $TANZU_AI_API_KEY" \
"$TANZU_AI_ENDPOINT/openai/v1/models" | python3 -m json.tool
# Test chat completions
curl -s -X POST "$TANZU_AI_ENDPOINT/openai/v1/chat/completions" \
-H "Authorization: Bearer $TANZU_AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8","messages":[{"role":"user","content":"hello"}],"max_tokens":10}'
# Test streaming
curl -s -N -X POST "$TANZU_AI_ENDPOINT/openai/v1/chat/completions" \
-H "Authorization: Bearer $TANZU_AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8","messages":[{"role":"user","content":"hello"}],"max_tokens":10,"stream":true}'