Skip to content

Conversation

@yixuan
Copy link
Contributor

@yixuan yixuan commented Nov 1, 2025

Description

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

According to the class structure, error classes such as APIStatusError and APITimeoutError are not accessible via zai.* as in the example code in README:

from zai import ZaiClient
import zai

client = ZaiClient(api_key="your-api-key")

try:
    response = client.chat.completions.create(
        model="glm-4",
        messages=[
            {"role": "user", "content": "Hello, Z.ai!"}
        ]
    )
    print(response.choices[0].message.content)
    
except zai.APIStatusError as err:
    print(f"API Status Error: {err}")
except zai.APITimeoutError as err:
    print(f"Request Timeout: {err}")
except Exception as err:
    print(f"Unexpected Error: {err}")

Instead, the correct path is zai.core.APIStatusError and zai.core.APITimeoutError, etc.

@tomsun28 tomsun28 requested a review from wellenzheng November 15, 2025 11:12
Copy link
Member

@tomsun28 tomsun28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tomsun28 tomsun28 merged commit fec2f2b into zai-org:main Nov 18, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants