Polyweave

@polyweave/zai (1.0.6)

Published 2026-07-10 19:07:40 +00:00 by Dvorak

Installation

@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/
npm install @polyweave/zai@1.0.6
"@polyweave/zai": "1.0.6"

About this package

@polyweave/zai

Z.AI (ZhipuAI/GLM) adapter for Polyweave - multi-capability adapter supporting chat (streaming, tools, vision, thinking mode with GLM-4.7/4.6/4.5), image generation (CogView-4), video generation (CogVideoX-3, Vidu), audio transcription (GLM-ASR), and cost estimation.

Synopsis

import { createZaiAdapter } from '@polyweave/zai';

const adapter = createZaiAdapter({ apiKey: 'YOUR_API_KEY' });
adapter.source.pipe(someSink);
adapter.sink.write({ type: 'PARAM', content: { key: 'model', value: 'glm-4.7' } });
adapter.sink.write({ type: 'TEXT', content: { text: 'Hello!' } });

Install

npm install @polyweave/zai

API

createZaiAdapter(config)

Returns an IFrameDuplex stream adapter. Configuration options:

Option Type Default Description
apiKey string process.env.ZAI_API_KEY Z.AI API key
baseURL string 'https://api.z.ai/api/paas/v4' API base URL
timeout number 60000 Request timeout in ms
maxRetries number 2 Max retry count

Frame Types

  • Input: TEXT, IMAGE, AUDIO, TOOL_RESULT, PARAM, COST_CHECK, START, END
  • Output: TEXT, IMAGE, VIDEO, TOOL_CALL, RECEIPT, ERROR, COST, END

Tasks

Route via task PARAM: image, video, transcription/asr. Default: chat completion with streaming, tool calling, vision, and thinking mode support. API base: https://api.z.ai/api/paas/v4.

Tests

npm test

Requirements

  • Node.js >= 18.0.0
  • @polyweave/core (peer)
  • @polyweave/errors (peer)

License

MIT

Dependencies

Development Dependencies

ID Version
@rigor/core *

Peer Dependencies

ID Version
@polyweave/core *
@polyweave/costs *
@polyweave/errors *
@polyweave/push-websocket *

Keywords

polyweave zai ai adapter
Details
npm
2026-07-10 19:07:40 +00:00
4
John Dvorak
SEE LICENSE IN LICENSE
16 KiB
Assets (1)
zai-1.0.6.tgz 16 KiB
Versions (3) View all
1.0.10 2026-07-11
1.0.7 2026-07-11
1.0.6 2026-07-10