创建响应 (OpenAI Responses API)
curl --request POST \
--url https://api.tkhub.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 123,
"temperature": 123,
"top_p": 123,
"stream": true,
"tools": [
{}
],
"tool_choice": "<string>",
"reasoning": {
"summary": "<string>"
},
"previous_response_id": "<string>"
}
'import requests
url = "https://api.tkhub.ai/v1/responses"
payload = {
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 123,
"temperature": 123,
"top_p": 123,
"stream": True,
"tools": [{}],
"tool_choice": "<string>",
"reasoning": { "summary": "<string>" },
"previous_response_id": "<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: '<string>',
input: '<string>',
instructions: '<string>',
max_output_tokens: 123,
temperature: 123,
top_p: 123,
stream: true,
tools: [{}],
tool_choice: '<string>',
reasoning: {summary: '<string>'},
previous_response_id: '<string>'
})
};
fetch('https://api.tkhub.ai/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.tkhub.ai/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' => '<string>',
'instructions' => '<string>',
'max_output_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'stream' => true,
'tools' => [
[
]
],
'tool_choice' => '<string>',
'reasoning' => [
'summary' => '<string>'
],
'previous_response_id' => '<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.tkhub.ai/v1/responses"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stream\": true,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"reasoning\": {\n \"summary\": \"<string>\"\n },\n \"previous_response_id\": \"<string>\"\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.tkhub.ai/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stream\": true,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"reasoning\": {\n \"summary\": \"<string>\"\n },\n \"previous_response_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tkhub.ai/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\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stream\": true,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"reasoning\": {\n \"summary\": \"<string>\"\n },\n \"previous_response_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "response",
"created_at": 123,
"model": "<string>",
"output": [
{
"type": "<string>",
"id": "<string>",
"status": "<string>",
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
]
}
],
"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
}
}
}OpenAI格式(Responses)
创建响应 (OpenAI Responses API)
OpenAI Responses API,用于创建模型响应。 支持多轮对话、工具调用、推理等功能。
POST
/
v1
/
responses
创建响应 (OpenAI Responses API)
curl --request POST \
--url https://api.tkhub.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 123,
"temperature": 123,
"top_p": 123,
"stream": true,
"tools": [
{}
],
"tool_choice": "<string>",
"reasoning": {
"summary": "<string>"
},
"previous_response_id": "<string>"
}
'import requests
url = "https://api.tkhub.ai/v1/responses"
payload = {
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 123,
"temperature": 123,
"top_p": 123,
"stream": True,
"tools": [{}],
"tool_choice": "<string>",
"reasoning": { "summary": "<string>" },
"previous_response_id": "<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: '<string>',
input: '<string>',
instructions: '<string>',
max_output_tokens: 123,
temperature: 123,
top_p: 123,
stream: true,
tools: [{}],
tool_choice: '<string>',
reasoning: {summary: '<string>'},
previous_response_id: '<string>'
})
};
fetch('https://api.tkhub.ai/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.tkhub.ai/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' => '<string>',
'instructions' => '<string>',
'max_output_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'stream' => true,
'tools' => [
[
]
],
'tool_choice' => '<string>',
'reasoning' => [
'summary' => '<string>'
],
'previous_response_id' => '<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.tkhub.ai/v1/responses"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stream\": true,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"reasoning\": {\n \"summary\": \"<string>\"\n },\n \"previous_response_id\": \"<string>\"\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.tkhub.ai/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stream\": true,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"reasoning\": {\n \"summary\": \"<string>\"\n },\n \"previous_response_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tkhub.ai/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\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stream\": true,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"reasoning\": {\n \"summary\": \"<string>\"\n },\n \"previous_response_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "response",
"created_at": 123,
"model": "<string>",
"output": [
{
"type": "<string>",
"id": "<string>",
"status": "<string>",
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
]
}
],
"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
}
}
}Authorizations
使用 Bearer Token 认证。
格式: Authorization: Bearer sk-xxxxxx
Body
application/json
输入内容,可以是字符串或消息数组
Show child attributes
Show child attributes
Available options:
auto, disabled Was this page helpful?
⌘I