Could you clarify your question by referring to the example provided in the link you posted earlier?
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "This is a test"}
],
max_tokens=5,
user="user_123456"
)
I think it’s clear that when a user makes a request, they already have an ID, and this ID or a reference to it should be passed along. Including the reference in the request to OpenAI indicates that best practices are being followed. In case of policy violations, the ID helps to identify the specific user and take appropriate actions.
Hi, thanks for your quick reply. I’m using the assistants API, not the completions API. There is no “user” parameter in the createMessage endpoint (https://platform.openai.com/docs/api-reference/messages/createMessage). That is why I was asking if I should send the user id in the metadata map. Many thanks in advance for your support!
Ok.
Ultimately you want to know which user added which message/ to whom a message belongs to. So your initial thought is correct.
If you know that a assistant or thread belongs to a single user then you can opt for another solution. The metadata object is available at the thread level as well.
Thanks. I will be sending a “user” entry with a hashed id in all the threads I generate. My main concern here is that my API-Key does not get banned because of user misuse.
When policy violations are being detected by the system the user parameter helps to identify the problematic user.
Also, when you receive a warning from OpenAI you can point to your best practice implementation to acquire good will before they make a decision.
Ultimately the user parameter does exactly what you need to protect your account.