curl --request POST \
--url https://api.haitoken.ai/v1/responses \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"model": "<string>",
"context_management": [
{
"compact_threshold": 123,
"type": "<string>"
}
],
"max_output_tokens": 123,
"max_tool_calls": 123,
"parallel_tool_calls": true,
"previous_response_id": "<string>",
"prompt_cache_key": "<string>",
"safety_identifier": "<string>",
"stream_options": {
"include_obfuscation": true
},
"top_logprobs": 123,
"top_p": 123,
"background": true,
"conversation": {},
"include": [
"<string>"
],
"instructions": "<string>",
"metadata": {
"metadata": "new java.util.HashMap<>()"
},
"moderation": {
"input": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
},
"output": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
},
"reasoning": {},
"store": false,
"stream": false,
"temperature": 123,
"text": {
"format": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
},
"verbosity": "<string>"
},
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": true,
"defer_loading": true
}
],
"user": "<string>"
}
'import requests
url = "https://api.haitoken.ai/v1/responses"
payload = {
"input": "<string>",
"model": "<string>",
"context_management": [
{
"compact_threshold": 123,
"type": "<string>"
}
],
"max_output_tokens": 123,
"max_tool_calls": 123,
"parallel_tool_calls": True,
"previous_response_id": "<string>",
"prompt_cache_key": "<string>",
"safety_identifier": "<string>",
"stream_options": { "include_obfuscation": True },
"top_logprobs": 123,
"top_p": 123,
"background": True,
"conversation": {},
"include": ["<string>"],
"instructions": "<string>",
"metadata": { "metadata": "new java.util.HashMap<>()" },
"moderation": {
"input": {
"category_applied_input_types": { "key": {} },
"category_scores": { "key": {} },
"categories": { "key": {} },
"flagged": True,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
},
"output": {
"category_applied_input_types": { "key": {} },
"category_scores": { "key": {} },
"categories": { "key": {} },
"flagged": True,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
},
"reasoning": {},
"store": False,
"stream": False,
"temperature": 123,
"text": {
"format": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": True
},
"verbosity": "<string>"
},
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": True,
"defer_loading": True
}
],
"user": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input: '<string>',
model: '<string>',
context_management: [{compact_threshold: 123, type: '<string>'}],
max_output_tokens: 123,
max_tool_calls: 123,
parallel_tool_calls: true,
previous_response_id: '<string>',
prompt_cache_key: '<string>',
safety_identifier: '<string>',
stream_options: {include_obfuscation: true},
top_logprobs: 123,
top_p: 123,
background: true,
conversation: {},
include: ['<string>'],
instructions: '<string>',
metadata: {metadata: 'new java.util.HashMap<>()'},
moderation: {
input: {
category_applied_input_types: {key: {}},
category_scores: {key: {}},
categories: {key: {}},
flagged: true,
model: '<string>',
type: '<string>',
code: '<string>',
message: '<string>'
},
output: {
category_applied_input_types: {key: {}},
category_scores: {key: {}},
categories: {key: {}},
flagged: true,
model: '<string>',
type: '<string>',
code: '<string>',
message: '<string>'
}
},
reasoning: {},
store: false,
stream: false,
temperature: 123,
text: {
format: {name: '<string>', description: '<string>', schema: {}, strict: true},
verbosity: '<string>'
},
tools: [
{
type: 'function',
name: '<string>',
description: '<string>',
parameters: {},
strict: true,
defer_loading: true
}
],
user: '<string>'
})
};
fetch('https://api.haitoken.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.haitoken.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([
'input' => '<string>',
'model' => '<string>',
'context_management' => [
[
'compact_threshold' => 123,
'type' => '<string>'
]
],
'max_output_tokens' => 123,
'max_tool_calls' => 123,
'parallel_tool_calls' => true,
'previous_response_id' => '<string>',
'prompt_cache_key' => '<string>',
'safety_identifier' => '<string>',
'stream_options' => [
'include_obfuscation' => true
],
'top_logprobs' => 123,
'top_p' => 123,
'background' => true,
'conversation' => [
],
'include' => [
'<string>'
],
'instructions' => '<string>',
'metadata' => [
'metadata' => 'new java.util.HashMap<>()'
],
'moderation' => [
'input' => [
'category_applied_input_types' => [
'key' => [
]
],
'category_scores' => [
'key' => [
]
],
'categories' => [
'key' => [
]
],
'flagged' => true,
'model' => '<string>',
'type' => '<string>',
'code' => '<string>',
'message' => '<string>'
],
'output' => [
'category_applied_input_types' => [
'key' => [
]
],
'category_scores' => [
'key' => [
]
],
'categories' => [
'key' => [
]
],
'flagged' => true,
'model' => '<string>',
'type' => '<string>',
'code' => '<string>',
'message' => '<string>'
]
],
'reasoning' => [
],
'store' => false,
'stream' => false,
'temperature' => 123,
'text' => [
'format' => [
'name' => '<string>',
'description' => '<string>',
'schema' => [
],
'strict' => true
],
'verbosity' => '<string>'
],
'tools' => [
[
'type' => 'function',
'name' => '<string>',
'description' => '<string>',
'parameters' => [
],
'strict' => true,
'defer_loading' => true
]
],
'user' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.haitoken.ai/v1/responses"
payload := strings.NewReader("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"context_management\": [\n {\n \"compact_threshold\": 123,\n \"type\": \"<string>\"\n }\n ],\n \"max_output_tokens\": 123,\n \"max_tool_calls\": 123,\n \"parallel_tool_calls\": true,\n \"previous_response_id\": \"<string>\",\n \"prompt_cache_key\": \"<string>\",\n \"safety_identifier\": \"<string>\",\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"top_logprobs\": 123,\n \"top_p\": 123,\n \"background\": true,\n \"conversation\": {},\n \"include\": [\n \"<string>\"\n ],\n \"instructions\": \"<string>\",\n \"metadata\": {\n \"metadata\": \"new java.util.HashMap<>()\"\n },\n \"moderation\": {\n \"input\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n },\n \"output\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n }\n },\n \"reasoning\": {},\n \"store\": false,\n \"stream\": false,\n \"temperature\": 123,\n \"text\": {\n \"format\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n },\n \"verbosity\": \"<string>\"\n },\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": true,\n \"defer_loading\": true\n }\n ],\n \"user\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.haitoken.ai/v1/responses")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"context_management\": [\n {\n \"compact_threshold\": 123,\n \"type\": \"<string>\"\n }\n ],\n \"max_output_tokens\": 123,\n \"max_tool_calls\": 123,\n \"parallel_tool_calls\": true,\n \"previous_response_id\": \"<string>\",\n \"prompt_cache_key\": \"<string>\",\n \"safety_identifier\": \"<string>\",\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"top_logprobs\": 123,\n \"top_p\": 123,\n \"background\": true,\n \"conversation\": {},\n \"include\": [\n \"<string>\"\n ],\n \"instructions\": \"<string>\",\n \"metadata\": {\n \"metadata\": \"new java.util.HashMap<>()\"\n },\n \"moderation\": {\n \"input\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n },\n \"output\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n }\n },\n \"reasoning\": {},\n \"store\": false,\n \"stream\": false,\n \"temperature\": 123,\n \"text\": {\n \"format\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n },\n \"verbosity\": \"<string>\"\n },\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": true,\n \"defer_loading\": true\n }\n ],\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.haitoken.ai/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"context_management\": [\n {\n \"compact_threshold\": 123,\n \"type\": \"<string>\"\n }\n ],\n \"max_output_tokens\": 123,\n \"max_tool_calls\": 123,\n \"parallel_tool_calls\": true,\n \"previous_response_id\": \"<string>\",\n \"prompt_cache_key\": \"<string>\",\n \"safety_identifier\": \"<string>\",\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"top_logprobs\": 123,\n \"top_p\": 123,\n \"background\": true,\n \"conversation\": {},\n \"include\": [\n \"<string>\"\n ],\n \"instructions\": \"<string>\",\n \"metadata\": {\n \"metadata\": \"new java.util.HashMap<>()\"\n },\n \"moderation\": {\n \"input\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n },\n \"output\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n }\n },\n \"reasoning\": {},\n \"store\": false,\n \"stream\": false,\n \"temperature\": 123,\n \"text\": {\n \"format\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n },\n \"verbosity\": \"<string>\"\n },\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": true,\n \"defer_loading\": true\n }\n ],\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"incomplete_details": {
"reason": "max_output_tokens"
},
"parallel_tool_calls": true,
"tool_choice": "none",
"top_p": 123,
"completed_at": 123,
"max_output_tokens": 123,
"max_tool_calls": 123,
"previous_response_id": "<string>",
"prompt_cache_key": "<string>",
"prompt_cache_retention": "in_memory",
"safety_identifier": "<string>",
"service_tier": "auto",
"top_logprobs": 123,
"id": "<string>",
"error": {
"code": "server_error",
"message": "<string>"
},
"instructions": "<string>",
"metadata": {
"key": "<string>"
},
"model": "<string>",
"object": "response",
"output": [
{}
],
"temperature": 123,
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": true,
"defer_loading": true
}
],
"background": false,
"conversation": {
"id": "<string>"
},
"moderation": {
"input": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
},
"output": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
},
"prompt": {
"id": "<string>",
"variables": {},
"version": "<string>"
},
"reasoning": {
"generate_summary": "auto",
"context": "auto",
"effort": "none",
"summary": "auto"
},
"status": "completed",
"text": {
"format": {
"type": "text",
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
},
"verbosity": "<string>"
},
"truncation": "auto",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"input_tokens_details": {
"cached_tokens": 0,
"cache_write_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 123
}
},
"user": "<string>"
}Responses 格式
创建聊天补全请求,兼容 OpenAI Responses 协议,支持流式和非流式响应
curl --request POST \
--url https://api.haitoken.ai/v1/responses \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"model": "<string>",
"context_management": [
{
"compact_threshold": 123,
"type": "<string>"
}
],
"max_output_tokens": 123,
"max_tool_calls": 123,
"parallel_tool_calls": true,
"previous_response_id": "<string>",
"prompt_cache_key": "<string>",
"safety_identifier": "<string>",
"stream_options": {
"include_obfuscation": true
},
"top_logprobs": 123,
"top_p": 123,
"background": true,
"conversation": {},
"include": [
"<string>"
],
"instructions": "<string>",
"metadata": {
"metadata": "new java.util.HashMap<>()"
},
"moderation": {
"input": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
},
"output": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
},
"reasoning": {},
"store": false,
"stream": false,
"temperature": 123,
"text": {
"format": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
},
"verbosity": "<string>"
},
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": true,
"defer_loading": true
}
],
"user": "<string>"
}
'import requests
url = "https://api.haitoken.ai/v1/responses"
payload = {
"input": "<string>",
"model": "<string>",
"context_management": [
{
"compact_threshold": 123,
"type": "<string>"
}
],
"max_output_tokens": 123,
"max_tool_calls": 123,
"parallel_tool_calls": True,
"previous_response_id": "<string>",
"prompt_cache_key": "<string>",
"safety_identifier": "<string>",
"stream_options": { "include_obfuscation": True },
"top_logprobs": 123,
"top_p": 123,
"background": True,
"conversation": {},
"include": ["<string>"],
"instructions": "<string>",
"metadata": { "metadata": "new java.util.HashMap<>()" },
"moderation": {
"input": {
"category_applied_input_types": { "key": {} },
"category_scores": { "key": {} },
"categories": { "key": {} },
"flagged": True,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
},
"output": {
"category_applied_input_types": { "key": {} },
"category_scores": { "key": {} },
"categories": { "key": {} },
"flagged": True,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
},
"reasoning": {},
"store": False,
"stream": False,
"temperature": 123,
"text": {
"format": {
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": True
},
"verbosity": "<string>"
},
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": True,
"defer_loading": True
}
],
"user": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input: '<string>',
model: '<string>',
context_management: [{compact_threshold: 123, type: '<string>'}],
max_output_tokens: 123,
max_tool_calls: 123,
parallel_tool_calls: true,
previous_response_id: '<string>',
prompt_cache_key: '<string>',
safety_identifier: '<string>',
stream_options: {include_obfuscation: true},
top_logprobs: 123,
top_p: 123,
background: true,
conversation: {},
include: ['<string>'],
instructions: '<string>',
metadata: {metadata: 'new java.util.HashMap<>()'},
moderation: {
input: {
category_applied_input_types: {key: {}},
category_scores: {key: {}},
categories: {key: {}},
flagged: true,
model: '<string>',
type: '<string>',
code: '<string>',
message: '<string>'
},
output: {
category_applied_input_types: {key: {}},
category_scores: {key: {}},
categories: {key: {}},
flagged: true,
model: '<string>',
type: '<string>',
code: '<string>',
message: '<string>'
}
},
reasoning: {},
store: false,
stream: false,
temperature: 123,
text: {
format: {name: '<string>', description: '<string>', schema: {}, strict: true},
verbosity: '<string>'
},
tools: [
{
type: 'function',
name: '<string>',
description: '<string>',
parameters: {},
strict: true,
defer_loading: true
}
],
user: '<string>'
})
};
fetch('https://api.haitoken.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.haitoken.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([
'input' => '<string>',
'model' => '<string>',
'context_management' => [
[
'compact_threshold' => 123,
'type' => '<string>'
]
],
'max_output_tokens' => 123,
'max_tool_calls' => 123,
'parallel_tool_calls' => true,
'previous_response_id' => '<string>',
'prompt_cache_key' => '<string>',
'safety_identifier' => '<string>',
'stream_options' => [
'include_obfuscation' => true
],
'top_logprobs' => 123,
'top_p' => 123,
'background' => true,
'conversation' => [
],
'include' => [
'<string>'
],
'instructions' => '<string>',
'metadata' => [
'metadata' => 'new java.util.HashMap<>()'
],
'moderation' => [
'input' => [
'category_applied_input_types' => [
'key' => [
]
],
'category_scores' => [
'key' => [
]
],
'categories' => [
'key' => [
]
],
'flagged' => true,
'model' => '<string>',
'type' => '<string>',
'code' => '<string>',
'message' => '<string>'
],
'output' => [
'category_applied_input_types' => [
'key' => [
]
],
'category_scores' => [
'key' => [
]
],
'categories' => [
'key' => [
]
],
'flagged' => true,
'model' => '<string>',
'type' => '<string>',
'code' => '<string>',
'message' => '<string>'
]
],
'reasoning' => [
],
'store' => false,
'stream' => false,
'temperature' => 123,
'text' => [
'format' => [
'name' => '<string>',
'description' => '<string>',
'schema' => [
],
'strict' => true
],
'verbosity' => '<string>'
],
'tools' => [
[
'type' => 'function',
'name' => '<string>',
'description' => '<string>',
'parameters' => [
],
'strict' => true,
'defer_loading' => true
]
],
'user' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.haitoken.ai/v1/responses"
payload := strings.NewReader("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"context_management\": [\n {\n \"compact_threshold\": 123,\n \"type\": \"<string>\"\n }\n ],\n \"max_output_tokens\": 123,\n \"max_tool_calls\": 123,\n \"parallel_tool_calls\": true,\n \"previous_response_id\": \"<string>\",\n \"prompt_cache_key\": \"<string>\",\n \"safety_identifier\": \"<string>\",\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"top_logprobs\": 123,\n \"top_p\": 123,\n \"background\": true,\n \"conversation\": {},\n \"include\": [\n \"<string>\"\n ],\n \"instructions\": \"<string>\",\n \"metadata\": {\n \"metadata\": \"new java.util.HashMap<>()\"\n },\n \"moderation\": {\n \"input\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n },\n \"output\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n }\n },\n \"reasoning\": {},\n \"store\": false,\n \"stream\": false,\n \"temperature\": 123,\n \"text\": {\n \"format\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n },\n \"verbosity\": \"<string>\"\n },\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": true,\n \"defer_loading\": true\n }\n ],\n \"user\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.haitoken.ai/v1/responses")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"context_management\": [\n {\n \"compact_threshold\": 123,\n \"type\": \"<string>\"\n }\n ],\n \"max_output_tokens\": 123,\n \"max_tool_calls\": 123,\n \"parallel_tool_calls\": true,\n \"previous_response_id\": \"<string>\",\n \"prompt_cache_key\": \"<string>\",\n \"safety_identifier\": \"<string>\",\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"top_logprobs\": 123,\n \"top_p\": 123,\n \"background\": true,\n \"conversation\": {},\n \"include\": [\n \"<string>\"\n ],\n \"instructions\": \"<string>\",\n \"metadata\": {\n \"metadata\": \"new java.util.HashMap<>()\"\n },\n \"moderation\": {\n \"input\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n },\n \"output\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n }\n },\n \"reasoning\": {},\n \"store\": false,\n \"stream\": false,\n \"temperature\": 123,\n \"text\": {\n \"format\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n },\n \"verbosity\": \"<string>\"\n },\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": true,\n \"defer_loading\": true\n }\n ],\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.haitoken.ai/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"context_management\": [\n {\n \"compact_threshold\": 123,\n \"type\": \"<string>\"\n }\n ],\n \"max_output_tokens\": 123,\n \"max_tool_calls\": 123,\n \"parallel_tool_calls\": true,\n \"previous_response_id\": \"<string>\",\n \"prompt_cache_key\": \"<string>\",\n \"safety_identifier\": \"<string>\",\n \"stream_options\": {\n \"include_obfuscation\": true\n },\n \"top_logprobs\": 123,\n \"top_p\": 123,\n \"background\": true,\n \"conversation\": {},\n \"include\": [\n \"<string>\"\n ],\n \"instructions\": \"<string>\",\n \"metadata\": {\n \"metadata\": \"new java.util.HashMap<>()\"\n },\n \"moderation\": {\n \"input\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n },\n \"output\": {\n \"category_applied_input_types\": {\n \"key\": {}\n },\n \"category_scores\": {\n \"key\": {}\n },\n \"categories\": {\n \"key\": {}\n },\n \"flagged\": true,\n \"model\": \"<string>\",\n \"type\": \"<string>\",\n \"code\": \"<string>\",\n \"message\": \"<string>\"\n }\n },\n \"reasoning\": {},\n \"store\": false,\n \"stream\": false,\n \"temperature\": 123,\n \"text\": {\n \"format\": {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"schema\": {},\n \"strict\": true\n },\n \"verbosity\": \"<string>\"\n },\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {},\n \"strict\": true,\n \"defer_loading\": true\n }\n ],\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"incomplete_details": {
"reason": "max_output_tokens"
},
"parallel_tool_calls": true,
"tool_choice": "none",
"top_p": 123,
"completed_at": 123,
"max_output_tokens": 123,
"max_tool_calls": 123,
"previous_response_id": "<string>",
"prompt_cache_key": "<string>",
"prompt_cache_retention": "in_memory",
"safety_identifier": "<string>",
"service_tier": "auto",
"top_logprobs": 123,
"id": "<string>",
"error": {
"code": "server_error",
"message": "<string>"
},
"instructions": "<string>",
"metadata": {
"key": "<string>"
},
"model": "<string>",
"object": "response",
"output": [
{}
],
"temperature": 123,
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {},
"strict": true,
"defer_loading": true
}
],
"background": false,
"conversation": {
"id": "<string>"
},
"moderation": {
"input": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
},
"output": {
"category_applied_input_types": {
"key": {}
},
"category_scores": {
"key": {}
},
"categories": {
"key": {}
},
"flagged": true,
"model": "<string>",
"type": "<string>",
"code": "<string>",
"message": "<string>"
}
},
"prompt": {
"id": "<string>",
"variables": {},
"version": "<string>"
},
"reasoning": {
"generate_summary": "auto",
"context": "auto",
"effort": "none",
"summary": "auto"
},
"status": "completed",
"text": {
"format": {
"type": "text",
"name": "<string>",
"description": "<string>",
"schema": {},
"strict": true
},
"verbosity": "<string>"
},
"truncation": "auto",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"input_tokens_details": {
"cached_tokens": 0,
"cache_write_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 123
}
},
"user": "<string>"
}功能特性
- 支持流式(SSE)和非流式两种响应模式
- 支持函数调用与工具调用(Function/Tool Calling)
- 支持结构化输出(JSON Schema)
- 支持推理模式配置(reasoning_effort)
- 支持网络搜索选项
使用场景
适用于需要与 OpenAI 兼容模型进行对话交互的场景,包括:- 单轮或多轮对话
- 函数调用与工具编排
- 结构化 JSON 输出
- 流式实时响应
认证方式
在请求头中携带Authorization 字段,格式为 Bearer YOUR_API_KEY。
- 请勿在客户端代码中暴露 API Key,建议通过服务端代理转发请求。
previous_response_idconversation
input 参数显式传递完整上下文。快速示例
import requests
url = "https://api.haitoken.ai/v1/responses"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "gpt-5.4",
"input": "你好,请介绍一下自己"
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
const response = await fetch('https://api.haitoken.ai/v1/responses', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-5.4',
input: '你好,请介绍一下自己'
})
});
const data = await response.json();
console.log(data);
curl -X POST 'https://api.haitoken.ai/v1/responses' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5.4",
"input": "你好,请介绍一下自己"
}'
请求头
API Key token (Bearer sk-xxx)
"application/json"
请求体
输入内容,可以是字符串或输入项列表。
模型 ID,如 gpt-4o、gpt-5 等。
上下文管理配置。
Show child attributes
Show child attributes
最大输出 token 数量(包含可见输出与 reasoning tokens)。
内置工具最大总调用次数。
是否启用并行工具调用。
前一次响应 ID,用于多轮对话。
Prompt 缓存键,用于替换 user 提升缓存命中率。
Prompt 缓存保留策略
in_memory, 24h 安全标识符。
{auto=auto, default=default, flex=flex, scale=scale, priority=priority}
auto, default, flex, scale, priority 流式响应选项,仅在{@code stream: true} 时设置。
Show child attributes
Show child attributes
工具选择策略:none、auto、required 或包含 type/name 的工具选择对象。
none, auto, required 每个 token 位置返回的最可能 token 数量(0-20)。
核采样。
是否后台运行响应。
关联会话。可以是会话 ID 字符串,也可以是包含 id 的会话对象{@link ResponseConversationParam}。
额外返回数据项。
系统/开发者指令。
元数据,最多 16 个 key-value 对。
Show child attributes
Show child attributes
内容审核配置。
Show child attributes
Show child attributes
可复用 Prompt 模板引用。
Show child attributes
Show child attributes
推理模型配置(gpt-5 及 o 系列模型)。
Show child attributes
Show child attributes
是否存储响应。
是否启用流式输出(OpenAI Responses API 原生字段,同时用于网关流式判断)。
采样温度。
文本/结构化输出配置,替代旧的 response_format。
Show child attributes
Show child attributes
工具列表,支持 function、web_search_preview、file_search、computer_use_preview 等。
OpenAI Responses API 工具定义基类。支持 function、file_search、web_search_preview 等多种工具类型。
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
- Option 10
- Option 11
- Option 12
- Option 13
- Option 14
- Option 15
- Option 16
Show child attributes
Show child attributes
{auto=auto, disabled=disabled}
auto, disabled 用户标识(已废弃,建议使用 safety_identifier / prompt_cache_key)。
响应
创建时间(Unix 时间戳,秒)
未完成的详情
Show child attributes
Show child attributes
是否启用并行工具调用
工具选择策略
none, auto, required 核采样
完成时间(Unix 时间戳,秒)
最大输出 token 数量
内置工具最大总调用次数
前一次响应 ID
Prompt 缓存键
{in_memory=in_memory, 24h=24h}
in_memory, 24h 安全标识符
{auto=auto, default=default, flex=flex, scale=scale, priority=priority}
auto, default, flex, scale, priority 每个 token 位置返回的最可能 token 数量
响应唯一标识
错误信息
Show child attributes
Show child attributes
系统/开发者指令。可以是字符串,也可以是输入项列表。
元数据,最多 16 个 key-value 对 与OPENAI SDK不一致,与文档一致
Show child attributes
Show child attributes
使用的模型 ID
对象类型,始终为 "response"
输出项列表
采样温度
工具列表
OpenAI Responses API 工具定义基类。支持 function、file_search、web_search_preview 等多种工具类型。
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
- Option 10
- Option 11
- Option 12
- Option 13
- Option 14
- Option 15
- Option 16
Show child attributes
Show child attributes
是否后台运行响应
关联会话
Show child attributes
Show child attributes
输入/输出内容审核配置
Show child attributes
Show child attributes
可复用 Prompt 模板引用
Show child attributes
Show child attributes
推理模型配置
Show child attributes
Show child attributes
{completed=completed, failed=failed, in_progress=in_progress, cancelled=cancelled, queued=queued, incomplete=incomplete}
completed, failed, in_progress, cancelled, queued, incomplete 文本/结构化输出配置
Show child attributes
Show child attributes
{auto=auto, disabled=disabled}
auto, disabled 使用统计信息
Show child attributes
Show child attributes
用户标识(已废弃)