Search code examples
openai-apichatgpt-api

ChatGPT completion /v1/chat/completions memorize across multiple requests


When I use user parameter on https://api.openai.com/v1/chat/completions, the memory is not persisted across multiple requests. How can we let the model memorize it across multiple requests?

Eg. is the message "My name is XXX" remembered by the ChatGPT API? Or do I have to send it every time? Then what is the purpose of the "user" variable if it is not used to remember things?

{
    "model": "gpt-4",
    "messages": [
        {
            "role": "user",
            "content": "My name is XXX."
        }
    ],
    "user": "myuser"
}

Solution

  • You have 2 options here. Use the Chat Completion API, that will be soon obsolete, or use the new Assistant API, the latter is exactly what you need. With the Chat Completion API you must add all the conversation texts every time you post a question, in that case ChatGPT will be able to extract from the previous question/answers the context and history of the conversation. With the new Assistant API (at the moment in beta version) that is done more efficiently and with less effort from your side because they have been developed to deal with what you need (test the assistant API playground on OpenAI website to check it). They released the assistant API a couple of weeks ago.