Responses API
curl --request POST \
--url https://api.chenyu.cn/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {},
"stream": true,
"temperature": 123,
"max_output_tokens": 123,
"reasoning": {}
}
'import requests
url = "https://api.chenyu.cn/v1/responses"
payload = {
"model": "<string>",
"input": {},
"stream": True,
"temperature": 123,
"max_output_tokens": 123,
"reasoning": {}
}
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: '<string>',
input: {},
stream: true,
temperature: 123,
max_output_tokens: 123,
reasoning: {}
})
};
fetch('https://api.chenyu.cn/v1/responses', 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.chenyu.cn/v1/responses",
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>',
'input' => [
],
'stream' => true,
'temperature' => 123,
'max_output_tokens' => 123,
'reasoning' => [
]
]),
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.chenyu.cn/v1/responses"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"max_output_tokens\": 123,\n \"reasoning\": {}\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.chenyu.cn/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"max_output_tokens\": 123,\n \"reasoning\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chenyu.cn/v1/responses")
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\": \"<string>\",\n \"input\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"max_output_tokens\": 123,\n \"reasoning\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"status": "<string>",
"model": "<string>",
"output": [
{}
],
"usage": {}
}直接 API 调用
Responses API
使用 OpenAI Responses 格式调用文本模型
POST
/
v1
/
responses
Responses API
curl --request POST \
--url https://api.chenyu.cn/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {},
"stream": true,
"temperature": 123,
"max_output_tokens": 123,
"reasoning": {}
}
'import requests
url = "https://api.chenyu.cn/v1/responses"
payload = {
"model": "<string>",
"input": {},
"stream": True,
"temperature": 123,
"max_output_tokens": 123,
"reasoning": {}
}
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: '<string>',
input: {},
stream: true,
temperature: 123,
max_output_tokens: 123,
reasoning: {}
})
};
fetch('https://api.chenyu.cn/v1/responses', 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.chenyu.cn/v1/responses",
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>',
'input' => [
],
'stream' => true,
'temperature' => 123,
'max_output_tokens' => 123,
'reasoning' => [
]
]),
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.chenyu.cn/v1/responses"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"max_output_tokens\": 123,\n \"reasoning\": {}\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.chenyu.cn/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"max_output_tokens\": 123,\n \"reasoning\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chenyu.cn/v1/responses")
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\": \"<string>\",\n \"input\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"max_output_tokens\": 123,\n \"reasoning\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"status": "<string>",
"model": "<string>",
"output": [
{}
],
"usage": {}
}Responses API
使用 OpenAI Responses 兼容格式调用文本模型。适合使用input 组织请求,或需要携带模型专属参数的场景。
请求参数
输入内容。可以是字符串,也可以是 Responses 格式的输入数组
是否使用流式响应
采样温度
最大输出 token 数
推理相关参数,具体支持范围以模型为准
响应参数
响应 ID
响应类型,通常为
response响应状态,如
completed实际调用的模型 ID
输出内容数组
token 用量
代码示例
import requests
url = "https://api.chenyu.cn/v1/responses"
headers = {
"Authorization": "Bearer your_api_key",
"Content-Type": "application/json"
}
payload = {
"model": "doubao-seed-2-0-lite-260428",
"input": "用三句话说明 GPU 云服务适合哪些场景"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
const axios = require('axios');
axios.post('https://api.chenyu.cn/v1/responses', {
model: 'doubao-seed-2-0-lite-260428',
input: '用三句话说明 GPU 云服务适合哪些场景'
}, {
headers: {
Authorization: 'Bearer your_api_key',
'Content-Type': 'application/json'
}
}).then((response) => {
console.log(response.data);
});
curl -X POST "https://api.chenyu.cn/v1/responses" \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-2-0-lite-260428",
"input": "用三句话说明 GPU 云服务适合哪些场景"
}'
模型专属参数
{
"model": "doubao-seed-2-0-lite-260428",
"input": "分析这个问题",
"thinking": {"type": "enabled"},
"reasoning": {"effort": "low"}
}
响应示例
{
"id": "resp_xxx",
"object": "response",
"status": "completed",
"model": "doubao-seed-2-0-lite-260428",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "GPU 云服务适合模型训练、推理部署和批量数据处理。"
}
]
}
],
"usage": {
"input_tokens": 18,
"output_tokens": 16,
"total_tokens": 34
}
}
⌘I