ChatGPT Plus subscription and OpenAI API payment method are different things

ChatGPT Plus subscription and OpenAI API usage are different things

  • 關於ChatGPT plus和OpenAI API收費分開的問題
  • 關於使用OpenAI API的使用量與需要花多少錢分析
    • a) 使用API來問問題做其他事(p.s. 語音轉文字/產生圖片)的計費方式不同
    • b) 針對用API來問問題做費用計算
  • 實際例子
    • 問一個問題,並計算使用的token數與要花多少錢分析

關於ChatGPT plus和OpenAI API收費分開的問題

上面提到ChatGPT plus和ChatGPT API的收費方式是分開的,如果你訂閱ChatGPT Plus,那你只能在https://chat.openai.com/這個網站來使用ChatGPT(如下圖所示):

題外話:

上週和組織裡的人討論到OpenAI有人把它porting到mac上,讓你可以直接在mac上使用,採訂閱制收費。

但奇怪的事,要透過那個軟體使用OpenAI的API服務,又要填入自己申請的OpenAI api key。這不是被扒了2層皮嗎……

Note 1:

申請OpenAI的API key雖然免費,但OpenAI對API的收費是pay-as-you-go (p.s. 用多少就收多少錢,沒有所謂的免費扣打)

OpenAI對於API收費的計算方式: https://openai.com/pricing

Note 2:

ChatGPT plus的訂閱只能夠用在下面這個網站,其和OpenAI的API付費是分開的:

https://chat.openai.com/


關於使用OpenAI API的使用量與需要花多少錢分析

Token 粗略的計算可以用以下規則來評估:
1 Token 約等於英文4 個字元
1 Token 約等於¾ 個單字
100 Tokens 約等於75 個單字

(p.s. 上述估算token方式是參考自: https://dotblogs.com.tw/anyun/2023/03/12/180209)

(p.s. 官方token計算方式: https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them)

a) 使用API來問問題和做其他事(p.s. 語音轉文字/產生圖片)的計費方式不同

官網的計費方式: (https://openai.com/pricing)

注意Chat(i.e. 問問題)和使用GPT-4 Model的計費方式並不相同

b) 針對用API來問問題做費用計算:


一天問100個問題,每個問題平均200單字(英文),每個問題平均回答600單字(英文),則1個月費用是:
(100*200*(100/75)/1000*0.002 + 100*600*(100/75)/1000*0.002)*30 = 6.4

(p.s. 約195.328 NTD (1 USD = 30.52NTD計算))

但因為OpenAI官方目前因太多人使用,所以限制每人每月最高上限只能使用到120美元 (約3662.4 NTD),所以不用擔心花太多:D

Note 1:

上述為約略估算,想要詳細計算可參考下面這篇文章或自行計算

https://dotblogs.com.tw/anyun/2023/03/12/180209


實際例子

問問題並計算使用的token與要花多少錢分析

問題:

give me sample code for bubble sort in swift

回答:


Certainly! Here’s an example implementation of the Bubble Sort algorithm in Swift:
func bubbleSort(_ array: inout [Int]) {
guard array.count > 1 else {
return
}

for i in 0..<array.count {
    var swapped = false
    for j in 1..<array.count-i {
        if array[j] < array[j-1] {
            array.swapAt(j, j-1)
            swapped = true
        }
    }
    if !swapped {
        return
    }
}

}

This function takes an array of integers as input and sorts it in ascending order using the Bubble Sort algorithm. The function works by repeatedly iterating through the array and comparing adjacent elements, swapping them if they are in the wrong order. This process is repeated until the array is sorted.

To use this function, simply create an array of integers and pass it to the bubbleSort function:

var myArray = [5, 2, 9, 3, 1, 8]
bubbleSort(&myArray)
print(myArray) // [1, 2, 3, 5, 8, 9]

OpenAI官方的Token計算器:

官方token計算器連結: https://platform.openai.com/tokenizer

Note: 使用不同Model的token計算方式也不一樣,但目前官方的token計算器只能算GPT-3 & Codex Model,以下我們用GPT-3 Model來做計算:

以下把問題和回答直接貼在官方計算器的輸入欄位:

官方使用OpenAI的API問問題的計費方式如下:

所以我們問這個問題,用官方計算器搭配上方的計費方式:

395/1000*0.002 = 0.00079 USD (p.s. 約0.024 NTD)

下面這張圖是官方後台看到的實際費用

去官方後台看到的實際費用為0.000678

官方後台看到的實際費用為0.000678和我們自行計算得到的金額0.00079很接近。

假設每天問100個如上面的問題(i.e. 問題與回答的總字數和上面這個問題相近),使用一個月我們要花72 NTD

這樣其實只比line貼圖的訂閱制每月所花的錢再多一些,我們就可以讓GPT-3幫助我們工作!!!

探索更多來自 LifeJourney 的內容

立即訂閱即可持續閱讀,還能取得所有封存文章。

Continue reading