Responses格式
OpenAI Responses API,用于创建模型响应。 支持多轮对话、工具调用、推理等功能。
POST
/v1/responsesResponses格式
OpenAI Responses API,用于创建模型响应。 支持多轮对话、工具调用、推理等功能。
鉴权: 使用 Bearer Token 认证。 格式: `Authorization: Bearer sk-xxxxxx`
请求体
必填
Content-Type: application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | |
input | string | array<object> | 输入内容,可以是字符串或消息数组 | |
[] | object | ||
instructions | string | ||
max_output_tokens | integer | ||
temperature | number | ||
top_p | number | ||
stream | boolean | ||
tools | array<object> | ||
[] | object | ||
tool_choice | string | object | ||
reasoning | object | ||
effort | string | 可选值: low, medium, high | |
summary | string | ||
previous_response_id | string | ||
truncation | string | 可选值: auto, disabled |
示例代码
curl -X POST "https://api.nodeprice.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"model": "string",
"input": "string",
"instructions": "string",
"max_output_tokens": 0,
"temperature": 0,
"top_p": 0,
"stream": false,
"tools": [
{}
],
"tool_choice": "string",
"reasoning": {
"effort": "low",
"summary": "string"
},
"previous_response_id": "string",
"truncation": "auto"
}'const url = "https://api.nodeprice.com/v1/responses";
const body = {
"model": "string",
"input": "string",
"instructions": "string",
"max_output_tokens": 0,
"temperature": 0,
"top_p": 0,
"stream": false,
"tools": [
{}
],
"tool_choice": "string",
"reasoning": {
"effort": "low",
"summary": "string"
},
"previous_response_id": "string",
"truncation": "auto"
};
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer <token>"
},
body: JSON.stringify(body)
});
console.log(await response.text());package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
url := "https://api.nodeprice.com/v1/responses"
body := strings.NewReader(`{
"model": "string",
"input": "string",
"instructions": "string",
"max_output_tokens": 0,
"temperature": 0,
"top_p": 0,
"stream": false,
"tools": [
{}
],
"tool_choice": "string",
"reasoning": {
"effort": "low",
"summary": "string"
},
"previous_response_id": "string",
"truncation": "auto"
}`)
req, err := http.NewRequest("POST", url, body)
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer <token>")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(data))
}import requests
url = "https://api.nodeprice.com/v1/responses"
body = """{
"model": "string",
"input": "string",
"instructions": "string",
"max_output_tokens": 0,
"temperature": 0,
"top_p": 0,
"stream": false,
"tools": [
{}
],
"tool_choice": "string",
"reasoning": {
"effort": "low",
"summary": "string"
},
"previous_response_id": "string",
"truncation": "auto"
}"""
response = requests.request("POST", url, data=body, headers={
"Content-Type": "application/json",
"Authorization": "Bearer <token>"
})
print(response.text)OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n"
+ " \"model\": \"string\",\n"
+ " \"input\": \"string\",\n"
+ " \"instructions\": \"string\",\n"
+ " \"max_output_tokens\": 0,\n"
+ " \"temperature\": 0,\n"
+ " \"top_p\": 0,\n"
+ " \"stream\": false,\n"
+ " \"tools\": [\n"
+ " {}\n"
+ " ],\n"
+ " \"tool_choice\": \"string\",\n"
+ " \"reasoning\": {\n"
+ " \"effort\": \"low\",\n"
+ " \"summary\": \"string\"\n"
+ " },\n"
+ " \"previous_response_id\": \"string\",\n"
+ " \"truncation\": \"auto\"\n"
+ "}");
Request request = new Request.Builder()
.url("https://api.nodeprice.com/v1/responses")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer <token>")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());#include <stdio.h>
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (curl == NULL) {
return 1;
}
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.nodeprice.com/v1/responses");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\n"
+ " \"model\": \"string\",\n"
+ " \"input\": \"string\",\n"
+ " \"instructions\": \"string\",\n"
+ " \"max_output_tokens\": 0,\n"
+ " \"temperature\": 0,\n"
+ " \"top_p\": 0,\n"
+ " \"stream\": false,\n"
+ " \"tools\": [\n"
+ " {}\n"
+ " ],\n"
+ " \"tool_choice\": \"string\",\n"
+ " \"reasoning\": {\n"
+ " \"effort\": \"low\",\n"
+ " \"summary\": \"string\"\n"
+ " },\n"
+ " \"previous_response_id\": \"string\",\n"
+ " \"truncation\": \"auto\"\n"
+ "}");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
CURLcode code = curl_easy_perform(curl);
if (code != CURLE_OK) {
fprintf(stderr, "%s\n", curl_easy_strerror(code));
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.nodeprice.com/v1/responses");
request.Headers.Add("Authorization", "Bearer <token>");
request.Content = new StringContent("{\n"
+ " \"model\": \"string\",\n"
+ " \"input\": \"string\",\n"
+ " \"instructions\": \"string\",\n"
+ " \"max_output_tokens\": 0,\n"
+ " \"temperature\": 0,\n"
+ " \"top_p\": 0,\n"
+ " \"stream\": false,\n"
+ " \"tools\": [\n"
+ " {}\n"
+ " ],\n"
+ " \"tool_choice\": \"string\",\n"
+ " \"reasoning\": {\n"
+ " \"effort\": \"low\",\n"
+ " \"summary\": \"string\"\n"
+ " },\n"
+ " \"previous_response_id\": \"string\",\n"
+ " \"truncation\": \"auto\"\n"
+ "}", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}响应
200 成功创建响应
Content-Type: application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | ||
object | string | 示例: "response" | |
created_at | integer | ||
status | string | 可选值: completed, failed, in_progress, incomplete | |
model | string | ||
output | array<object> | ||
[] | object | ||
type | string | ||
id | string | ||
status | string | ||
role | string | ||
content | array<object> | ||
[] | object | ||
type | string | ||
text | string | ||
usage | object | ||
prompt_tokens | integer | 提示词 Token 数 | |
completion_tokens | integer | 补全 Token 数 | |
total_tokens | integer | 总 Token 数 | |
prompt_tokens_details | object | ||
cached_tokens | integer | ||
text_tokens | integer | ||
audio_tokens | integer | ||
image_tokens | integer | ||
completion_tokens_details | object | ||
text_tokens | integer | ||
audio_tokens | integer | ||
reasoning_tokens | integer |