快速开始
1. 注册账号
访问 Gretoken 注册账号。
2. 获取 API Key
登录后进入「仪表盘」→「API Key」页面,点击「创建 Key」生成你的专属密钥。
3. 发起请求
Gretoken 完全兼容 OpenAI API 格式,只需将 base_url 替换为 Gretoken 的地址即可。
Python 示例
python
from openai import OpenAI
client = OpenAI(
api_key="sk-your-gretoken-key",
base_url="https://www.gretoken.com/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "你好,请介绍一下你自己"}
]
)
print(response.choices[0].message.content)cURL 示例
bash
curl https://www.gretoken.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-gretoken-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'4. 选择模型
Gretoken 支持多种模型,在请求中通过 model 参数指定即可。查看 支持的模型列表 了解详情。
