文本生成
Responses 接口
OpenAI Responses 协议入口,除 deepseek-v3.1-terminus 外的全部文本模型可用
POST
/
v1
/
responses
curl -X POST https://api.qingbo.ai/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。"
}'
from openai import OpenAI
client = OpenAI(
base_url="https://api.qingbo.ai/v1",
api_key="YOUR_API_KEY"
)
response = client.responses.create(
model="gpt-5.3-codex",
input="解释一下冒泡排序算法。"
)
print(response.output_text)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.qingbo.ai/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.responses.create({
model: 'gpt-5.3-codex',
input: '解释一下冒泡排序算法。'
});
console.log(response.output_text);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.qingbo.ai/v1/responses", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
import java.net.http.*;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.qingbo.ai/v1/responses"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
{
"id": "resp_09e342953eda0be6006905acbcvoik1nhmezpmzzl7lex552vq",
"object": "response",
"created_at": 1761979488,
"model": "gpt-5.3-codex",
"status": "completed",
"output": [
{
"id": "rs_09e342953eda0be6006905ac62b6f48197aefa292b7dcdd477",
"type": "reasoning",
"summary": []
},
{
"id": "msg_09e342953eda0be6006905ac649e0081979f9859a09c70d4db",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "冒泡排序是一种简单的比较交换排序:重复遍历序列,比较相邻元素并把较大的一个换到右侧,每一趟把当前未排部分的最大值放到末尾,直到某一趟没有发生交换。",
"annotations": [],
"logprobs": []
}
]
}
],
"usage": {
"input_tokens": 642,
"output_tokens": 184,
"total_tokens": 826,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 128
}
},
"reasoning": {
"effort": "medium",
"summary": null
},
"temperature": 1,
"top_p": 1,
"tool_choice": "auto",
"tools": [],
"parallel_tool_calls": true,
"store": true,
"service_tier": "default",
"truncation": "disabled",
"background": false,
"content_filters": null,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"metadata": {},
"previous_response_id": null,
"prompt_cache_key": null,
"safety_identifier": null,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"top_logprobs": 0,
"user": null
}
{
"error": {
"code": 400,
"message": "请求参数无效",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "身份验证失败,请检查您的API密钥",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "账户余额不足,请充值后再试",
"type": "payment_required"
}
}
{
"error": {
"code": 403,
"message": "访问被禁止,您没有权限访问此资源",
"type": "permission_error"
}
}
{
"error": {
"code": 429,
"message": "请求过于频繁,请稍后再试",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "服务器内部错误,请稍后重试",
"type": "server_error"
}
}
{
"error": {
"code": 502,
"message": "网关错误,服务器暂时不可用",
"type": "bad_gateway"
}
}
OpenAI Responses 协议入口,除
思考 token 也从
deepseek-v3.1-terminus 外的全部文本模型都可调用。gpt-5-pro、gpt-5.2-pro、gpt-5.4-pro、gpt-5.3-codex 与 o3-pro 五个模型只接受本接口,不接受 Chat Completions。
curl -X POST https://api.qingbo.ai/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。"
}'
from openai import OpenAI
client = OpenAI(
base_url="https://api.qingbo.ai/v1",
api_key="YOUR_API_KEY"
)
response = client.responses.create(
model="gpt-5.3-codex",
input="解释一下冒泡排序算法。"
)
print(response.output_text)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.qingbo.ai/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.responses.create({
model: 'gpt-5.3-codex',
input: '解释一下冒泡排序算法。'
});
console.log(response.output_text);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.qingbo.ai/v1/responses", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
import java.net.http.*;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.qingbo.ai/v1/responses"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
{
"id": "resp_09e342953eda0be6006905acbcvoik1nhmezpmzzl7lex552vq",
"object": "response",
"created_at": 1761979488,
"model": "gpt-5.3-codex",
"status": "completed",
"output": [
{
"id": "rs_09e342953eda0be6006905ac62b6f48197aefa292b7dcdd477",
"type": "reasoning",
"summary": []
},
{
"id": "msg_09e342953eda0be6006905ac649e0081979f9859a09c70d4db",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "冒泡排序是一种简单的比较交换排序:重复遍历序列,比较相邻元素并把较大的一个换到右侧,每一趟把当前未排部分的最大值放到末尾,直到某一趟没有发生交换。",
"annotations": [],
"logprobs": []
}
]
}
],
"usage": {
"input_tokens": 642,
"output_tokens": 184,
"total_tokens": 826,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 128
}
},
"reasoning": {
"effort": "medium",
"summary": null
},
"temperature": 1,
"top_p": 1,
"tool_choice": "auto",
"tools": [],
"parallel_tool_calls": true,
"store": true,
"service_tier": "default",
"truncation": "disabled",
"background": false,
"content_filters": null,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"metadata": {},
"previous_response_id": null,
"prompt_cache_key": null,
"safety_identifier": null,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"top_logprobs": 0,
"user": null
}
{
"error": {
"code": 400,
"message": "请求参数无效",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "身份验证失败,请检查您的API密钥",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "账户余额不足,请充值后再试",
"type": "payment_required"
}
}
{
"error": {
"code": 403,
"message": "访问被禁止,您没有权限访问此资源",
"type": "permission_error"
}
}
{
"error": {
"code": 429,
"message": "请求过于频繁,请稍后再试",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "服务器内部错误,请稍后重试",
"type": "server_error"
}
}
{
"error": {
"code": 502,
"message": "网关错误,服务器暂时不可用",
"type": "bad_gateway"
}
}
鉴权
string
必填
所有接口均需要使用 Bearer Token 进行认证获取 API Key:访问 API Key 管理页面 获取您的 API Key使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY
请求参数
string
必填
模型 ID除
deepseek-v3.1-terminus 外的全部文本模型都可调用本接口。只接受本接口的五个模型:gpt-5-progpt-5.2-progpt-5.4-progpt-5.3-codexo3-pro
这五个模型发到
/v1/chat/completions 会返回 400;deepseek-v3.1-terminus 发到本接口同样返回 400。各模型的计费方式见文本模型总览。string or array
必填
integer
本次请求的输出预算思考 token 也从这个预算里扣。
status: "incomplete" 表示输出可能没写完,不能当作完整回答。array
工具列表
这五个模型不支持工具调用与结构化输出,
tools、tool_choice、response_format 都会返回 400,不计费。需要函数调用请改用支持工具的其他模型。number
控制输出随机性,范围 0-2默认值:1.0
integer
生成的最大 token 数量
boolean
是否使用流式输出默认值:false
响应
string
响应的唯一标识符
string
对象类型,固定为
responseinteger
创建时间戳
string
实际使用的模型名称
string
响应状态可能的值:
completed- 已完成in_progress- 处理中failed- 失败cancelled- 已取消
array
输出内容数组
显示 属性
显示 属性
string
输出类型
reasoning- 推理过程(思考模型专用)message- 消息内容
string
输出项的唯一标识符
array
推理摘要(当 type 为 reasoning 时)
string
角色类型,如
assistant(当 type 为 message 时)string
消息状态(当 type 为 message 时)
object
number
实际使用的采样温度
number
实际使用的核采样参数
string
工具选择策略
array
使用的工具列表
boolean
是否允许并行工具调用
boolean
是否存储对话历史
string
服务等级
string
截断策略
boolean
是否为后台任务
object
错误信息(如果有)
object
元数据信息
使用示例
单次输入
{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。"
}
多轮输入
{
"model": "gpt-5.4-pro",
"input": [
{"role": "user", "content": "什么是机器学习?"},
{"role": "assistant", "content": "机器学习是人工智能的一个分支……"},
{"role": "user", "content": "能举个例子吗?"}
]
}
限制输出预算
{
"model": "o3-pro",
"input": "证明素数有无穷多个。",
"max_output_tokens": 4096
}
max_output_tokens 里扣。响应 status 为 "incomplete" 时表示预算用尽,输出可能没写完。
流式输出
{
"model": "gpt-5.2-pro",
"input": "写一首关于春天的诗。",
"stream": true
}
用量与计费
usage.input_tokens 是输入总量(含 input_tokens_details.cached_tokens),usage.output_tokens 已包含 output_tokens_details.reasoning_tokens,思考 token 只按输出价计一次。这五个模型目前都是输入 / 输出两项计价,没有独立缓存价,响应里的缓存统计按普通输入价计。单价与计费通则见文本模型总览 · 计费口径。
流式计费取终态用量:以 response.completed、response.incomplete、response.failed 或 response.cancelled 事件里的 usage 为准。失败或截断的响应同样可能产生 token 费用;HTTP 200、部分文本或 [DONE] 都不足以证明拿到了完整用量。
没有拿到终态用量时,冻结的额度会保留待核对。请先到控制台核对这次调用的用量记录,不要自动重发。
当前不支持
以下请求会返回400,不计费:
- 托管工具 ——
file_search、remote_mcp等厂商内置工具;web_search的可用模型与计费见文本模型总览 · 计费口径。 - 上述五个模型的工具调用与结构化输出 —— 见上方
tools说明。 service_tier取standard/default以外的值。- 图像与视频输入。
相关文档
⌘I
curl -X POST https://api.qingbo.ai/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。"
}'
from openai import OpenAI
client = OpenAI(
base_url="https://api.qingbo.ai/v1",
api_key="YOUR_API_KEY"
)
response = client.responses.create(
model="gpt-5.3-codex",
input="解释一下冒泡排序算法。"
)
print(response.output_text)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.qingbo.ai/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.responses.create({
model: 'gpt-5.3-codex',
input: '解释一下冒泡排序算法。'
});
console.log(response.output_text);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.qingbo.ai/v1/responses", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
import java.net.http.*;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"model": "gpt-5.3-codex",
"input": "解释一下冒泡排序算法。"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.qingbo.ai/v1/responses"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
{
"id": "resp_09e342953eda0be6006905acbcvoik1nhmezpmzzl7lex552vq",
"object": "response",
"created_at": 1761979488,
"model": "gpt-5.3-codex",
"status": "completed",
"output": [
{
"id": "rs_09e342953eda0be6006905ac62b6f48197aefa292b7dcdd477",
"type": "reasoning",
"summary": []
},
{
"id": "msg_09e342953eda0be6006905ac649e0081979f9859a09c70d4db",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "冒泡排序是一种简单的比较交换排序:重复遍历序列,比较相邻元素并把较大的一个换到右侧,每一趟把当前未排部分的最大值放到末尾,直到某一趟没有发生交换。",
"annotations": [],
"logprobs": []
}
]
}
],
"usage": {
"input_tokens": 642,
"output_tokens": 184,
"total_tokens": 826,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 128
}
},
"reasoning": {
"effort": "medium",
"summary": null
},
"temperature": 1,
"top_p": 1,
"tool_choice": "auto",
"tools": [],
"parallel_tool_calls": true,
"store": true,
"service_tier": "default",
"truncation": "disabled",
"background": false,
"content_filters": null,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"metadata": {},
"previous_response_id": null,
"prompt_cache_key": null,
"safety_identifier": null,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"top_logprobs": 0,
"user": null
}
{
"error": {
"code": 400,
"message": "请求参数无效",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "身份验证失败,请检查您的API密钥",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "账户余额不足,请充值后再试",
"type": "payment_required"
}
}
{
"error": {
"code": 403,
"message": "访问被禁止,您没有权限访问此资源",
"type": "permission_error"
}
}
{
"error": {
"code": 429,
"message": "请求过于频繁,请稍后再试",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "服务器内部错误,请稍后重试",
"type": "server_error"
}
}
{
"error": {
"code": 502,
"message": "网关错误,服务器暂时不可用",
"type": "bad_gateway"
}
}