文本生成
通用对话接口
POST
/
v1
/
chat
/
completions
curl -X POST https://www.qingbo.dev/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [
{
"role": "system",
"content": "你是一个专业的AI助手。"
},
{
"role": "user",
"content": "解释一下冒泡排序算法。"
}
],
"temperature": 0.7,
"max_tokens": 1024
}'
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
response = client.chat.completions.create(
model="gpt-5",
messages=[
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.chat.completions.create({
model: 'gpt-5',
messages: [
{ role: 'system', content: '你是一个专业的AI助手。' },
{ role: 'user', content: '解释一下冒泡排序算法。' }
],
temperature: 0.7,
max_tokens: 1024
});
console.log(response.choices[0].message.content);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "gpt-5",
"messages": []map[string]string{
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"},
},
"temperature": 0.7,
"max_tokens": 1024,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/v1/chat/completions", 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",
"messages": [
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"}
],
"temperature": 0.7,
"max_tokens": 1024
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/v1/chat/completions"))
.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": "chatcmpl-CdA8u0qPqzeN2gu8QLuQfjaP9CHU4",
"object": "chat.completion",
"created": 1763449816,
"model": "gpt-5-2025-08-07",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "冒泡排序(Bubble Sort)是一种简单的比较交换排序。它通过重复遍历序列,比较相邻元素并把较大的“冒泡”到右侧末端,直到序列有序。\n\n核心思想\n- 每一趟从左到右比较相邻元素,若前者大于后者则交换。一次趟结束后,当前未排部分中最大的元素被放到末尾。\n- 重复多趟,直到没有发生交换或已完成 n−1 趟。\n\n流程示例(以 [5, 1, 4, 2] 为例)\n- 第1趟:比较并交换 → [1, 5, 4, 2] → [1, 4, 5, 2] → [1, 4, 2, 5](最大元素5到末尾)\n- 第2趟:比较并交换 → [1, 4, 2, 5] → [1, 2, 4, 5](已整体有序,可提前结束)\n\n性质\n- 时间复杂度:平均/最坏 O(n^2),最好 O(n)(当已基本有序且使用提前退出优化)\n- 空间复杂度:O(1)(就地排序)\n- 稳定性:稳定(相等元素相对次序不变)\n- 适用场景:数据量小或序列几乎有序;不适合大规模无序数据\n\n常见优化\n- 提前退出:某趟未发生交换则已排序完成。\n- 缩短边界:记录本趟最后一次交换的位置,下一趟只需遍历到该位置。\n- 双向冒泡(鸡尾酒排序):从左到右、再从右到左各走一遍,更快收敛。\n\n简要伪代码\nfunction bubbleSort(a):\n n = length(a)\n repeat\n swapped = false\n for j = 0 to n-2:\n if a[j] > a[j+1]:\n swap(a[j], a[j+1])\n swapped = true\n n = n - 1 // 末尾已就位,缩短范围\n until swapped == false\n\n如需,我可以给出某种语言的实现代码或更多变体说明。",
"refusal": null,
"annotations": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 1030,
"total_tokens": 1054,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 512,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}
{
"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"
}
}
- 统一的对话 API 接口,支持所有主流文本生成模型
- 完全兼容 OpenAI Chat Completions API 格式
- 通过
model参数无缝切换不同 AI 模型 - 支持流式输出、函数调用等高级功能
curl -X POST https://www.qingbo.dev/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [
{
"role": "system",
"content": "你是一个专业的AI助手。"
},
{
"role": "user",
"content": "解释一下冒泡排序算法。"
}
],
"temperature": 0.7,
"max_tokens": 1024
}'
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
response = client.chat.completions.create(
model="gpt-5",
messages=[
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.chat.completions.create({
model: 'gpt-5',
messages: [
{ role: 'system', content: '你是一个专业的AI助手。' },
{ role: 'user', content: '解释一下冒泡排序算法。' }
],
temperature: 0.7,
max_tokens: 1024
});
console.log(response.choices[0].message.content);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "gpt-5",
"messages": []map[string]string{
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"},
},
"temperature": 0.7,
"max_tokens": 1024,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/v1/chat/completions", 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",
"messages": [
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"}
],
"temperature": 0.7,
"max_tokens": 1024
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/v1/chat/completions"))
.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": "chatcmpl-CdA8u0qPqzeN2gu8QLuQfjaP9CHU4",
"object": "chat.completion",
"created": 1763449816,
"model": "gpt-5-2025-08-07",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "冒泡排序(Bubble Sort)是一种简单的比较交换排序。它通过重复遍历序列,比较相邻元素并把较大的“冒泡”到右侧末端,直到序列有序。\n\n核心思想\n- 每一趟从左到右比较相邻元素,若前者大于后者则交换。一次趟结束后,当前未排部分中最大的元素被放到末尾。\n- 重复多趟,直到没有发生交换或已完成 n−1 趟。\n\n流程示例(以 [5, 1, 4, 2] 为例)\n- 第1趟:比较并交换 → [1, 5, 4, 2] → [1, 4, 5, 2] → [1, 4, 2, 5](最大元素5到末尾)\n- 第2趟:比较并交换 → [1, 4, 2, 5] → [1, 2, 4, 5](已整体有序,可提前结束)\n\n性质\n- 时间复杂度:平均/最坏 O(n^2),最好 O(n)(当已基本有序且使用提前退出优化)\n- 空间复杂度:O(1)(就地排序)\n- 稳定性:稳定(相等元素相对次序不变)\n- 适用场景:数据量小或序列几乎有序;不适合大规模无序数据\n\n常见优化\n- 提前退出:某趟未发生交换则已排序完成。\n- 缩短边界:记录本趟最后一次交换的位置,下一趟只需遍历到该位置。\n- 双向冒泡(鸡尾酒排序):从左到右、再从右到左各走一遍,更快收敛。\n\n简要伪代码\nfunction bubbleSort(a):\n n = length(a)\n repeat\n swapped = false\n for j = 0 to n-2:\n if a[j] > a[j+1]:\n swap(a[j], a[j+1])\n swapped = true\n n = n - 1 // 末尾已就位,缩短范围\n until swapped == false\n\n如需,我可以给出某种语言的实现代码或更多变体说明。",
"refusal": null,
"annotations": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 1030,
"total_tokens": 1054,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 512,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}
{
"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
所有接口均需要使用Bearer Token进行认证获取 API Key:访问 API Key 管理页面 获取您的 API Key使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY
Body
模型名称支持的模型包括:
- OpenAI:
gpt-5,gpt-5-mini,gpt-5-nano,gpt-5.1,gpt-5.2,gpt-5.4,gpt-4.1,gpt-4.1-mini,gpt-4.1-nano,gpt-4o,gpt-4o-mini,o1,o3-mini,o4-mini - Anthropic:
claude-opus-4.6,claude-sonnet-4.6,claude-opus-4.5,claude-sonnet-4.5,claude-haiku-4.5 - Google:
gemini-2.5-pro,gemini-2.5-flash,gemini-2.5-flash-lite,gemini-3-flash-preview,gemini-3.1-pro-preview - DeepSeek:
deepseek-r1-0528,deepseek-v3.2,deepseek-v3.2-exp - MiniMax:
minimax-m2.1,minimax-m2.5 - MoonshotAI:
kimi-k2.5,kimi-k2-thinking - Z.ai:
glm-4.6,glm-4.7,glm-5,glm-5.1 - 更多模型持续更新中…
控制输出随机性,范围 0-2
- 较低的值(如 0.2)使输出更确定
- 较高的值(如 1.8)使输出更随机
生成的最大token数量不同模型有不同的最大值限制,请参考具体模型文档
是否使用流式输出
true: 流式返回(SSE格式)false: 一次性返回完整响应
核采样参数,范围 0-1控制生成文本的多样性,建议与 temperature 二选一使用默认值:1.0
频率惩罚,范围 -2.0 到 2.0正值会降低重复使用相同词汇的可能性默认值:0
存在惩罚,范围 -2.0 到 2.0正值会增加谈论新主题的可能性默认值:0
停止序列最多4个序列,遇到这些序列时将停止生成
生成的回复数量默认值:1
Response
响应的唯一标识符
对象类型,固定为
chat.completion创建时间戳
实际使用的模型名称
token使用统计
显示 属性
显示 属性
输入消息的 token 数
生成内容的 token 数
总 token 数
系统指纹标识(用于追踪后端配置)
支持的模型列表
OpenAI 系列
gpt-5- GPT-5 基础模型gpt-5-mini- GPT-5 轻量版gpt-5-nano- GPT-5 超轻量版gpt-5.1- GPT-5.1gpt-5.2- GPT-5.2gpt-5.4- GPT-5.4gpt-4.1- GPT-4.1gpt-4.1-mini- GPT-4.1 轻量版gpt-4.1-nano- GPT-4.1 超轻量版gpt-4o- GPT-4o 多模态模型gpt-4o-mini- GPT-4o 轻量版o1- OpenAI o1 推理模型o3-mini- OpenAI o3 Minio4-mini- OpenAI o4 Mini
Anthropic 系列
claude-opus-4.6- Claude 4.6 Opus 最新旗舰模型claude-sonnet-4.6- Claude 4.6 Sonnet 最新版claude-opus-4.5- Claude 4.5 Opus 旗舰模型claude-sonnet-4.5- Claude 4.5 Sonnet 平衡版claude-haiku-4.5- Claude 4.5 Haiku 快速响应版
Google 系列
gemini-3.1-pro-preview- Gemini 3.1 Pro 预览版gemini-3-flash-preview- Gemini 3 Flash 预览版gemini-2.5-pro- Gemini 2.5 专业版gemini-2.5-flash- Gemini 2.5 快速版gemini-2.5-flash-lite- Gemini 2.5 超轻量版
DeepSeek 系列
deepseek-r1-0528- DeepSeek R1 推理模型deepseek-v3.2- DeepSeek V3.2deepseek-v3.2-exp- DeepSeek V3.2 实验版
MiniMax 系列
minimax-m2.1- MiniMax M2.1minimax-m2.5- MiniMax M2.5
MoonshotAI 系列
kimi-k2.5- Kimi K2.5kimi-k2-thinking- Kimi K2 思考版
Z.ai 系列
glm-4.6- GLM 4.6glm-4.7- GLM 4.7glm-5- GLM 5glm-5.1- GLM 5.1
使用示例
基础对话
{
"model": "gpt-5",
"messages": [
{"role": "user", "content": "你好"}
]
}
系统提示词
{
"model": "claude-sonnet-4.5",
"messages": [
{"role": "system", "content": "你是一位专业的Python编程导师"},
{"role": "user", "content": "如何使用列表推导式?"}
]
}
多轮对话
{
"model": "gemini-2.5-flash",
"messages": [
{"role": "user", "content": "什么是机器学习?"},
{"role": "assistant", "content": "机器学习是人工智能的一个分支..."},
{"role": "user", "content": "能举个例子吗?"}
]
}
流式输出
{
"model": "gpt-5",
"messages": [
{"role": "user", "content": "写一首关于春天的诗"}
],
"stream": true
}
高级功能
⌘I
curl -X POST https://www.qingbo.dev/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [
{
"role": "system",
"content": "你是一个专业的AI助手。"
},
{
"role": "user",
"content": "解释一下冒泡排序算法。"
}
],
"temperature": 0.7,
"max_tokens": 1024
}'
from openai import OpenAI
client = OpenAI(
base_url="https://www.qingbo.dev/v1",
api_key="YOUR_API_KEY"
)
response = client.chat.completions.create(
model="gpt-5",
messages=[
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://www.qingbo.dev/v1',
apiKey: 'YOUR_API_KEY'
});
const response = await client.chat.completions.create({
model: 'gpt-5',
messages: [
{ role: 'system', content: '你是一个专业的AI助手。' },
{ role: 'user', content: '解释一下冒泡排序算法。' }
],
temperature: 0.7,
max_tokens: 1024
});
console.log(response.choices[0].message.content);
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload := map[string]interface{}{
"model": "gpt-5",
"messages": []map[string]string{
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"},
},
"temperature": 0.7,
"max_tokens": 1024,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://www.qingbo.dev/v1/chat/completions", 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",
"messages": [
{"role": "system", "content": "你是一个专业的AI助手。"},
{"role": "user", "content": "解释一下冒泡排序算法。"}
],
"temperature": 0.7,
"max_tokens": 1024
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.qingbo.dev/v1/chat/completions"))
.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": "chatcmpl-CdA8u0qPqzeN2gu8QLuQfjaP9CHU4",
"object": "chat.completion",
"created": 1763449816,
"model": "gpt-5-2025-08-07",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "冒泡排序(Bubble Sort)是一种简单的比较交换排序。它通过重复遍历序列,比较相邻元素并把较大的“冒泡”到右侧末端,直到序列有序。\n\n核心思想\n- 每一趟从左到右比较相邻元素,若前者大于后者则交换。一次趟结束后,当前未排部分中最大的元素被放到末尾。\n- 重复多趟,直到没有发生交换或已完成 n−1 趟。\n\n流程示例(以 [5, 1, 4, 2] 为例)\n- 第1趟:比较并交换 → [1, 5, 4, 2] → [1, 4, 5, 2] → [1, 4, 2, 5](最大元素5到末尾)\n- 第2趟:比较并交换 → [1, 4, 2, 5] → [1, 2, 4, 5](已整体有序,可提前结束)\n\n性质\n- 时间复杂度:平均/最坏 O(n^2),最好 O(n)(当已基本有序且使用提前退出优化)\n- 空间复杂度:O(1)(就地排序)\n- 稳定性:稳定(相等元素相对次序不变)\n- 适用场景:数据量小或序列几乎有序;不适合大规模无序数据\n\n常见优化\n- 提前退出:某趟未发生交换则已排序完成。\n- 缩短边界:记录本趟最后一次交换的位置,下一趟只需遍历到该位置。\n- 双向冒泡(鸡尾酒排序):从左到右、再从右到左各走一遍,更快收敛。\n\n简要伪代码\nfunction bubbleSort(a):\n n = length(a)\n repeat\n swapped = false\n for j = 0 to n-2:\n if a[j] > a[j+1]:\n swap(a[j], a[j+1])\n swapped = true\n n = n - 1 // 末尾已就位,缩短范围\n until swapped == false\n\n如需,我可以给出某种语言的实现代码或更多变体说明。",
"refusal": null,
"annotations": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 1030,
"total_tokens": 1054,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 512,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}
{
"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"
}
}