OpenAI 的 安全最佳实践 旨在降低被滥用的可能性。
在请求中发送安全标识符可以成为一项有用的工具,帮助 OpenAI 监控并检测滥用行为。当我们在你的应用中检测到任何违反政策的情况时,这也能让 OpenAI 为你的团队提供更具可操作性的反馈。
安全标识符应为一个能唯一标识每位用户的字符串。请对用户名或电子邮箱地址进行哈希处理,以避免向我们发送任何可识别身份的信息。如果你向未登录用户提供产品预览,则可以改为发送会话 ID。
安全标识符取代了此前用于相同目的的 user 参数。
在 API 请求中通过 safety_identifier 参数包含安全标识符:
Python — Chat Completions API
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-5-mini",
messages=[
{"role": "user", "content": "This is a test"}
],
safety_identifier="user_123456"
)Python — Responses API
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5-mini",
input="This is a test",
safety_identifier="user_123456"
)