跳转到主要内容
POST
/
openai
/
v1
/
chat
/
completions
创建聊天对话请求
curl --request POST \
  --url https://api.ppio.com/openai/v1/chat/completions \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "model": "<string>",
  "messages": [
    {
      "content": {
        "type": "<string>",
        "text": "<string>",
        "image_url": "<string>",
        "video_url": "<string>",
        "modalities": [
          "<string>"
        ],
        "input_audio": {
          "data": "<string>",
          "format": "<string>"
        }
      },
      "role": "<string>",
      "name": {}
    }
  ],
  "max_tokens": 123,
  "stream": {},
  "stream_options": {
    "include_usage": true
  },
  "n": {},
  "seed": {},
  "frequency_penalty": {},
  "presence_penalty": {},
  "repetition_penalty": {},
  "stop": {},
  "temperature": {},
  "top_p": {},
  "top_k": {},
  "min_p": {},
  "logit_bias": {},
  "logprobs": {},
  "top_logprobs": {},
  "tools": {
    "type": "<string>",
    "function": {
      "name": "<string>",
      "description": {},
      "parameters": {},
      "strict": true
    }
  },
  "response_format": {
    "type": "<string>",
    "json_schema": {
      "name": "<string>",
      "description": {},
      "schema": {},
      "strict": true
    }
  },
  "separate_reasoning": {},
  "enable_thinking": {}
}
'
import requests

url = "https://api.ppio.com/openai/v1/chat/completions"

payload = {
"model": "<string>",
"messages": [
{
"content": {
"type": "<string>",
"text": "<string>",
"image_url": "<string>",
"video_url": "<string>",
"modalities": ["<string>"],
"input_audio": {
"data": "<string>",
"format": "<string>"
}
},
"role": "<string>",
"name": {}
}
],
"max_tokens": 123,
"stream": {},
"stream_options": { "include_usage": True },
"n": {},
"seed": {},
"frequency_penalty": {},
"presence_penalty": {},
"repetition_penalty": {},
"stop": {},
"temperature": {},
"top_p": {},
"top_k": {},
"min_p": {},
"logit_bias": {},
"logprobs": {},
"top_logprobs": {},
"tools": {
"type": "<string>",
"function": {
"name": "<string>",
"description": {},
"parameters": {},
"strict": True
}
},
"response_format": {
"type": "<string>",
"json_schema": {
"name": "<string>",
"description": {},
"schema": {},
"strict": True
}
},
"separate_reasoning": {},
"enable_thinking": {}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
model: '<string>',
messages: [
{
content: {
type: '<string>',
text: '<string>',
image_url: '<string>',
video_url: '<string>',
modalities: ['<string>'],
input_audio: {data: '<string>', format: '<string>'}
},
role: '<string>',
name: {}
}
],
max_tokens: 123,
stream: {},
stream_options: {include_usage: true},
n: {},
seed: {},
frequency_penalty: {},
presence_penalty: {},
repetition_penalty: {},
stop: {},
temperature: {},
top_p: {},
top_k: {},
min_p: {},
logit_bias: {},
logprobs: {},
top_logprobs: {},
tools: {
type: '<string>',
function: {name: '<string>', description: {}, parameters: {}, strict: true}
},
response_format: {
type: '<string>',
json_schema: {name: '<string>', description: {}, schema: {}, strict: true}
},
separate_reasoning: {},
enable_thinking: {}
})
};

fetch('https://api.ppio.com/openai/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.ppio.com/openai/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' => '<string>',
'messages' => [
[
'content' => [
'type' => '<string>',
'text' => '<string>',
'image_url' => '<string>',
'video_url' => '<string>',
'modalities' => [
'<string>'
],
'input_audio' => [
'data' => '<string>',
'format' => '<string>'
]
],
'role' => '<string>',
'name' => [

]
]
],
'max_tokens' => 123,
'stream' => [

],
'stream_options' => [
'include_usage' => true
],
'n' => [

],
'seed' => [

],
'frequency_penalty' => [

],
'presence_penalty' => [

],
'repetition_penalty' => [

],
'stop' => [

],
'temperature' => [

],
'top_p' => [

],
'top_k' => [

],
'min_p' => [

],
'logit_bias' => [

],
'logprobs' => [

],
'top_logprobs' => [

],
'tools' => [
'type' => '<string>',
'function' => [
'name' => '<string>',
'description' => [

],
'parameters' => [

],
'strict' => true
]
],
'response_format' => [
'type' => '<string>',
'json_schema' => [
'name' => '<string>',
'description' => [

],
'schema' => [

],
'strict' => true
]
],
'separate_reasoning' => [

],
'enable_thinking' => [

]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);

$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.ppio.com/openai/v1/chat/completions"

payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": {}\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")

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.ppio.com/openai/v1/chat/completions")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": {}\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.ppio.com/openai/v1/chat/completions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": {\n \"type\": \"<string>\",\n \"text\": \"<string>\",\n \"image_url\": \"<string>\",\n \"video_url\": \"<string>\",\n \"modalities\": [\n \"<string>\"\n ],\n \"input_audio\": {\n \"data\": \"<string>\",\n \"format\": \"<string>\"\n }\n },\n \"role\": \"<string>\",\n \"name\": {}\n }\n ],\n \"max_tokens\": 123,\n \"stream\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"n\": {},\n \"seed\": {},\n \"frequency_penalty\": {},\n \"presence_penalty\": {},\n \"repetition_penalty\": {},\n \"stop\": {},\n \"temperature\": {},\n \"top_p\": {},\n \"top_k\": {},\n \"min_p\": {},\n \"logit_bias\": {},\n \"logprobs\": {},\n \"top_logprobs\": {},\n \"tools\": {\n \"type\": \"<string>\",\n \"function\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"parameters\": {},\n \"strict\": true\n }\n },\n \"response_format\": {\n \"type\": \"<string>\",\n \"json_schema\": {\n \"name\": \"<string>\",\n \"description\": {},\n \"schema\": {},\n \"strict\": true\n }\n },\n \"separate_reasoning\": {},\n \"enable_thinking\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "choices": [
    {
      "finish_reason": "<string>",
      "index": 123,
      "message": {
        "role": "<string>",
        "content": {},
        "reasoning_content": {}
      }
    }
  ],
  "created": 123,
  "id": "<string>",
  "model": "<string>",
  "object": "<string>",
  "usage": {
    "completion_tokens": 123,
    "prompt_tokens": 123,
    "total_tokens": 123
  }
}
根据指定的聊天对话生成模型回复

请求头

Content-Type
string
必填
枚举值: application/json
Authorization
string
必填
Bearer 身份验证格式,例如:Bearer {{API 密钥}}。

请求体

model
string
必填
对应的模型名称。可用模型名称请参考:模型列表
messages
object[]
必填
截至目前组成对话的消息列表。
max_tokens
integer
必填
在生成对话时可产生的最大 tokens 数。

如果您的提示(之前的消息)中的 tokens 数量加上 max_tokens 超过了模型的上下文长度,则行为取决于 context_length_exceeded_behavior。默认情况下,max_tokens 会被调整以适应上下文窗口,而不是返回错误。
stream
boolean | null
是否使用流式传输。默认为 false,如果设置了,tokens 将以 data-only server-sent events(SSE)发送,并以 data: [DONE] 消息终止流。
stream_options
object
流式回复选项。仅当 stream 设置为 true 时设置。
n
integer | null
每个提示生成多少个对话。默认值为 1。

注意:由于此参数会生成多个对话,因此可能会快速消耗您的 tokens 计费额度。请谨慎使用,并确保为 max_tokens 和 stop 设置了合理的值。
所需范围:1 < x < 128
seed
integer | null
如果指定,我们的系统将尽最大努力进行确定性采样,以便相同的 seed 和参数的重复请求应返回相同的结果。
frequency_penalty
number | null
默认值为 0,正值会根据新 tokens 在当前文本中的出现频率对其进行惩罚,从而降低模型重复相同内容的可能性。

如果目的是仅仅减少重复样本,合理的值大约在 0.1 到 1 之间。如果目的是强烈抑制重复,可以将系数提高到 2,但这可能会明显降低样本质量。负值可以用来增加重复的可能性。

另见 presence_penalty,用于以固定速率惩罚至少出现一次的 tokens
所需范围:-2 < x < 2
presence_penalty
number | null
默认值为 0,正值会根据新 tokens 是否出现在当前文本中对其进行惩罚,从而增加模型谈论新话题的可能性。

如果目的是稍微减少重复样本,合理的值大约在 0.1 到 1 之间。如果目的是强烈抑制重复,可以将系数提高到 2,但这可能会显著降低样本质量。负值可以用来增加重复的可能性。

另见 frequency_penalty,用于根据 tokens 出现的频率按递增速率进行惩罚
所需范围:-2 < x < 2
repetition_penalty
number | null
对重复的 tokens 应用惩罚,以抑制或鼓励重复。值为 1.0 表示没有惩罚,允许自由重复。大于 1.0 的值会惩罚重复,降低重复 tokens 的可能性。介于 0.0 和 1.0 之间的值会奖励重复,增加重复 tokens 的机会。为了达到良好的平衡,通常建议使用 1.2。请注意,在仅解码器模型中,惩罚会同时应用于生成的输出和提示。
所需范围:0 < x < 2
stop
string | null
最多 4 个序列,API 将停止生成更多 tokens。返回的文本包含停止序列。
temperature
number | null
对话中的随机性程度,默认值为 1,介于 0 和 2 之间。较高的值(如 0.8)会使输出更加随机,而较低的值(如 0.2),会使输出更集中且确定性更强。

我们通常建议只调整此项或 top_p,而不是同时调整两者。
所需范围:0 < x < 2
top_p
number | null
作为 temperature 的替代方法,称为 nucleus sampling,模型会考虑具有 top_p 概率质量的 tokens 的结果。因此,0.1 意味着只考虑构成前 10% 概率质量的 tokens。我们通常建议只调整此项或 temperature,而不是同时调整两者。
所需范围:0 < x ≤ 1
top_k
integer | null
Top-k 采样是另一种采样方法,在这种方法中,k 个最可能的下一个 tokens 会被筛选出来,并且概率质量仅在这 k 个 tokens 之间重新分配。k 的值控制了在每一步生成文本时,下一个 tokens 的候选数量。
所需范围:1 < x < 128
min_p
number | null
表示一个 tokens 被考虑的最小概率的浮动值,相对于最有可能的 tokens 的概率。
所需范围:0 ≤ x ≤ 1
logit_bias
map[string, integer]
默认为 null。修改指定 tokens 在对话中出现的可能性。接受一个 JSON 对象,将 tokens 映射到一个从 -100 到 100 的关联偏差值。
logprobs
boolean | null
是否返回输出 tokens 的对数概率。如果为 true,则返回消息内容中每个输出 tokens 的对数概率。
top_logprobs
integer | null
一个介于 0 到 20 之间的整数,指定在每个 tokens 位置返回的最可能的 tokens 数量,每个 tokens 都有一个关联的对数概率。如果使用此参数,必须将 logprobs 设置为 true。
所需范围:0 ≤ x ≤ 20
tools
object[] | null
模型可以调用的工具列表。目前仅支持函数作为工具。使用此参数提供模型可能生成 JSON 输入的函数列表。工具调用(Function Calling)中了解更多关于函数调用的信息。
response_format
object | null
允许强制模型产生特定的输出格式。设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型匹配您提供的 JSON schema。设置为 { "type": "json_object" } 启用较旧的 JSON 模式,确保模型生成的消息是有效的 JSON。对于支持的模型,推荐使用 json_schema
separate_reasoning
boolean | null
控制是否将 “思考内容” 单独放入 “reasoning_content” 字段中。默认为 false,即不单独返回 “思考内容”。目前支持的模型:deepseek/deepseek-r1-turbo
enable_thinking
boolean | null
默认值:false
控制是否开启思考模式。目前支持的模型:
  • zai-org/glm-4.5
  • deepseek/deepseek-v3.1
  • deepseek/deepseek-v3.1-terminus
  • deepseek/deepseek-v3.2-exp

响应参数

choices
object[]
必填
生成的对话选择列表。
created
integer
必填
响应生成的 Unix 时间戳(以秒为单位)。
id
string
必填
响应的唯一标识符。
model
string
必填
用于对话的模型。
object
string
必填
对象类型,始终为 chat.completion。
usage
object
使用统计。
对于流式回复,usage 字段被包含在返回的最后一个回复块中。
最后修改于 2026年7月6日