快速开始
直接调用 aihubmix API
其中 "AIHUBMIX_API_KEY" 替换为 aihubmix key,注意 key
的有效期和额度限制
- Shell
- JavaScript
- Python
curl 'https://aihubmix.com/v1/chat/completions' \
-H 'Authorization: Bearer <AIHUBMIX_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'
// 请在https://aihubmix.com域名下尝试,否则有浏览器跨域问题
fetch('https://aihubmix.com/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: 'Bearer <AIHUBMIX_API_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: "gpt-3.5-turbo",
messages: [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}),
})
import requests
import json
response = requests.post(
url="https://aihubmix.com/v1/chat/completions",
headers={
"Authorization": "Bearer <AIHUBMIX_API_KEY>",
"Content-Type": "application/json",
},
data=json.dumps({
"model": "gpt-3.5-turbo", # Optional
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
})
)
API 同样也支持流式数据, 参数增加 stream: true
通过客户端发起请求
使用三方客户端或框架发起aihubmix请求,可参考 场景示例