建立聊天對話
curl --request POST \
--url https://api.aiid.edu.kg/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>",
"reasoning_content": "<string>"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": false,
"stream_options": {
"include_usage": true
},
"stop": "<string>",
"max_tokens": 123,
"max_completion_tokens": 123,
"presence_penalty": 0,
"frequency_penalty": 0,
"logit_bias": {},
"user": "<string>",
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
}
}
],
"response_format": {
"json_schema": {}
},
"seed": 123,
"modalities": [],
"audio": {
"voice": "<string>",
"format": "<string>"
}
}
'import requests
url = "https://api.aiid.edu.kg/v1/chat/completions"
payload = {
"model": "gpt-4",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>",
"reasoning_content": "<string>"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": False,
"stream_options": { "include_usage": True },
"stop": "<string>",
"max_tokens": 123,
"max_completion_tokens": 123,
"presence_penalty": 0,
"frequency_penalty": 0,
"logit_bias": {},
"user": "<string>",
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
}
}
],
"response_format": { "json_schema": {} },
"seed": 123,
"modalities": [],
"audio": {
"voice": "<string>",
"format": "<string>"
}
}
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-4',
messages: [
{
content: '<string>',
name: '<string>',
tool_calls: [
{
id: '<string>',
type: 'function',
function: {name: '<string>', arguments: '<string>'}
}
],
tool_call_id: '<string>',
reasoning_content: '<string>'
}
],
temperature: 1,
top_p: 1,
n: 1,
stream: false,
stream_options: {include_usage: true},
stop: '<string>',
max_tokens: 123,
max_completion_tokens: 123,
presence_penalty: 0,
frequency_penalty: 0,
logit_bias: {},
user: '<string>',
tools: [
{
type: 'function',
function: {name: '<string>', description: '<string>', parameters: {}}
}
],
response_format: {json_schema: {}},
seed: 123,
modalities: [],
audio: {voice: '<string>', format: '<string>'}
})
};
fetch('https://api.aiid.edu.kg/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aiid.edu.kg/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4',
'messages' => [
[
'content' => '<string>',
'name' => '<string>',
'tool_calls' => [
[
'id' => '<string>',
'type' => 'function',
'function' => [
'name' => '<string>',
'arguments' => '<string>'
]
]
],
'tool_call_id' => '<string>',
'reasoning_content' => '<string>'
]
],
'temperature' => 1,
'top_p' => 1,
'n' => 1,
'stream' => false,
'stream_options' => [
'include_usage' => true
],
'stop' => '<string>',
'max_tokens' => 123,
'max_completion_tokens' => 123,
'presence_penalty' => 0,
'frequency_penalty' => 0,
'logit_bias' => [
],
'user' => '<string>',
'tools' => [
[
'type' => 'function',
'function' => [
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
]
],
'response_format' => [
'json_schema' => [
]
],
'seed' => 123,
'modalities' => [
],
'audio' => [
'voice' => '<string>',
'format' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aiid.edu.kg/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ],\n \"tool_call_id\": \"<string>\",\n \"reasoning_content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"stop\": \"<string>\",\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"user\": \"<string>\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n }\n ],\n \"response_format\": {\n \"json_schema\": {}\n },\n \"seed\": 123,\n \"modalities\": [],\n \"audio\": {\n \"voice\": \"<string>\",\n \"format\": \"<string>\"\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))
}HttpResponse<String> response = Unirest.post("https://api.aiid.edu.kg/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ],\n \"tool_call_id\": \"<string>\",\n \"reasoning_content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"stop\": \"<string>\",\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"user\": \"<string>\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n }\n ],\n \"response_format\": {\n \"json_schema\": {}\n },\n \"seed\": 123,\n \"modalities\": [],\n \"audio\": {\n \"voice\": \"<string>\",\n \"format\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aiid.edu.kg/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ],\n \"tool_call_id\": \"<string>\",\n \"reasoning_content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"stop\": \"<string>\",\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"user\": \"<string>\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n }\n ],\n \"response_format\": {\n \"json_schema\": {}\n },\n \"seed\": 123,\n \"modalities\": [],\n \"audio\": {\n \"voice\": \"<string>\",\n \"format\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>",
"reasoning_content": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123,
"text_tokens": 123,
"audio_tokens": 123,
"image_tokens": 123
},
"completion_tokens_details": {
"text_tokens": 123,
"audio_tokens": 123,
"reasoning_tokens": 123
}
},
"system_fingerprint": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}OpenAI格式(Chat)
建立聊天對話
根據對話歷史建立模型回應。支援串流與非串流回應。
相容 OpenAI Chat Completions API。
POST
/
v1
/
chat
/
completions
建立聊天對話
curl --request POST \
--url https://api.aiid.edu.kg/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>",
"reasoning_content": "<string>"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": false,
"stream_options": {
"include_usage": true
},
"stop": "<string>",
"max_tokens": 123,
"max_completion_tokens": 123,
"presence_penalty": 0,
"frequency_penalty": 0,
"logit_bias": {},
"user": "<string>",
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
}
}
],
"response_format": {
"json_schema": {}
},
"seed": 123,
"modalities": [],
"audio": {
"voice": "<string>",
"format": "<string>"
}
}
'import requests
url = "https://api.aiid.edu.kg/v1/chat/completions"
payload = {
"model": "gpt-4",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>",
"reasoning_content": "<string>"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": False,
"stream_options": { "include_usage": True },
"stop": "<string>",
"max_tokens": 123,
"max_completion_tokens": 123,
"presence_penalty": 0,
"frequency_penalty": 0,
"logit_bias": {},
"user": "<string>",
"tools": [
{
"type": "function",
"function": {
"name": "<string>",
"description": "<string>",
"parameters": {}
}
}
],
"response_format": { "json_schema": {} },
"seed": 123,
"modalities": [],
"audio": {
"voice": "<string>",
"format": "<string>"
}
}
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-4',
messages: [
{
content: '<string>',
name: '<string>',
tool_calls: [
{
id: '<string>',
type: 'function',
function: {name: '<string>', arguments: '<string>'}
}
],
tool_call_id: '<string>',
reasoning_content: '<string>'
}
],
temperature: 1,
top_p: 1,
n: 1,
stream: false,
stream_options: {include_usage: true},
stop: '<string>',
max_tokens: 123,
max_completion_tokens: 123,
presence_penalty: 0,
frequency_penalty: 0,
logit_bias: {},
user: '<string>',
tools: [
{
type: 'function',
function: {name: '<string>', description: '<string>', parameters: {}}
}
],
response_format: {json_schema: {}},
seed: 123,
modalities: [],
audio: {voice: '<string>', format: '<string>'}
})
};
fetch('https://api.aiid.edu.kg/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aiid.edu.kg/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4',
'messages' => [
[
'content' => '<string>',
'name' => '<string>',
'tool_calls' => [
[
'id' => '<string>',
'type' => 'function',
'function' => [
'name' => '<string>',
'arguments' => '<string>'
]
]
],
'tool_call_id' => '<string>',
'reasoning_content' => '<string>'
]
],
'temperature' => 1,
'top_p' => 1,
'n' => 1,
'stream' => false,
'stream_options' => [
'include_usage' => true
],
'stop' => '<string>',
'max_tokens' => 123,
'max_completion_tokens' => 123,
'presence_penalty' => 0,
'frequency_penalty' => 0,
'logit_bias' => [
],
'user' => '<string>',
'tools' => [
[
'type' => 'function',
'function' => [
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
]
],
'response_format' => [
'json_schema' => [
]
],
'seed' => 123,
'modalities' => [
],
'audio' => [
'voice' => '<string>',
'format' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aiid.edu.kg/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ],\n \"tool_call_id\": \"<string>\",\n \"reasoning_content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"stop\": \"<string>\",\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"user\": \"<string>\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n }\n ],\n \"response_format\": {\n \"json_schema\": {}\n },\n \"seed\": 123,\n \"modalities\": [],\n \"audio\": {\n \"voice\": \"<string>\",\n \"format\": \"<string>\"\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))
}HttpResponse<String> response = Unirest.post("https://api.aiid.edu.kg/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ],\n \"tool_call_id\": \"<string>\",\n \"reasoning_content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"stop\": \"<string>\",\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"user\": \"<string>\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n }\n ],\n \"response_format\": {\n \"json_schema\": {}\n },\n \"seed\": 123,\n \"modalities\": [],\n \"audio\": {\n \"voice\": \"<string>\",\n \"format\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aiid.edu.kg/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ],\n \"tool_call_id\": \"<string>\",\n \"reasoning_content\": \"<string>\"\n }\n ],\n \"temperature\": 1,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"stream_options\": {\n \"include_usage\": true\n },\n \"stop\": \"<string>\",\n \"max_tokens\": 123,\n \"max_completion_tokens\": 123,\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"logit_bias\": {},\n \"user\": \"<string>\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n }\n ],\n \"response_format\": {\n \"json_schema\": {}\n },\n \"seed\": 123,\n \"modalities\": [],\n \"audio\": {\n \"voice\": \"<string>\",\n \"format\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>",
"reasoning_content": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123,
"text_tokens": 123,
"audio_tokens": 123,
"image_tokens": 123
},
"completion_tokens_details": {
"text_tokens": 123,
"audio_tokens": 123,
"reasoning_tokens": 123
}
},
"system_fingerprint": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}授權
使用 Bearer Token 認證。
格式: Authorization: Bearer sk-xxxxxx
主體
application/json
模型 ID
範例:
"gpt-4"
對話訊息列表
Hide child attributes
Hide child attributes
訊息角色
可用選項:
system, user, assistant, tool, developer 訊息內容
發送者名稱
工具呼叫 ID(用於 tool 角色訊息)
推理內容
取樣溫度
必填範圍:
0 <= x <= 2核採樣參數
必填範圍:
0 <= x <= 1生成數量
必填範圍:
x >= 1是否串流回應
停止序列
最大生成 Token 數
最大生成 Token 數
必填範圍:
-2 <= x <= 2必填範圍:
-2 <= x <= 2可用選項:
none, auto, required 推理強度 (用於支援推理的模型)
可用選項:
low, medium, high 可用選項:
text, audio 回應
成功建立回應
範例:
"chat.completion"
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
訊息角色
可用選項:
system, user, assistant, tool, developer 訊息內容
發送者名稱
工具呼叫 ID(用於 tool 角色訊息)
推理內容
可用選項:
stop, length, tool_calls, content_filter Hide child attributes
Hide child attributes
提示詞 Token 數
補全 Token 數
總 Token 數
