#Does creating thread cost money ?
1 messages · Page 1 of 1 (latest)
Hi @dense pollen. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Creating a thread in OpenAI's API does not cost money. You can create as many threads as you want without incurring any charges. The cost is associated with model usage and file usage, not with the creation of threads themselves [source (https://community.openai.com/t/629290)].
However, when you add messages to a thread and run the model, you will be charged for the tokens of the entire conversation history with each run. This includes the whole thread, the retrieved documents, your new query, and the new output every time the thread runs [source (https://community.openai.com/t/606285), source (https://cookbook.openai.com/examples/assistants_api_overview_python#threads)].
Here's an example of how to create a thread and add a message to it using the Python SDK:
# Create a new thread
thread = client.beta.threads.create()
show_json(thread)
# Add a message to the thread
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="I need to solve the equation `3x + 11 = 14`. Can you help me?",
)
show_json(message)
[source (https://cookbook.openai.com/examples/assistants_api_overview_python#threads)]
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@dense pollen kapa.ai is still learning and improving, please let us know how it did by reacting below