@polyweave/zhipu (1.0.4)
Installation
@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/npm install @polyweave/zhipu@1.0.4"@polyweave/zhipu": "1.0.4"About this package
Zhipu (GLM)
Zhipu AI / GLM adapter for Polyweave. AllTools agent model, 1M context.
Published as @polyweave/zhipu.
Synopsis
import { createZhipuAdapter } from '@polyweave/zhipu';
import { createTextFrame, createFrameSink } from '@polyweave/core';
var adapter = createZhipuAdapter({ apiKey: process.env.ZHIPU_API_KEY, model: 'glm-4-plus' });
adapter.source.pipe(createFrameSink(function(frame) {
if (frame.type === 'TEXT') console.log(frame.content.text);
}));
adapter.sink.write(createTextFrame('Write a short story about AI'));
Install
npm install @polyweave/zhipu
Description
Zhipu AI adapter for the GLM model series. OpenAI-compatible chat completions with streaming SSE, tool/function calling, vision input, and embeddings.
Models: glm-4-plus, glm-4-flash, glm-4-air, glm-4-alltools, glm-4-long, glm-4v, glm-4.
API
createZhipuAdapter(config)
| Parameter | Type | Default | Description |
|---|---|---|---|
config.apiKey |
string |
process.env.ZHIPU_API_KEY |
API key |
config.baseURL |
string |
https://open.bigmodel.cn/api/paas/v4 |
Base URL |
config.model |
string |
glm-4-plus |
Default model |
config.budget |
number |
0 | Budget cap |
config.name |
string |
null | Node name for PARAM targeting |
config.timeout |
number |
120000 | Request timeout in ms |
Returns an IFrameDuplex with source and sink.
Frame Protocol
| Inbound | Outbound |
|---|---|
| TEXT, IMAGE, EMBEDDING | TEXT, EMBEDDING, TOOL_CALL, RECEIPT, ERROR, END |
| PARAM | — |
| COST_CHECK | COST |
PARAM Keys
model, max_tokens, temperature, top_p, stream, system, tools, tool_choice, response_format, embedding_model, budget, apiKey
Tests
npm test
Covers adapter construction and PARAM accumulation.
Requirements
Node.js 18 or later. ESM only.
Caveats
Zhipu's GLM-4-AllTools model supports function calling, web search, code interpreter, and knowledge base retrieval in a single model. The base URL uses bigmodel.cn (Chinese domain). JWT-based authentication is supported; the adapter expects a Bearer token by default.
See Also
License
MIT
Dependencies
Development Dependencies
| ID | Version |
|---|---|
| @rigor/core | * |
Peer Dependencies
| ID | Version |
|---|---|
| @polyweave/core | * |
| @polyweave/costs | * |