TL;DR How can I calculate the cost, in tokens, of a specific request made to the OpenAI API?
Hi all. I’ve just used the OpenAI Playground (model: gpt-3.5-turbo
) to submit a user message and obtain an assistant message in reply. Is it possible to calculate the actual cost of this, in terms of tokens? If so, how can I do that? The user message, assistant message, and system message are below.
ChatGPT says the user message contains 2 tokens and the assistant message contains 3 tokens. I didn’t include the system message in my question–does it affect tokens used?
Motivation for my question: As a side project I want to build a web app using the OpenAI API. But before I do so, I’d like to estimate the costs I can expect to incur during the project.
Thanks in advance.
System message
You are an expert in American cuisine, and creating different dishes from items found in US grocery stores.
User message
I will give you the name of a common product found in a US grocery store. I would like you to tell me the dish most commonly consumed in the US that contains this item as its featured ingredient. If possible, ensure the dish is one that most would consider to be 'American cuisine.' Please restrict your answer to one item, and include only the name of the dish.
The item is:
Boneless skinless chicken thighs
Assistant message
Barbecue Chicken Thighs