创建结构化输出
![]()
示例使用 gpt-6.1-sol。Chat 使用 reasoning_effort,仅接受 low/medium/high/xhigh/max;不要传 none 或 minimal。工具调用请改用 Responses 函数调用。
在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token
Authorization: Bearer ********************
请求参数
完整 JSON 请求体
{
"model": "gpt-6.1-sol",
"messages": [
{
"role": "system",
"content": "Determine if the user input violates specific guidelines and explain if they do."
},
{
"role": "user",
"content": "How do I prepare for a job interview?"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "content_compliance",
"description": "Determines if content is violating specific moderation rules",
"schema": {
"type": "object",
"properties": {
"is_violating": {
"type": "boolean",
"description": "Indicates if the content is violating guidelines"
},
"category": {
"type": [
"string",
"null"
],
"description": "Type of violation, if the content is violating guidelines. Null otherwise.",
"enum": [
"violence",
"sexual",
"self_harm",
null
]
},
"explanation_if_violating": {
"type": [
"string",
"null"
],
"description": "Explanation of why the content is violating"
}
},
"required": [
"is_violating",
"category",
"explanation_if_violating"
],
"additionalProperties": false
},
"strict": true
}
},
"reasoning_effort": "low"
}
请求示例代码
curl --fail-with-body --request POST 'https://api.apizt.com/v1/chat/completions' \
--header "Authorization: Bearer ${tokenba_API_KEY}" \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-6.1-sol",
"messages": [
{
"role": "system",
"content": "Determine if the user input violates specific guidelines and explain if they do."
},
{
"role": "user",
"content": "How do I prepare for a job interview?"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "content_compliance",
"description": "Determines if content is violating specific moderation rules",
"schema": {
"type": "object",
"properties": {
"is_violating": {
"type": "boolean",
"description": "Indicates if the content is violating guidelines"
},
"category": {
"type": [
"string",
"null"
],
"description": "Type of violation, if the content is violating guidelines. Null otherwise.",
"enum": [
"violence",
"sexual",
"self_harm",
null
]
},
"explanation_if_violating": {
"type": [
"string",
"null"
],
"description": "Explanation of why the content is violating"
}
},
"required": [
"is_violating",
"category",
"explanation_if_violating"
],
"additionalProperties": false
},
"strict": true
}
},
"reasoning_effort": "low"
}'async function main() {
const headers = {
"Authorization": "Bearer " + process.env.tokenba_API_KEY,
"Content-Type": "application/json"
};
const body = JSON.stringify({
"model": "gpt-6.1-sol",
"messages": [
{
"role": "system",
"content": "Determine if the user input violates specific guidelines and explain if they do."
},
{
"role": "user",
"content": "How do I prepare for a job interview?"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "content_compliance",
"description": "Determines if content is violating specific moderation rules",
"schema": {
"type": "object",
"properties": {
"is_violating": {
"type": "boolean",
"description": "Indicates if the content is violating guidelines"
},
"category": {
"type": [
"string",
"null"
],
"description": "Type of violation, if the content is violating guidelines. Null otherwise.",
"enum": [
"violence",
"sexual",
"self_harm",
null
]
},
"explanation_if_violating": {
"type": [
"string",
"null"
],
"description": "Explanation of why the content is violating"
}
},
"required": [
"is_violating",
"category",
"explanation_if_violating"
],
"additionalProperties": false
},
"strict": true
}
},
"reasoning_effort": "low"
});
const response = await fetch("https://api.apizt.com/v1/chat/completions", { method: "POST", headers, body });
if (!response.ok) throw new Error("HTTP " + response.status + ": " + await response.text());
console.log(await response.text());
}
main().catch(console.error);import os
import requests
headers = {"Authorization": "Bearer " + os.environ["tokenba_API_KEY"]}
payload = {'model': 'gpt-6.1-sol',
'messages': [{'role': 'system',
'content': 'Determine if the user input violates specific guidelines '
'and explain if they do.'},
{'role': 'user', 'content': 'How do I prepare for a job interview?'}],
'response_format': {'type': 'json_schema',
'json_schema': {'name': 'content_compliance',
'description': 'Determines if content is '
'violating specific moderation '
'rules',
'schema': {'type': 'object',
'properties': {'is_violating': {'type': 'boolean',
'description': 'Indicates '
'if '
'the '
'content '
'is '
'violating '
'guidelines'},
'category': {'type': ['string',
'null'],
'description': 'Type '
'of '
'violation, '
'if '
'the '
'content '
'is '
'violating '
'guidelines. '
'Null '
'otherwise.',
'enum': ['violence',
'sexual',
'self_harm',
None]},
'explanation_if_violating': {'type': ['string',
'null'],
'description': 'Explanation '
'of '
'why '
'the '
'content '
'is '
'violating'}},
'required': ['is_violating',
'category',
'explanation_if_violating'],
'additionalProperties': False},
'strict': True}},
'reasoning_effort': 'low'}
response = requests.post('https://api.apizt.com/v1/chat/completions', headers=headers, json=payload, timeout=120)
response.raise_for_status()
print(response.text)返回响应
Chat Completions 文本位于 choices[].message.content。以下为结构示例,不代表实际调用结果。
{
"id": "chatcmpl_demo",
"object": "chat.completion",
"model": "gpt-6.1-sol",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\"is_violating\": false, \"category\": null, \"explanation_if_violating\": null}"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 8,
"total_tokens": 18
}
}
示例先设置 tokenba_API_KEY。JavaScript 使用 Node.js 20+,Python 安装 requests。流式示例的 Python 与 JavaScript 会逐段输出事件数据。代码中的 ID、文件名与令牌须替换为自己的值。
GPT-6.1 Sol 的 Chat 请求使用 reasoning_effort,Responses 使用 reasoning.effort;等级为 low、medium、high、xhigh、max。工具调用使用 Responses。官方型号说明。
当前模型与版本
依据 apizt 价格页,同步于 。以下型号按目录声明的协议与本页用途筛选;不代表所有参数和功能通用。切换前请核对型号说明、令牌分组与参数差异。Gemini 原生接口需同时替换 URL 中的模型 ID。
| 模型 ID | 能力标签 | 支持分组 |
|---|---|---|
gpt-6.1-sol | 对话,工具,识图,思考 | 分组(9)
|
gpt-6-astra | 对话,工具,识图,思考 | 分组(10)
|
gpt-6-sol | 对话,工具,识图,思考 | 分组(10)
|
gpt-6-luna | 对话,工具,识图,思考 | 分组(10)
|
claude-sonnet-5-5 | 对话,识图,工具 | 分组(6)
|
claude-opus-5-5 | 对话,工具,识图 | 分组(6)
|
claude-sonnet-5 | 对话,识图,工具 | 分组(8)
|
claude-fable-5-1 | 对话,识图,工具 | 分组(5)
|
共列入 220 个候选型号。查看完整模型、版本与接口目录。