文本生成
多模态响应接口
POST
/
v1
/
responses
curl -X POST https://www.qingbo.dev/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"input": "解释一下冒泡排序算法。"
}'
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
response = client.responses.create(
model="gpt-5",
input="解释一下冒泡排序算法。"
)
print(response.output_text)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.responses.create({
model: 'gpt-5',
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",
"input": "解释一下冒泡排序算法。",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/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",
"input": "解释一下冒泡排序算法。"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/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-2025-08-07",
"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 API 格式
- 支持文本和图像的多模态输入
- 支持工具扩展:网络搜索、文件搜索、函数调用、远程 MCP
curl -X POST https://www.qingbo.dev/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"input": "解释一下冒泡排序算法。"
}'
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
response = client.responses.create(
model="gpt-5",
input="解释一下冒泡排序算法。"
)
print(response.output_text)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.responses.create({
model: 'gpt-5',
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",
"input": "解释一下冒泡排序算法。",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/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",
"input": "解释一下冒泡排序算法。"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/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-2025-08-07",
"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"
}
}
Authorizations
string
必填
所有接口均需要使用 Bearer Token 进行认证获取 API Key:访问 API Key 管理页面 获取您的 API Key使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY
Body
string
必填
模型名称支持的模型包括:
gpt-5- GPT-5 基础模型gpt-5-pro- GPT-5 专业增强版(仅支持此接口)gpt-5-codex- GPT-5 Codex 代码模型(仅支持此接口)gpt-5.1-codex- GPT-5.1 Codex 代码模型(仅支持此接口)gpt-5.1-codex-mini- GPT-5.1 Codex Mini(仅支持此接口)gpt-5.2-codex- GPT-5.2 Codex 代码模型(仅支持此接口)gpt-5.3-codex- GPT-5.3 Codex 代码模型(仅支持此接口)- 以及所有支持
/v1/chat/completions的模型
gpt-5-pro 和所有 Codex 系列模型仅支持此接口(/v1/responses),不支持 /v1/chat/completions。string or array
必填
array
工具列表,可选配置支持的工具类型:
web_search- 网络搜索file_search- 文件搜索function- 函数调用remote_mcp- 远程 MCP 服务
显示 示例
显示 示例
[
{"type": "web_search"},
{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取天气信息",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"}
},
"required": ["city"]
}
}
}
]
number
控制输出随机性,范围 0-2默认值:1.0
integer
生成的最大 token 数量
boolean
是否使用流式输出默认值:false
Response
string
响应的唯一标识符
string
对象类型,固定为
responseinteger
创建时间戳
string
实际使用的模型名称(如
gpt-5-2025-08-07)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",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "这张图片里有什么?请详细描述"
},
{
"type": "input_image",
"image_url": "https://example.com/image.jpg"
}
]
}
]
}
视频分析
{
"model": "gemini-2.5-pro",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "分析一下这个视频的内容"
},
{
"type": "input_video",
"video_url": "https://example.com/video.mp4"
}
]
}
],
"max_tokens": 5000
}
使用网络搜索工具
{
"model": "gpt-5",
"tools": [
{"type": "web_search"}
],
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "2025年最新的AI技术趋势是什么?"
}
]
}
]
}
使用函数调用
{
"model": "gpt-5",
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取城市天气信息",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "城市名称,例如:北京"
}
},
"required": ["city"]
}
}
}
],
"input": "北京今天天气怎么样?"
}
内容类型说明
input_text
文本输入类型 属性:type: 固定为"input_text"text: 文本内容(字符串)
input_image
图像输入类型 属性:type: 固定为"input_image"image_url: 图像 URL 或 Base64 编码的数据 URI
- JPEG
- PNG
- GIF
- WebP
- 最大文件大小:20MB
- 推荐分辨率:不超过 2048x2048 像素
input_video
视频输入类型(部分模型支持) 属性:type: 固定为"input_video"video_url: 视频 URL
- MP4
- MOV
- AVI
- WebM
- 最大文件大小:200MB
- 最大时长:10 分钟
- 推荐分辨率:1080p
工具使用详解
网络搜索 (Web Search)
使用网络搜索工具可以让模型访问实时互联网信息。 配置示例:{
"tools": [{"type": "web_search"}]
}
- 查询最新新闻和时事
- 获取实时数据(股票、天气、汇率等)
- 搜索最新的技术文档和资料
- 验证事实信息
文件搜索 (File Search)
文件搜索工具允许模型在已上传的文档中搜索相关信息。 配置示例:{
"tools": [{"type": "file_search"}]
}
- 分析企业内部文档
- 搜索技术规范和手册
- 查询合同和法律文件
- 知识库问答系统
函数调用 (Function Calling)
定义自定义函数,让模型能够调用外部 API 或执行特定操作。 完整配置示例:{
"tools": [
{
"type": "function",
"function": {
"name": "get_stock_price",
"description": "获取股票的实时价格",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "股票代码,例如:AAPL"
},
"currency": {
"type": "string",
"enum": ["USD", "CNY"],
"description": "货币单位",
"default": "USD"
}
},
"required": ["symbol"]
}
}
}
]
}
name: 函数名称(必需)description: 函数功能描述(必需)parameters: 参数定义,使用 JSON Schema 格式type: 参数类型properties: 参数属性定义required: 必需参数列表
- 调用第三方 API
- 执行数据库查询
- 触发业务流程
- 与内部系统集成
远程 MCP (Remote MCP)
连接到远程模型上下文协议(MCP)服务,扩展模型能力。 配置示例:{
"tools": [
{
"type": "remote_mcp",
"remote_mcp": {
"url": "https://your-mcp-server.com/api",
"auth_token": "your_auth_token",
"timeout": 30
}
}
]
}
url: MCP 服务器地址(必需)auth_token: 认证令牌(可选)timeout: 超时时间(秒),默认 30 秒
- 连接企业级 AI 服务
- 使用专业领域模型
- 访问受保护的数据源
- 分布式 AI 系统集成
工具响应格式
当模型使用工具时,响应格式会包含工具调用信息:{
"id": "resp-123456",
"object": "response",
"created": 1677652288,
"model": "gpt-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\": \"北京\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
]
}
- 模型接收用户输入
- 分析是否需要使用工具
- 如需要,返回工具调用请求
- 客户端执行工具调用
- 将工具结果返回给模型
- 模型生成最终响应
注意事项
-
图像 URL 要求:
- 必须是公开可访问的 URL
- 或使用 Base64 编码的 Data URI 格式
-
Token 计费:
- 图像会根据其分辨率消耗相应的 tokens
- 高分辨率图像会自动调整大小以优化成本
- 工具调用也会消耗额外的 tokens
-
内容顺序:
- content 数组中的元素顺序会影响模型理解
- 建议先放置文本指令,再放置图像/视频
-
多模态组合:
- 可以在一个请求中混合多个文本和图像
- 支持多轮对话,保持上下文连贯性
-
工具使用限制:
- 同时使用多个工具时,模型会智能选择最合适的工具
- 函数调用需要明确的函数定义和参数说明
- 网络搜索结果可能受地域和时间限制
-
API 兼容性:
- 完全兼容 OpenAI Responses API 格式
- 可无缝迁移现有 OpenAI 代码
- 支持所有 OpenAI 工具扩展功能
⌘I
curl -X POST https://www.qingbo.dev/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"input": "解释一下冒泡排序算法。"
}'
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
response = client.responses.create(
model="gpt-5",
input="解释一下冒泡排序算法。"
)
print(response.output_text)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.responses.create({
model: 'gpt-5',
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",
"input": "解释一下冒泡排序算法。",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/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",
"input": "解释一下冒泡排序算法。"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/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-2025-08-07",
"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"
}
}