llm-api-adapter-zai
An optional Z.ai / GLM organization package for LLM API Adapter, a Python SDK with one shared interface for calling LLM APIs.
Uses Z.ai / GLM's official Chat Completions API without a provider SDK.
Installation
Install through the Core package extra:
pip install "llm-api-adapter[zai]"
Direct installation is also supported when Core is managed separately:
pip install llm-api-adapter-zai
Async requests need HTTPX:
pip install "llm-api-adapter[zai,async]"
Synchronous requests use requests by default. To opt into HTTPX for sync
chat() and stream_chat(), install "llm-api-adapter[zai,httpx]" and pass
transport="httpx".
Quick start
import os
from llm_api_adapter.models.messages.chat_message import UserMessage
from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter
adapter = UniversalLLMAPIAdapter(
organization="zai",
model="glm-5.3-flash",
api_key=os.environ["ZAI_API_KEY"],
)
response = adapter.chat(
messages=[UserMessage("Explain retrieval-augmented generation.")],
max_tokens=128,
)
print(response.content)
Supported models
glm-5.3-flashglm-5.3-flashx
Capabilities
| Capability | glm-5.3-flash |
glm-5.3-flashx |
|---|---|---|
| Text chat; sync/async streaming | Supported through the official Chat Completions endpoint | Supported through the official Chat Completions endpoint |
| Application function tools | tool_choice="auto" only; at most 128 declarations |
tool_choice="auto" only; at most 128 declarations |
| Reasoning | Core reasoning_level is mapped to Z.ai effort; kept separate from visible text |
Core reasoning_level is mapped to Z.ai effort; kept separate from visible text |
| Image input | User-message URL, bytes, and data-URL forms | User-message URL, bytes, and data-URL forms |
| Usage | Valid provider usage only; missing or malformed usage is unavailable | Valid provider usage only; missing or malformed usage is unavailable |
| Portable JSON Schema / Pydantic output | Unsupported; rejected before HTTP | Unsupported; rejected before HTTP |
| Documents and generic files | Unsupported; rejected before HTTP | Unsupported; rejected before HTTP |
| Deployments, uploads, OCR, retries, continuation, and video | Unsupported | Unsupported |
Unknown, retired, aliased, or unverified model IDs are not inferred. Unsupported
tool choices, parallel-tool control, provider-built-in tools, and every
DocumentPart URL or byte form fail locally before the transport is called.
The adapter accepts only the official endpoint and the ZAI_API_KEY bearer
credential.
reasoning_level="none" uses the minimum registered effort and emits a
warning. previous_response is accepted but ignored: send complete messages
history, including assistant tool calls and tool results, on each turn; no
provider continuation identifier is sent. Exact values and exceptions are
recorded in the Z.ai registry.
Automatic cache usage and pricing
usage.prompt_tokens_details.cached_tokens becomes Usage.cached_tokens,
a subset of total input. The model uses its registry's ordinary and cache-read
USD rates. No separately priced automatic cache-write component is registered,
so cache_write_tokens remains None.
An omitted cache-read split leaves cost_input and cost_total unknown;
known output cost can remain available. The adapter does not enable opt-in
cache controls or price selectable TTLs or storage. See the shared
usage and pricing guide.
See the main llm-api-adapter README for the shared API contract and transport behavior.
Metadata
Release files for llm-api-adapter-zai 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_api_adapter_zai-0.1.1.tar.gz | 21.0 kB | Without provenance | Details for llm_api_adapter_zai-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_api_adapter_zai-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for llm_api_adapter_zai-0.1.1-py3-none-any.whl |
Total release size: 40.0 kB
Release files / llm_api_adapter_zai-0.1.1.tar.gz
| Download URL | llm_api_adapter_zai-0.1.1.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51d3d62d08bf59cc3f6ee329e3b6dbe435d2eea998d3e68849bda9042bfe2f02
|
|
BLAKE2b-256 checksum How to use checksums |
c4c58163e5646109755c8f615e657e00e6bc565bf3fa43fe6de1cdb02c5dc669
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / llm_api_adapter_zai-0.1.1-py3-none-any.whl
| Download URL | llm_api_adapter_zai-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5ef1e88542d64b4f139c5e0343b0f404bd1765534e5d26fe58894d83356f92c
|
|
BLAKE2b-256 checksum How to use checksums |
528e4639e892d5da52515843c80ab29a5228f0820e9e4909b7c7116b86956d86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for llm-api-adapter-zai 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.