# Stateles & sending previous replies, to create a thread

**URL:** <https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237>\
**Category:** API\
**Tags:** gpt-4\
**Created:** [November 10, 2023, 9:29am UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237 "2023-11-10T09:29:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsvnk](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/itsvnk/32/448395_2.png) [@itsvnk](https://community.openai.com/u/itsvnk)\
**Post date:** [November 10, 2023, 9:29am UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/1 "2023-11-10T09:29:03Z")

</div>

I see a lot of posts on this topic and understand that chatGPT is stateless.

So, essentially, if I want chatGPT to “remember” the previous context, i have to send past messages as well.

1. Is there a particular way to do this? How do i format it?
2. And of course, with each message that is concatenated and sent, the token usage goes up, right? 🤔

Thanks

> [@Want the recent conversation history to manage using the api](https://community.openai.com/t/want-the-recent-conversation-history-to-manage-using-the-api/279508/3):
>
> Currently the API is stateless which means it doesn’t automatically track your previous messages. With each new request you need to send the previous messages (this will give it the chat history effect).

---

<div class="post-metadata">

**Author:** ![itsvnk](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/itsvnk/32/448395_2.png) [@itsvnk](https://community.openai.com/u/itsvnk)\
**Post date:** [November 10, 2023, 11:41am UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/2 "2023-11-10T11:41:35Z")

</div>

I was lazy, sorry, I found the answer after doing some searching

Looking at the solution, it seems pretty obvious in retrospect 🤦‍♂️

> [@GPT-3.5-turbo how to remember previous messages like Chat-GPT website](https://community.openai.com/t/gpt-3-5-turbo-how-to-remember-previous-messages-like-chat-gpt-website/170370/6):
>
> go to this link, [OpenAI API](https://platform.openai.com/docs/guides/chat/introduction) look a the example # Note: you need to be using OpenAI Python v0.27.0 for the code below to work import openai openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."}, {"role": "user", "content": "Where was…

---

<div class="post-metadata">

**Author:** ![purgenetik](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/purgenetik/32/247596_2.png) [@purgenetik](https://community.openai.com/u/purgenetik)\
**Post date:** [November 13, 2023, 11:30pm UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/3 "2023-11-13T23:30:47Z")

</div>

eats up your money very effectively. because after each call, chatgpt “forgets” all the questions, and in order to return it to the final state, the newly born openai.ChatCompletion needs to ask the entire chain of questions again and again! that is, by the 5th question, 1 question will be asked (and paid) 5 times, 2 question - 4 times, etc. What if the dialogue is 20 questions long?! You’ll quickly be left without pants!)))  
Why can’t you open one openai.ChatCompletion object at the beginning, and then not ask questions to it sequentially, saving the status? I don’t understand?!  
Owners’ greed?

---

<div class="post-metadata">

**Author:** ![joelce23](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/joelce23/32/247368_2.png) [@joelce23](https://community.openai.com/u/joelce23)\
**Post date:** [November 13, 2023, 11:42pm UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/4 "2023-11-13T23:42:08Z")

</div>

I believe this is what they’re doing with the new Assistants API but I think the cost issue remains but less dev work to maintain state

---

<div class="post-metadata">

**Author:** ![purgenetik](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/purgenetik/32/247596_2.png) [@purgenetik](https://community.openai.com/u/purgenetik)\
**Post date:** [November 14, 2023, 9:29am UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/5 "2023-11-14T09:29:36Z")

</div>

Do you think that support for state-saving was not foreseen from the very beginning? That is, on GUI of the original openai site, the current model state is not saved in threads, but only the history of questions? which are also re-asked from the very beginning if a person asks a new question in a thread?

Would it be interesting to hear the developers’ response…

---

<div class="post-metadata">

**Author:** ![EricGT](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ericgt/32/20571_2.png) [@EricGT](https://community.openai.com/u/EricGT)\
**Post date:** [December 19, 2023, 6:15pm UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/6 "2023-12-19T18:15:23Z")

</div>

Can we close this topic?

* * *

Now for a useless sentence to keep the AI happy.

---

<div class="post-metadata">

**Author:** ![EricGT](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ericgt/32/20571_2.png) [@EricGT](https://community.openai.com/u/EricGT)\
**Post date:** [December 19, 2023, 6:36pm UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/7 "2023-12-19T18:36:20Z")

</div>

The OP marked this [post](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/2) as the solution before changing it to my post. Most moderators will not mark a post as the solution and I will not for this topic.

As it seems the OP is OK with this topic being closed, will close this topic.

---

<div class="post-metadata">

**Author:** ![EricGT](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ericgt/32/20571_2.png) [@EricGT](https://community.openai.com/u/EricGT)\
**Post date:** [December 19, 2023, 6:36pm UTC](https://community.openai.com/t/stateles-sending-previous-replies-to-create-a-thread/492237/8 "2023-12-19T18:36:23Z")

</div>

Closed on December 19, 2023, 6:36pm UTC


