OpenAI 安全分类器
随着 GPT-5 推出,OpenAI 增加了一些检查,识别并阻止用户获取危险信息。尤其是用途广泛的应用,部分用户最终可能会尝试违反 OpenAI 政策的用途。
安全分类流程
- OpenAI 将发送给 GPT-5 的请求划分到不同风险阈值。
- 如果组织反复达到高风险阈值,接口会返回错误,并发送警告邮件。
- 如果请求在通知的期限后仍持续出现(通常为七天),OpenAI 会停止该组织对 GPT-5 的访问,此后的请求将无法使用。
如何避免错误、延迟和封禁
组织出现违反安全政策的可疑活动时,OpenAI 可能返回错误、限制模型访问,甚至封禁账户。以下措施有助于定位高风险请求的来源,以便针对具体最终用户采取措施,而不是阻止整个组织。
- 对由独立用户与模型交互的产品,实现安全标识符。建议使用,但并非必填。
- 如果生命科学领域的有益应用需要访问限制较少的服务版本,查看生命科学研究特别访问计划,确认是否符合条件。
为独立用户实现安全标识符
要将标识符对应的警告与停用通知接入调查或支持流程,参见安全执行通知。
Responses API、Chat Completions API 和 Images API 支持 safety_identifier 参数。Realtime API 通过 OpenAI-Safety-Identifier 请求头支持同一概念。每次请求提供最终用户稳定不变的 ID;应对邮箱或内部用户 ID 做哈希,避免传入个人信息。
安全标识符不会在不同 API 或会话间自动继承。即使 Responses 请求已传入,也要在每次 Images 请求和创建或连接每个 Realtime 会话时分别提供同一个稳定值。
图像生成和编辑请求均应携带 safety_identifier,长度不超过 128 个字符。从已弃用的 user 参数迁移,参见图像安全标识符。
Responses 示例:
来源示例 1(javascript):
// [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-5.6-terra",
input: "This is a test",
safety_identifier: "user_123456",
});
console.log(response.output_text);
来源示例 2(python):
## [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.6-terra",
input="This is a test",
safety_identifier="user_123456",
)
来源示例 3(go):
// [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6-terra",
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("This is a test")},
SafetyIdentifier: openai.String("user_123456"),
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
来源示例 4(java):
// [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-5.6-terra")
.input("Help me plan a study schedule.")
.safetyIdentifier("user_1234")
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text()));
来源示例 5(ruby):
## [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-5.6-terra",
input: "Help me plan a study schedule.",
safety_identifier: "user_1234"
)
puts(response.output_text)
来源示例 6(bash):
## [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.6-terra",
"input": "This is a test",
"safety_identifier": "user_123456"
}'
Chat Completions 示例:
来源示例 7(javascript):
// [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.chat.completions.create({
model: "gpt-5.6-terra",
messages: [{ role: "user", content: "This is a test" }],
safety_identifier: "user_123456",
});
console.log(response.choices[0].message.content);
来源示例 8(python):
## [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "This is a test"}],
safety_identifier="user_123456",
)
来源示例 9(go):
// [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
)
func main() {
client := openai.NewClient()
response, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "gpt-5.6-terra",
Messages: []openai.ChatCompletionMessageParamUnion{openai.UserMessage("This is a test")},
SafetyIdentifier: openai.String("user_123456"),
})
if err != nil {
panic(err)
}
fmt.Println(response.Choices[0].Message.Content)
}
来源示例 10(java):
// [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
ChatCompletionCreateParams params =
ChatCompletionCreateParams.builder()
.model("gpt-5.6-terra")
.addUserMessage("Help me plan a study schedule.")
.safetyIdentifier("user_1234")
.build();
client.chat().completions().create(params).choices().stream()
.flatMap(choice -> choice.message().content().stream())
.forEach(System.out::println);
来源示例 11(ruby):
## [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
require "openai"
client = OpenAI::Client.new
completion = client.chat.completions.create(
model: "gpt-5.6-terra",
messages: [
{
role: :user,
content: "Help me plan a study schedule."
}
],
safety_identifier: "user_1234"
)
puts(completion.choices.fetch(0).message.content)
来源示例 12(bash):
## [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.6-terra",
"messages": [
{"role": "user", "content": "This is a test"}
],
"safety_identifier": "user_123456"
}'
Realtime 示例:
来源示例 13(bash):
## [中文] 为最终用户传入稳定且已做哈希的安全标识符;同一值须在不同API和Realtime会话分别提供,不传明文邮箱。
curl https://api.openai.com/v1/realtime/client_secrets \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Safety-Identifier: user_123456" \
-d '{
"session": {
"type": "realtime",
"model": "gpt-realtime-2.1"
}
}'
可能采取的措施
监控系统发现潜在滥用时,OpenAI 可能采取不同级别的措施:
- 延迟流式响应。作为较轻的初步干预,先执行额外检查,再向可能违规的用户返回完整响应。通过检查后才开始流式输出;未通过则停止请求,不输出词元,也不开始流。可显示加载提示,改善等待体验。
- 阻止特定用户访问模型。对于高置信度的违规,关联的
safety_identifier会被阻止访问。该标识符此后所有 GPT-5 请求都会收到identifier blocked错误。目前无法解除单个标识符的封禁。
应防止被封禁用户通过新建账户绕过限制。组织反复违规也可能导致整个组织失去访问权限。
为什么这样做
具体执行标准可能随实际使用或新模型发布而变化。目前,危险或可疑的生物、化学活动可能导致相应安全标识符被限制或封禁。背景见为生物领域未来 AI 能力做准备。
其他安全检查
工具和模型定制的保护措施见计算机使用中的确认与同意及微调安全检查。OpenAI 也在模型评估中心公布结果。

TRAE-AI编程


更多建议: