Create chat completion
curl --request POST \
--url https://api.maxapi.ai/v1/chat/completions \
--header 'Accept: <accept>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "gpt-4-all",
"messages": [
{
"role": "user",
"content": "画一只猫"
}
]
}
'import requests
url = "https://api.maxapi.ai/v1/chat/completions"
payload = {
"model": "gpt-4-all",
"messages": [
{
"role": "user",
"content": "画一只猫"
}
]
}
headers = {
"Content-Type": "<content-type>",
"Accept": "<accept>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Accept: '<accept>'},
body: JSON.stringify({model: 'gpt-4-all', messages: [{role: 'user', content: '画一只猫'}]})
};
fetch('https://api.maxapi.ai/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://api.maxapi.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4-all\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"画一只猫\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Accept", "<accept>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.maxapi.ai/v1/chat/completions")
.header("Content-Type", "<content-type>")
.header("Accept", "<accept>")
.body("{\n \"model\": \"gpt-4-all\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"画一只猫\"\n }\n ]\n}")
.asString();{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}Create chat completion
Use this endpoint to call the provider-compatible create chat completion operation through MaxAPI.
POST
https://api.maxapi.ai
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
--url https://api.maxapi.ai/v1/chat/completions \
--header 'Accept: <accept>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "gpt-4-all",
"messages": [
{
"role": "user",
"content": "画一只猫"
}
]
}
'import requests
url = "https://api.maxapi.ai/v1/chat/completions"
payload = {
"model": "gpt-4-all",
"messages": [
{
"role": "user",
"content": "画一只猫"
}
]
}
headers = {
"Content-Type": "<content-type>",
"Accept": "<accept>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Accept: '<accept>'},
body: JSON.stringify({model: 'gpt-4-all', messages: [{role: 'user', content: '画一只猫'}]})
};
fetch('https://api.maxapi.ai/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://api.maxapi.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4-all\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"画一只猫\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Accept", "<accept>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.maxapi.ai/v1/chat/completions")
.header("Content-Type", "<content-type>")
.header("Accept", "<accept>")
.body("{\n \"model\": \"gpt-4-all\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"画一只猫\"\n }\n ]\n}")
.asString();{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}Body
application/json
使用什么采样温度,介于 0 和 2 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如 0.2)将使输出更加集中和确定。 我们通常建议改变这个或top_p但不是两者。
一种替代温度采样的方法,称为核采样,其中模型考虑具有 top_p 概率质量的标记的结果。所以 0.1 意味着只考虑构成前 10% 概率质量的标记。 我们通常建议改变这个或temperature但不是两者。
为每个输入消息生成多少个聊天完成选项。
API 将停止生成更多令牌的最多 4 个序列。
聊天完成时生成的最大令牌数。 输入标记和生成标记的总长度受模型上下文长度的限制。
-2.0 和 2.0 之间的数字。正值会根据到目前为止是否出现在文本中来惩罚新标记,从而增加模型谈论新主题的可能性。 查看有关频率和存在惩罚的更多信息。
-2.0 和 2.0 之间的数字。正值会根据新标记在文本中的现有频率对其进行惩罚,从而降低模型逐字重复同一行的可能性。 查看有关频率和存在惩罚的更多信息。
修改指定标记出现在完成中的可能性。 接受一个 json 对象,该对象将标记(由标记器中的标记 ID 指定)映射到从 -100 到 100 的关联偏差值。从数学上讲,偏差会在采样之前添加到模型生成的 logits 中。确切的效果因模型而异,但 -1 和 1 之间的值应该会减少或增加选择的可能性;像 -100 或 100 这样的值应该导致相关令牌的禁止或独占选择。
Response
200 - application/json
Request succeeded.