z-ai-sdk-python/tests/integration_tests/test_images.py
wellenzheng 81cffb6cc4
feat: translate and enrich doc (#3)
* init

* enrich doc

* init

* init

* init

* doc

* chore: remove deprecated email field from pyproject.toml

* feat: translate content from Chinese to English and update documentation

This commit translates all Chinese text content in the codebase to English, including:
- Test messages and prompts
- Error messages
- Documentation strings
- API parameter descriptions
- README and release notes content

The changes ensure consistency in language usage across the entire project while maintaining all functionality. Documentation has been updated to reflect these changes and provide clearer English descriptions of features and usage.

* refactor: update branding from ZaiClient to Z.ai

Update SDK name in README and HTTP headers to reflect new branding. Also update endpoint references in type definitions.

* ci: allow spaces in PR commit message subject pattern

---------

Co-authored-by: zhengweijun <weijun.zheng@aminer.cn>
2025-07-11 15:20:27 +08:00

46 lines
1.2 KiB
Python

import logging
import logging.config
import zai
from zai import ZaiClient
def test_images(logging_conf):
logging.config.dictConfig(logging_conf) # type: ignore
client = ZaiClient() # Fill in your own API Key
try:
response = client.images.generations(
model='cogview-3', # Fill in the model name to call
prompt='a cute little kitten',
extra_body={'user_id': '1222212'},
user_id='12345678',
)
print(response)
except zai.core._errors.APIRequestFailedError as err:
print(err)
except zai.core._errors.APIInternalError as err:
print(err)
except zai.core._errors.APIStatusError as err:
print(err)
def test_images_sensitive_word_check(logging_conf):
logging.config.dictConfig(logging_conf) # type: ignore
client = ZaiClient() # Fill in your own API Key
try:
response = client.images.generations(
model='cogview-3', # Fill in the model name to call
prompt='a cute little kitten',
sensitive_word_check={'type': 'ALL', 'status': 'DISABLE'},
extra_body={'user_id': '1222212'},
user_id='12345678',
)
print(response)
except zai.core._errors.APIRequestFailedError as err:
print(err)
except zai.core._errors.APIInternalError as err:
print(err)
except zai.core._errors.APIStatusError as err:
print(err)