File size: 3,515 Bytes
e14fdae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import streamlit as st
import numpy as np
import plotly.graph_objects as go
# import time

st.set_page_config()
st.title('RoI on Openai Chatgpt vs API plans') #


@st.dialog("Assumptions")
def note():
    st.markdown('''
                # ChatGPT plans
                - Plus - $20/month with 320 and 640 msgs per day cap for GPT4 and GPT-4o models resp
                - Teams - $30/month with 800 and 1600 msgs per day cap for GPT4 and GPT-4o models resp (minimum 2 users)  
                [link](https://openai.com/chatgpt/pricing)

                # API plans
                - GPT-4o: \\$5/1Million input tokens, $15/1Million output tokens
                - GPT4: \\$30/1Million input tokens, $60/1Million output tokens  
                [link](https://openai.com/api/pricing)
                
                # Assumptions
                - 1 token = 0.75 words (1.33 token $\\approx$ 1 word)
                - For Chatgpt API plans, we consider 1 input prompt = 250 words and same word count for output messages 
                
                ''')

# st.button("Note")
if st.button("Show Assumptions"):
    note()

with st.sidebar:
  st.title("Model Parameters")
  max_months = st.select_slider("No. of months to show on plot (x-axis)", 
                                  options = np.arange(0, 37, 1, dtype=int), value=13)
  
  no_of_users = st.select_slider("No. of users", 
                                  options = np.arange(0, 100, 1, dtype=int), value=2)
  
  st.subheader("Rest params app. for API plans only", divider="gray")

  daily_no_of_prompts = st.select_slider("No. of prompts expected per day per user", 
                                  options = np.arange(0, 1520, 20, dtype=int), value=100)
  
  input_prompts_word_cnt = st.select_slider("No. of words given as prompt to llm", 
                                  options = np.arange(0, 1050, 50, dtype=int), value=200)
  
  output_prompts_word_cnt = st.select_slider("No. of words in the output response from llm", 
                                  options = np.arange(0, 1050, 50, dtype=int), value=200)
    
    
# fixed
plan_limits = {"Plus": {"GPT-4o": 640, "GPT4": 320, "price": 20}, # 40 messages/3hrs
               "Team": {"GPT-4o": 1600, "GPT4": 800, "price": 30}} # 100 messages/3hrs, minimum 2 users price 25 pm if billed annually

api_limits = {"GPT-4o": {"input": 5, "output": 15}, "GPT4": {"input": 30, "output": 60}} #usd per 1M tokens

# assumptions
token_to_word_ratio = 0.75
word_to_token_ratio = 1/token_to_word_ratio

x = np.arange(0, max_months, dtype=int) # in months timeline

api_price_per_month = {k: x*(v["input"] * daily_no_of_prompts * input_prompts_word_cnt * word_to_token_ratio + 
                           v["output"] * daily_no_of_prompts * output_prompts_word_cnt * word_to_token_ratio)*30/1_000_000 for k, v in api_limits.items()}


fig = go.Figure()
fig.add_trace(go.Scatter(x=x, y=api_price_per_month['GPT4'], name='GPT-4 API', fillcolor="darkkhaki"))
fig.add_trace(go.Scatter(x=x, y=api_price_per_month['GPT-4o'], name='GPT-4o API', fillcolor="darkgreen"))
fig.add_trace(go.Scatter(x=x, y=x*no_of_users*plan_limits["Team"]['price'], name='Chatgpt Team', fillcolor="firebrick"))
fig.add_trace(go.Scatter(x=x, y=x*no_of_users*plan_limits["Plus"]['price'], name='Chatgpt Plus', fillcolor="dodgerblue"))


fig.update_layout(title="Accumulated monthly costs over time",
                      xaxis_title="time in months",
                      yaxis_title="accu. cost in $")

st.plotly_chart(fig)