A loadable [Glamorous Toolkit](https://gtoolkit.com) package that adds [Z.ai](https://z.ai) (GLM models) as a provider for `GtLChat`, using Z.ai's OpenAI-compatible `/chat/completions` API.
# Gt4Llm-Zai A loadable [Glamorous Toolkit](https://gtoolkit.com) package that adds [Z.ai](https://z.ai) (GLM models) as a provider for `GtLChat`, using Z.ai's OpenAI-compatible `/chat/completions` API. ## What it provides - `GtLZaiCompletionsEndpoint` — OpenAI `/chat/completions` endpoint with a Z.ai-correct path (the parent `GtLOllamaCompletionsEndpoint` uses `/v1/chat/completions`, which would double the version segment against Z.ai's `.../paas/v4` base URL). - `GtLZaiProvider` — a `GtLModelProvider` whose user-message class is `GtLModelUserMessage` (so the chat understands `#markdown:`). - `GtLModelFactory >> zai` / `zai:` — factory methods returning a configured `GtLLlmModel`, with bearer auth wired in. ## Install ```smalltalk Metacello new repository: 'github://fromelicks/gt4llm-zai:main/src'; baseline: 'Gt4LlmZai'; load. ``` (Replace the repository with your GitLab remote, e.g. `'gitlab://...'` or a local `'filetree://...'` path.) ## Configure the API key Put your Z.ai key in a file outside the image (never committed): ``` ~/.secrets/zai-api-key.txt ``` To relocate it, override `GtLModelFactory >> zaiApiKeyFile`. If you use a **general** API key rather than the Coding Plan, override `GtLModelFactory >> zaiBaseUrl` to return `'https://api.z.ai/api/paas/v4'`. ## Use ```smalltalk | model chat | model := GtLModelFactory new zai. "or: zai: 'glm-4.7'" chat := GtLChat new provider: model provider. chat inspect. ``` Then type into the chat's Live view. ## Why this exists / design notes gt4llm has two parallel layers. Z.ai is threaded through the newer **model layer** (`GtLModelFactory` -> `GtLLlmModel` + endpoint objects), the same one LM Studio uses. Class names there describe origin, not protocol: `GtLOllamaCompletionsEndpoint` is really "the `/chat/completions` endpoint" and works for any OpenAI-compatible server; `GtLOpenAiResponsesEndpoint` targets OpenAI's newer `/responses` API and is unfinished. The client family (`GtLModelClient` / `GtLOllamaClient`) was built for keyless local servers, so bearer auth is injected via `GtLOpenAIClientZincBuilder` (which sets `Authorization: Bearer`).