chore: readme and china region api base url (#21)

Co-authored-by: zhengweijun <weijun.zheng@aminer.cn>
This commit is contained in:
wellenzheng 2025-07-27 15:05:59 +08:00 committed by GitHub
parent 8370fa0f04
commit 42d6cc34d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 3 deletions

View file

@ -77,6 +77,16 @@ pip install zai-sdk
## 🚀 Quick Start ## 🚀 Quick Start
### Create API Key ### Create API Key
#### Get API Key
- **Overseas regions**: Visit [Z.ai Open Platform](https://docs.z.ai/) to get your API key
- **Mainland China regions**: Visit [Zhipu AI Open Platform](https://www.bigmodel.cn/) to get your API key
#### API BASE URL
- **Mainland China regions**: `https://open.bigmodel.cn/api/paas/v4/`
- **Overseas regions**: `https://api.z.ai/api/paas/v4/`
#### Usage Steps
1. **Create client with API key** 1. **Create client with API key**
2. **Call the corresponding API methods** 2. **Call the corresponding API methods**
@ -85,11 +95,14 @@ For complete examples, please refer to the open platform [API Reference](https:/
### Basic Usage ### Basic Usage
```python ```python
from zai import ZaiClient from zai import ZaiClient, ZhipuAiClient
# Initialize client # For Overseas users, create the ZaiClient
client = ZaiClient(api_key="your-api-key") client = ZaiClient(api_key="your-api-key")
# For Chinese users, create the ZhipuAiClient
client = ZhipuAiClient(api_key="your-api-key")
# Create chat completion # Create chat completion
response = client.chat.completions.create( response = client.chat.completions.create(
model="glm-4", model="glm-4",

View file

@ -76,13 +76,45 @@ pip install zai-sdk
## 🚀 快速开始 ## 🚀 快速开始
### 基本用法 ### 创建 API Key
#### 获取 API Key
- **海外区域**: 访问 [Z.ai 开放平台](https://docs.z.ai/) 获取 API Key
- **中国大陆区域**: 访问 [智谱 AI 开放平台](https://www.bigmodel.cn/) 获取 API Key
#### API BASE URL
- **中国大陆区域**: `https://open.bigmodel.cn/api/paas/v4/`
- **海外区域**: `https://api.z.ai/api/paas/v4/`
#### 使用步骤
1. **使用API密钥创建客户端** 1. **使用API密钥创建客户端**
2. **调用相应的API方法** 2. **调用相应的API方法**
完整示例请参考开放平台[接口文档](https://docs.z.ai/api-reference/)以及[使用指南](https://docs.z.ai/guides/)记得替换为您自己的API密钥。 完整示例请参考开放平台[接口文档](https://docs.z.ai/api-reference/)以及[使用指南](https://docs.z.ai/guides/)记得替换为您自己的API密钥。
### 基本用法
### Basic Usage
```python
from zai import ZaiClient, ZhipuAiClient
# 对于海外用户使用ZaiClient
client = ZaiClient(api_key="your-api-key")
# 对于中国大陆用户使用ZhipuAiClient
client = ZhipuAiClient(api_key="your-api-key")
# Create chat completion
response = client.chat.completions.create(
model="glm-4",
messages=[
{"role": "user", "content": "Hello, Z.ai!"}
]
)
print(response.choices[0].message.content)
```
### 客户端配置 ### 客户端配置
SDK支持多种方式配置API密钥 SDK支持多种方式配置API密钥