curl --request POST \
--url https://model-api.skyengine.com.cn/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"model": "gpt-4o"
}
'import requests
url = "https://model-api.skyengine.com.cn/v1/chat/completions"
payload = {
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"model": "gpt-4o"
}
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({messages: [{role: 'user', content: '你好,请介绍一下你自己'}], model: 'gpt-4o'})
};
fetch('https://model-api.skyengine.com.cn/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://model-api.skyengine.com.cn/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你好,请介绍一下你自己\"\n }\n ],\n \"model\": \"gpt-4o\"\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://model-api.skyengine.com.cn/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你好,请介绍一下你自己\"\n }\n ],\n \"model\": \"gpt-4o\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://model-api.skyengine.com.cn/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([
'messages' => [
[
'role' => 'user',
'content' => '你好,请介绍一下你自己'
]
],
'model' => 'gpt-4o'
]),
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;
}{
"id": "chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"message": {
"content": "<string>",
"refusal": "<string>",
"role": "assistant",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"annotations": [
{
"type": "url_citation",
"url_citation": {
"end_index": 123,
"start_index": 123,
"url": "<string>",
"title": "<string>"
}
}
],
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"audio": {
"id": "<string>",
"expires_at": 123,
"data": "<string>",
"transcript": "<string>"
}
},
"logprobs": {
"content": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
],
"refusal": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
]
}
}
],
"created": 1741570283,
"model": "gpt-4o-2024-08-06",
"object": "chat.completion",
"service_tier": "auto",
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
}
}
}{
"error": {
"code": 123,
"message": "<string>",
"details": [
{}
]
}
}/v1/chat/completions
为给定的聊天对话创建模型响应。您可以在文本生成、视觉和音频指南中了解更多信息。
参数支持可能因用于生成响应的模型而异,特别是对于较新的推理模型。仅推理模型支持的参数将在下文中标注。
curl --request POST \
--url https://model-api.skyengine.com.cn/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"model": "gpt-4o"
}
'import requests
url = "https://model-api.skyengine.com.cn/v1/chat/completions"
payload = {
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"model": "gpt-4o"
}
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({messages: [{role: 'user', content: '你好,请介绍一下你自己'}], model: 'gpt-4o'})
};
fetch('https://model-api.skyengine.com.cn/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://model-api.skyengine.com.cn/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你好,请介绍一下你自己\"\n }\n ],\n \"model\": \"gpt-4o\"\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://model-api.skyengine.com.cn/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你好,请介绍一下你自己\"\n }\n ],\n \"model\": \"gpt-4o\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://model-api.skyengine.com.cn/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([
'messages' => [
[
'role' => 'user',
'content' => '你好,请介绍一下你自己'
]
],
'model' => 'gpt-4o'
]),
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;
}{
"id": "chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG",
"choices": [
{
"finish_reason": "stop",
"index": 123,
"message": {
"content": "<string>",
"refusal": "<string>",
"role": "assistant",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"annotations": [
{
"type": "url_citation",
"url_citation": {
"end_index": 123,
"start_index": 123,
"url": "<string>",
"title": "<string>"
}
}
],
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"audio": {
"id": "<string>",
"expires_at": 123,
"data": "<string>",
"transcript": "<string>"
}
},
"logprobs": {
"content": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
],
"refusal": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
]
}
}
],
"created": 1741570283,
"model": "gpt-4o-2024-08-06",
"object": "chat.completion",
"service_tier": "auto",
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
}
}
}{
"error": {
"code": 123,
"message": "<string>",
"details": [
{}
]
}
}Authorizations
OpenAI API密钥认证。在 Authorization HTTP Header 中包含您的 API-Key,格式为 Bearer {API_KEY}
Body
对话历史消息列表。根据您使用的模型,支持不同的消息类型(模态),如文本、图像和音频。
1- 用户消息
- 开发者消息
- 系统消息
- 助手消息
- 工具消息
- 函数消息
Show child attributes
Show child attributes
[
{ "role": "user", "content": "你好,请介绍一下你自己" }
]
用于生成响应的模型ID,如 gpt-4o。我们提供各种具有不同能力、性能特点和价格点的模型。
"gpt-4o"
请求的元数据
一个介于0和20之间的整数,指定在每个token位置返回的最可能token的数量,每个token都有相关的对数概率。如果使用此参数,必须将 logprobs 设置为 true。
0 <= x <= 20采样温度,取值范围在0到2之间。较高的值(如0.8)会使输出更加随机,而较低的值(如0.2)会使输出更加集中和确定性。 通常建议仅调整temperature或top_p其中之一,不建议两者都修改。
0 <= x <= 21
核采样的替代方法,称为nucleus采样,模型考虑具有top_p概率质量的token结果。例如,0.1意味着只考虑构成前10%概率质量的token。 通常建议仅调整temperature或top_p其中之一,不建议两者都修改。
0 <= x <= 11
此字段正在被safety_identifier和prompt_cache_key替代。请使用prompt_cache_key来维持缓存优化。 用于您的终端用户的稳定标识符。用于提高缓存命中率,通过更好地分组类似请求,并帮助检测和防止滥用。
"user-1234"
一个稳定的标识符,用于帮助检测可能违反使用政策的用户。ID应该是唯一标识每个用户的字符串。我们建议对用户名或电子邮件地址进行哈希处理,以避免向我们发送任何识别信息。
"safety-identifier-1234"
用于缓存类似请求的响应以优化缓存命中率。替代user字段。
"prompt-cache-key-1234"
服务层级
default, scale 指定响应中应包含的模态类型。
text, audio 控制模型响应的详细程度。
low, medium, high 限制推理模型的推理努力程度。当前支持的值有 minimal、low、medium 和 high。减少推理努力可以导致更快的响应和在响应中使用更少的推理token。
minimal, low, medium, high 完成部分可生成的token数量上限,包括可见的输出token和推理token。
-2.0到2.0之间的数字。正值会根据文本中已有的频率对新token进行惩罚,降低模型逐字重复相同内容的可能性。
-2 <= x <= 2-2.0到2.0之间的数字。正值会根据token是否已在文本中出现过进行惩罚,增加模型谈论新主题的可能性。
-2 <= x <= 2这个工具会搜索网络以获取相关结果用于响应。
Show child attributes
Show child attributes
指定模型必须输出的格式。
设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型匹配您提供的JSON模式。
设置为 { "type": "json_object" } 启用旧版JSON模式,确保模型生成的消息是有效的JSON。对于支持的模型,推荐使用 json_schema。
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
音频输出参数。当使用 modalities: ["audio"] 请求音频输出时需要。
Show child attributes
Show child attributes
是否存储此聊天完成请求的输出以用于模型蒸馏或评估产品。
支持文本和图像输入。注意:超过8MB的图像输入将被丢弃。
如果设置为true,模型响应数据将使用服务器发送事件(SSE)实时流式传输。 有关更多信息,请参阅流式响应指南。
最新推理模型 o3 和 o4-mini 不支持。
最多4个序列,API将在生成这些序列时停止生成更多token。返回的文本不会包含停止序列。
"\n"
修改指定token在完成中出现的可能性。
接受一个JSON对象,将token(通过其在分词器中的token ID指定)映射到-100到100之间的偏置值。在采样之前,偏置值会添加到模型生成的logits中。具体效果因模型而异,但-1到1之间的值应该会降低或增加选择的可能性;像-100或100这样的值应该会导致相关token被禁止或独占选择。
Show child attributes
Show child attributes
是否返回输出token的对数概率。如果为true,将在 message 的 content 中返回每个输出token的对数概率。
可以在聊天完成中生成的最大token数。这个值可用于控制通过API生成的文本的成本。
此值现已被 max_completion_tokens 取代,且与o系列模型不兼容。
为每个输入消息生成的聊天完成数量。请注意,您将根据所有选择生成的token数量被收费。保持 n 为 1 以最小化成本。
1 <= x <= 1281
预测输出配置,当模型响应的大部分内容事先已知时,可以大大提高响应时间。这在您要重新生成文件且大部分内容只有微小变化时最为常见。
Show child attributes
Show child attributes
此功能处于Beta阶段。
如果指定,我们的系统将尽最大努力确定性采样,使得具有相同 seed 和参数的重复请求应返回相同的结果。
不保证确定性,您应该参考响应参数中的 system_fingerprint 来监控后端的变化。
-9223372036854776000 <= x <= 9223372036854776000流式聊天完成的选项。
Show child attributes
Show child attributes
模型可能调用的工具列表。您可以提供自定义工具或函数工具。
- 函数工具
- 自定义工具
Show child attributes
Show child attributes
工具选择策略。'auto'表示模型自动决定是否使用工具,'none'表示不使用工具,'required'表示必须使用工具。
auto, none, required 是否允许模型并行调用多个工具。
已被 tool_choice 取代。
控制模型是否调用函数。
none 表示模型不会调用函数,而是生成一条消息。
auto 表示模型可以在生成消息和调用函数之间选择。
通过 {"name": "my_function"} 指定特定函数会强制模型调用该函数。
当没有函数存在时,默认为 none。当存在函数时,默认为 auto。
none, auto 已被 tools 取代。
模型可能为其生成JSON输入的函数列表。
1 - 128 elementsShow child attributes
Show child attributes
Response
返回聊天完成对象,如果请求是流式的,则返回聊天完成块对象的流式序列。
表示模型根据提供的输入返回的聊天完成响应。
聊天完成的唯一标识符。
"chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG"
聊天完成选项列表。如果 n 大于1,可以包含多个选项。
Show child attributes
Show child attributes
创建聊天完成的Unix时间戳(秒)。
1741570283
用于聊天完成的模型。
"gpt-4o-2024-08-06"
对象类型,始终为chat.completion。
chat.completion "chat.completion"
指定用于处理请求的处理类型。
- 如果设置为'auto',则请求将使用项目设置中配置的服务层级进行处理。除非另有配置,否则项目将使用'default'。
- 如果设置为'default',则请求将使用所选模型的标准定价和性能进行处理。
- 如果设置为'flex'或'priority',则请求将使用相应的服务层级进行处理。
- 未设置时,默认行为为'auto'。
设置service_tier参数时,响应体将包含基于实际用于处理请求的处理模式的service_tier值。此响应值可能与参数中设置的值不同。
auto, default, flex, scale, priority 此指纹代表模型运行的后端配置。可以与请求参数seed结合使用,以了解可能影响确定性的后端变化。
"fp_44709d6fcb"
完成请求的使用统计信息。
Show child attributes
Show child attributes

