创建对话补全
curl --request POST \
--url https://xxx.wengaocloud.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "你是一个简洁的产品助手。"
},
{
"role": "user",
"content": "用三句话介绍这个平台。"
}
]
}
'import requests
url = "https://xxx.wengaocloud.com/v1/chat/completions"
payload = {
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "你是一个简洁的产品助手。"
},
{
"role": "user",
"content": "用三句话介绍这个平台。"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: [
{role: 'system', content: '你是一个简洁的产品助手。'},
{role: 'user', content: '用三句话介绍这个平台。'}
]
})
};
fetch('https://xxx.wengaocloud.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xxx.wengaocloud.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o-mini\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"你是一个简洁的产品助手。\"\n },\n {\n \"role\": \"user\",\n \"content\": \"用三句话介绍这个平台。\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "<string>",
"object": "chat.completion",
"choices": [
{}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_tokens_details": {}
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}对话与文本
创建对话补全
OpenAI 兼容的对话补全接口(Chat Completions)。接收一组消息列表并返回一条模型生成的回复。 支持文本、多模态输入、流式输出和工具调用;具体能力以模型支持为准。
创建对话补全
curl --request POST \
--url https://xxx.wengaocloud.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "你是一个简洁的产品助手。"
},
{
"role": "user",
"content": "用三句话介绍这个平台。"
}
]
}
'import requests
url = "https://xxx.wengaocloud.com/v1/chat/completions"
payload = {
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "你是一个简洁的产品助手。"
},
{
"role": "user",
"content": "用三句话介绍这个平台。"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: [
{role: 'system', content: '你是一个简洁的产品助手。'},
{role: 'user', content: '用三句话介绍这个平台。'}
]
})
};
fetch('https://xxx.wengaocloud.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xxx.wengaocloud.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o-mini\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"你是一个简洁的产品助手。\"\n },\n {\n \"role\": \"user\",\n \"content\": \"用三句话介绍这个平台。\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "<string>",
"object": "chat.completion",
"choices": [
{}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_tokens_details": {}
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
⌘I
.png?fit=max&auto=format&n=v_sJS-AFS6goKAv3&q=85&s=e03202fddb83c95be2a503ab9c79163a)