Registry / llm-agents / zai-sdk

zai-sdk

JSON →
library0.2.2pypypi✓ verified 86d ago

A Python SDK for accessing large model APIs from Z.ai. Version 0.2.2 supports Python >=3.8. Provides clients for chatting, streaming, and embedding with multiple models. Early stage with frequent changes.

pip install zai-sdk
INSTALL
IMPORT
SIG · ZAI-SDK
Z
zai-sdk
llm-agentspythonv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ZaiClient
✓ from zai import ZaiClient
✗ from zai import ZAI
ZhipuAiClient
✓ from zai import ZhipuAiClient
core
✓ from zai import core

Initialize client with API key from environment variable and make a chat completion.

import os from zai import ZAI client = ZAI(api_key=os.environ.get('ZAI_API_KEY', '')) response = client.chat.completions.create( model="zai-gpt-4o", messages=[{"role": "user", "content": "Hello"}] ) print(response.choices[0].message.content)
Debug
Known issues
gotchaThe package name on PyPI is 'zai-sdk' but the import is 'from zai'. Do not use 'import zai_sdk'.
fix
Use pip install zai-sdk, then from zai import ZAI
affects: ALL
breakingVersion 0.2.x changed the client initialization signature. Old code used ZAI() with no arguments, now requires api_key parameter.
fix
Pass api_key to ZAI(api_key='your_key')
affects: <0.2.0
deprecatedThe method 'client.complete()' is deprecated in favor of 'client.chat.completions.create()'.
fix
Use client.chat.completions.create(model=..., messages=...)
affects: >=0.2.0
Upgrade
Version history
0.2.2latest on PyPI · released Feb 2, 2026
Audit
Dependencies
requestsrequiredHTTP client for API calls
pydanticoptionalData validation
Agent activity
76 hits · last 30 days
node
70
Perplexity
1
OpenAI (training)
1
Resources
zai-sdk — pip install zai-sdk · libregistry