# Pi + GLM-4.7 (Z.ai) Smoke Lane **Status:** Transport already proven — this Opencode session runs on GLM-4.7 via z.ai. Remaining step: formal JSONL capture with `pi --mode json`. **Owner:** Opencode / Z.ai Integrator ## Purpose Capture a formal JSONL-mode proof that `pi` can talk to GLM-4.7 through the Z.ai provider lane. The transport itself is already validated — you are reading output from it right now. This doc exists to produce a capture artifact other agents can reference. ## Key Situation Sam does **not** need to provide a separate key. The z.ai API key that powers this Opencode session is already configured in the host's opencode setup. The question is whether `pi` can reach the same endpoint using its own `--provider zai` path with the same key. If Sam's key is exposed as `ZAI_API_KEY` in the environment, `pi` picks it up automatically. If not, the key lives in opencode's own config and `pi` needs it exported explicitly for this smoke. ## Expected Environment - pi: `0.75.5` - node: `24.x` (`>=24` per the runtime engine policy) ## Smoke Commands ### 1. Check if the key is already available to pi ```sh echo "ZAI_API_KEY is set: ${ZAI_API_KEY:+yes}" ``` If not set, Sam can export it for this terminal: ```sh read -rsp "ZAI API key: " ZAI_API_KEY; echo export ZAI_API_KEY export ZAI_API_BASE="https://api.z.ai/api/coding/paas/v4" ``` ### 2. Prepare the repo-local capture directory ```sh mkdir -p tmp ``` ### 3. Discover available models ```sh pi --provider zai --list-models 2>&1 | tee tmp/zai-models.txt ``` ### 4. Filter for GLM models ```sh grep -i glm tmp/zai-models.txt ``` ### 5. Run smoke in JSON mode Use the exact model ID from step 4: ```sh pi --provider zai --model '' -p --mode json "reply with the single word: ok" 2>&1 | tee tmp/glm47-smoke.jsonl ``` ### 6. Validate the JSONL event stream ```sh python3 -c " import json provider = 'MISSING' model = 'MISSING' content_parts = [] events = [] with open('tmp/glm47-smoke.jsonl', 'r', encoding='utf-8') as f: for raw in f: line = raw.strip() if not line: continue obj = json.loads(line) events.append(obj.get('type', 'MISSING')) provider = obj.get('provider') or provider model = obj.get('model') or model delta = obj.get('delta') if isinstance(delta, str): content_parts.append(delta) text = obj.get('text') if isinstance(text, str): content_parts.append(text) content = ''.join(content_parts) print('events:', ','.join(events)) print('provider:', provider) print('model:', model) print('content:', content[:120] or 'MISSING') print('PASS' if 'ok' in content.lower() else 'FAIL') " ``` ### 7. Clean up ```sh unset ZAI_API_KEY ZAI_API_BASE ``` ## What to Report Back 1. Exact model ID from `--list-models` 2. Provider and model fields recovered from the JSONL stream 3. Event types seen in the stream 4. PASS/FAIL 5. Wall-clock latency ## Deletion Criteria - JSONL capture artifact is committed - Lane confirmed in agent capability table