Registry / llm-agents / zai-sdk

zai-sdk

JSON →
library0.2.2pypypi✓ verified 33d 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.

llm-agentsai-ml
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.

from zai import ZaiClient
from zai import ZhipuAiClient
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 footguns
gotchaThe package name on PyPI is 'zai-sdk' but the import is 'from zai'. Do not use 'import zai_sdk'.
breakingVersion 0.2.x changed the client initialization signature. Old code used ZAI() with no arguments, now requires api_key parameter.
deprecatedThe method 'client.complete()' is deprecated in favor of 'client.chat.completions.create()'.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
13 hits · last 30 days
claudebot
4
gptbot
3
ahrefsbot
3
amazonbot
3
Resources