curl --request POST \
--url https://api.ttapi.io/v1/responses \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.4-mini",
"input": "请用通俗语言解释量子计算。",
"instructions": "<string>",
"previous_response_id": "<string>",
"conversation": "<string>",
"background": false,
"include": [],
"max_output_tokens": 2,
"max_tool_calls": 2,
"metadata": {},
"parallel_tool_calls": true,
"prompt_cache_key": "<string>",
"reasoning": {},
"safety_identifier": "<string>",
"store": true,
"stream": false,
"stream_options": {
"include_obfuscation": true
},
"temperature": 1,
"text": {
"format": {}
},
"tools": [
{}
],
"top_logprobs": 10,
"top_p": 0.5,
"truncation": "disabled"
}
'import requests
url = "https://api.ttapi.io/v1/responses"
payload = {
"model": "gpt-5.4-mini",
"input": "请用通俗语言解释量子计算。",
"instructions": "<string>",
"previous_response_id": "<string>",
"conversation": "<string>",
"background": False,
"include": [],
"max_output_tokens": 2,
"max_tool_calls": 2,
"metadata": {},
"parallel_tool_calls": True,
"prompt_cache_key": "<string>",
"reasoning": {},
"safety_identifier": "<string>",
"store": True,
"stream": False,
"stream_options": { "include_obfuscation": True },
"temperature": 1,
"text": { "format": {} },
"tools": [{}],
"top_logprobs": 10,
"top_p": 0.5,
"truncation": "disabled"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-5.4-mini',
input: '请用通俗语言解释量子计算。',
instructions: '<string>',
previous_response_id: '<string>',
conversation: '<string>',
background: false,
include: [],
max_output_tokens: 2,
max_tool_calls: 2,
metadata: {},
parallel_tool_calls: true,
prompt_cache_key: '<string>',
reasoning: {},
safety_identifier: '<string>',
store: true,
stream: false,
stream_options: {include_obfuscation: true},
temperature: 1,
text: {format: {}},
tools: [{}],
top_logprobs: 10,
top_p: 0.5,
truncation: 'disabled'
})
};
fetch('https://api.ttapi.io/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.ttapi.io/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' => 'gpt-5.4-mini',
'input' => '请用通俗语言解释量子计算。',
'instructions' => '<string>',
'previous_response_id' => '<string>',
'conversation' => '<string>',
'background' => false,
'include' => [
],
'max_output_tokens' => 2,
'max_tool_calls' => 2,
'metadata' => [
],
'parallel_tool_calls' => true,
'prompt_cache_key' => '<string>',
'reasoning' => [
],
'safety_identifier' => '<string>',
'store' => true,
'stream' => false,
'stream_options' => [
'include_obfuscation' => true
],
'temperature' => 1,
'text' => [
'format' => [
]
],
'tools' => [
[
]
],
'top_logprobs' => 10,
'top_p' => 0.5,
'truncation' => 'disabled'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.ttapi.io/v1/responses"
payload := strings.NewReader("{\n \"model\": \"gpt-5.4-mini\",\n \"input\": \"请用通俗语言解释量子计算。\",\n \"instructions\": \"<string>\",\n \"previous_response_id\": \"<string>\",\n \"conversation\": \"<string>\",\n \"background\": false,\n \"include\": [],\n \"max_output_tokens\": 2,\n \"max_tool_calls\": 2,\n \"metadata\": {},\n \"parallel_tool_calls\": true,\n \"prompt_cache_key\": \"<string>\",\n \"reasoning\": {},\n \"safety_identifier\": \"<string>\",\n \"store\": true,\n \"stream\": false,\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"temperature\": 1,\n \"text\": {\n \"format\": {}\n },\n \"tools\": [\n {}\n ],\n \"top_logprobs\": 10,\n \"top_p\": 0.5,\n \"truncation\": \"disabled\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.ttapi.io/v1/responses")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-5.4-mini\",\n \"input\": \"请用通俗语言解释量子计算。\",\n \"instructions\": \"<string>\",\n \"previous_response_id\": \"<string>\",\n \"conversation\": \"<string>\",\n \"background\": false,\n \"include\": [],\n \"max_output_tokens\": 2,\n \"max_tool_calls\": 2,\n \"metadata\": {},\n \"parallel_tool_calls\": true,\n \"prompt_cache_key\": \"<string>\",\n \"reasoning\": {},\n \"safety_identifier\": \"<string>\",\n \"store\": true,\n \"stream\": false,\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"temperature\": 1,\n \"text\": {\n \"format\": {}\n },\n \"tools\": [\n {}\n ],\n \"top_logprobs\": 10,\n \"top_p\": 0.5,\n \"truncation\": \"disabled\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-5.4-mini\",\n \"input\": \"请用通俗语言解释量子计算。\",\n \"instructions\": \"<string>\",\n \"previous_response_id\": \"<string>\",\n \"conversation\": \"<string>\",\n \"background\": false,\n \"include\": [],\n \"max_output_tokens\": 2,\n \"max_tool_calls\": 2,\n \"metadata\": {},\n \"parallel_tool_calls\": true,\n \"prompt_cache_key\": \"<string>\",\n \"reasoning\": {},\n \"safety_identifier\": \"<string>\",\n \"store\": true,\n \"stream\": false,\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"temperature\": 1,\n \"text\": {\n \"format\": {}\n },\n \"tools\": [\n {}\n ],\n \"top_logprobs\": 10,\n \"top_p\": 0.5,\n \"truncation\": \"disabled\"\n}"
response = http.request(request)
puts response.read_body{
"id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b",
"object": "response",
"created_at": 1741476542,
"status": "completed",
"model": "<string>",
"output": [
{
"type": "<string>",
"id": "<string>",
"status": "<string>",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "<string>",
"refusal": "<string>",
"annotations": [
{}
],
"logprobs": [
{}
]
}
],
"call_id": "<string>",
"name": "<string>",
"arguments": "<string>"
}
],
"error": {
"code": "<string>",
"message": "<string>"
},
"incomplete_details": {
"reason": "max_output_tokens"
},
"output_text": "<string>",
"previous_response_id": "<string>",
"store": true,
"usage": {
"input_tokens": 123,
"input_tokens_details": {
"cached_tokens": 123
},
"output_tokens": 123,
"output_tokens_details": {
"reasoning_tokens": 123
},
"total_tokens": 123
},
"metadata": {}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}Responses
根据文本、图像或文件输入创建模型响应,支持结构化输出、工具调用、对话状态、后台处理和流式响应。
curl --request POST \
--url https://api.ttapi.io/v1/responses \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.4-mini",
"input": "请用通俗语言解释量子计算。",
"instructions": "<string>",
"previous_response_id": "<string>",
"conversation": "<string>",
"background": false,
"include": [],
"max_output_tokens": 2,
"max_tool_calls": 2,
"metadata": {},
"parallel_tool_calls": true,
"prompt_cache_key": "<string>",
"reasoning": {},
"safety_identifier": "<string>",
"store": true,
"stream": false,
"stream_options": {
"include_obfuscation": true
},
"temperature": 1,
"text": {
"format": {}
},
"tools": [
{}
],
"top_logprobs": 10,
"top_p": 0.5,
"truncation": "disabled"
}
'import requests
url = "https://api.ttapi.io/v1/responses"
payload = {
"model": "gpt-5.4-mini",
"input": "请用通俗语言解释量子计算。",
"instructions": "<string>",
"previous_response_id": "<string>",
"conversation": "<string>",
"background": False,
"include": [],
"max_output_tokens": 2,
"max_tool_calls": 2,
"metadata": {},
"parallel_tool_calls": True,
"prompt_cache_key": "<string>",
"reasoning": {},
"safety_identifier": "<string>",
"store": True,
"stream": False,
"stream_options": { "include_obfuscation": True },
"temperature": 1,
"text": { "format": {} },
"tools": [{}],
"top_logprobs": 10,
"top_p": 0.5,
"truncation": "disabled"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-5.4-mini',
input: '请用通俗语言解释量子计算。',
instructions: '<string>',
previous_response_id: '<string>',
conversation: '<string>',
background: false,
include: [],
max_output_tokens: 2,
max_tool_calls: 2,
metadata: {},
parallel_tool_calls: true,
prompt_cache_key: '<string>',
reasoning: {},
safety_identifier: '<string>',
store: true,
stream: false,
stream_options: {include_obfuscation: true},
temperature: 1,
text: {format: {}},
tools: [{}],
top_logprobs: 10,
top_p: 0.5,
truncation: 'disabled'
})
};
fetch('https://api.ttapi.io/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.ttapi.io/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' => 'gpt-5.4-mini',
'input' => '请用通俗语言解释量子计算。',
'instructions' => '<string>',
'previous_response_id' => '<string>',
'conversation' => '<string>',
'background' => false,
'include' => [
],
'max_output_tokens' => 2,
'max_tool_calls' => 2,
'metadata' => [
],
'parallel_tool_calls' => true,
'prompt_cache_key' => '<string>',
'reasoning' => [
],
'safety_identifier' => '<string>',
'store' => true,
'stream' => false,
'stream_options' => [
'include_obfuscation' => true
],
'temperature' => 1,
'text' => [
'format' => [
]
],
'tools' => [
[
]
],
'top_logprobs' => 10,
'top_p' => 0.5,
'truncation' => 'disabled'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.ttapi.io/v1/responses"
payload := strings.NewReader("{\n \"model\": \"gpt-5.4-mini\",\n \"input\": \"请用通俗语言解释量子计算。\",\n \"instructions\": \"<string>\",\n \"previous_response_id\": \"<string>\",\n \"conversation\": \"<string>\",\n \"background\": false,\n \"include\": [],\n \"max_output_tokens\": 2,\n \"max_tool_calls\": 2,\n \"metadata\": {},\n \"parallel_tool_calls\": true,\n \"prompt_cache_key\": \"<string>\",\n \"reasoning\": {},\n \"safety_identifier\": \"<string>\",\n \"store\": true,\n \"stream\": false,\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"temperature\": 1,\n \"text\": {\n \"format\": {}\n },\n \"tools\": [\n {}\n ],\n \"top_logprobs\": 10,\n \"top_p\": 0.5,\n \"truncation\": \"disabled\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.ttapi.io/v1/responses")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-5.4-mini\",\n \"input\": \"请用通俗语言解释量子计算。\",\n \"instructions\": \"<string>\",\n \"previous_response_id\": \"<string>\",\n \"conversation\": \"<string>\",\n \"background\": false,\n \"include\": [],\n \"max_output_tokens\": 2,\n \"max_tool_calls\": 2,\n \"metadata\": {},\n \"parallel_tool_calls\": true,\n \"prompt_cache_key\": \"<string>\",\n \"reasoning\": {},\n \"safety_identifier\": \"<string>\",\n \"store\": true,\n \"stream\": false,\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"temperature\": 1,\n \"text\": {\n \"format\": {}\n },\n \"tools\": [\n {}\n ],\n \"top_logprobs\": 10,\n \"top_p\": 0.5,\n \"truncation\": \"disabled\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-5.4-mini\",\n \"input\": \"请用通俗语言解释量子计算。\",\n \"instructions\": \"<string>\",\n \"previous_response_id\": \"<string>\",\n \"conversation\": \"<string>\",\n \"background\": false,\n \"include\": [],\n \"max_output_tokens\": 2,\n \"max_tool_calls\": 2,\n \"metadata\": {},\n \"parallel_tool_calls\": true,\n \"prompt_cache_key\": \"<string>\",\n \"reasoning\": {},\n \"safety_identifier\": \"<string>\",\n \"store\": true,\n \"stream\": false,\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"temperature\": 1,\n \"text\": {\n \"format\": {}\n },\n \"tools\": [\n {}\n ],\n \"top_logprobs\": 10,\n \"top_p\": 0.5,\n \"truncation\": \"disabled\"\n}"
response = http.request(request)
puts response.read_body{
"id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b",
"object": "response",
"created_at": 1741476542,
"status": "completed",
"model": "<string>",
"output": [
{
"type": "<string>",
"id": "<string>",
"status": "<string>",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "<string>",
"refusal": "<string>",
"annotations": [
{}
],
"logprobs": [
{}
]
}
],
"call_id": "<string>",
"name": "<string>",
"arguments": "<string>"
}
],
"error": {
"code": "<string>",
"message": "<string>"
},
"incomplete_details": {
"reason": "max_output_tokens"
},
"output_text": "<string>",
"previous_response_id": "<string>",
"store": true,
"usage": {
"input_tokens": 123,
"input_tokens_details": {
"cached_tokens": 123
},
"output_tokens": 123,
"output_tokens_details": {
"reasoning_tokens": 123
},
"total_tokens": 123
},
"metadata": {}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}请求体
OpenAI 兼容 Responses API 的请求体。
发送给模型的文本、图像或文件输入;字符串会被视为用户消息。
"请用通俗语言解释量子计算。"
插入模型上下文的 system 或 developer 指令。使用 previous_response_id 时不会继承上一响应的指令。
上一条响应的 ID,用于多轮对话;不能与 conversation 同时使用。
此响应所属的对话。
是否在后台运行响应。
指定响应中需要额外包含的输出数据。
file_search_call.results, web_search_call.results, web_search_call.action.sources, message.input_image.image_url, computer_call_output.output.image_url, code_interpreter_call.outputs, reasoning.encrypted_content, message.output_text.logprobs 可生成的最大 token 数,包括可见输出和推理 token。
x >= 1本次响应可处理的内置工具调用总数上限。
x >= 1附加到响应的最多 16 个字符串键值对。
Show child attributes
Show child attributes
是否允许模型并行调用工具。
可复用提示词模板及变量。
Show child attributes
Show child attributes
用于提高提示词缓存命中率的稳定键。
提示词缓存保留策略。
in-memory, 24h 受支持模型的推理配置。
Show child attributes
Show child attributes
用于滥用检测的稳定终端用户标识。
auto, default, flex, scale, priority 是否存储生成的响应,以便后续通过 API 获取。
是否通过服务器发送事件(SSE)流式返回响应。
流式响应选项,仅在 stream 为 true 时设置。
Show child attributes
Show child attributes
采样温度。通常只调整 temperature 或 top_p 其中之一。
0 <= x <= 2Show child attributes
Show child attributes
控制模型可调用哪些工具。
none, auto, required 提供给模型的函数工具或受支持的内置工具。
0 <= x <= 200 <= x <= 1auto, disabled 响应
请求成功。stream 为 true 时返回服务器发送事件。
"resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b"
"response"1741476542
completed, failed, in_progress, cancelled, queued, incomplete Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
SDK 提供的聚合文本输出便捷字段。
Show child attributes
Show child attributes
Show child attributes
Show child attributes