第一步:获取 Token
- 访问 Matrix 控制台,注册并登录账号
- 进入「令牌」页面,点击「创建新 Token」
- 复制生成的 Token(以
sk-开头)
第二步:确认连接信息
所有调用都需要两个参数:第三步:发起第一次调用
方式一:用 curl 测试
choices 字段,说明配置成功。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
三步开始使用 Matrix API 中转服务
sk- 开头)| 参数 | 值 |
|---|---|
| Base URL | https://matrix.000328.xyz |
| API Key | 你的 Token(sk-xxx) |
curl https://matrix.000328.xyz/v1/chat/completions \
-H "Authorization: Bearer sk-你的Token" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-3-mini-fast",
"messages": [{"role": "user", "content": "你好"}],
"stream": false
}'
choices 字段,说明配置成功。
from openai import OpenAI
client = OpenAI(
api_key="sk-你的Token",
base_url="https://matrix.000328.xyz/v1"
)
response = client.chat.completions.create(
model="grok-3-mini-fast",
messages=[{"role": "user", "content": "你好"}]
)
print(response.choices[0].message.content)