Is It Cheaper To Subscribe To ChatGPT and DALLE-3 Or To Use APIs?

--

So, the Willys Chocolate Experience graphics were so much better than the real thing. But how much do the images and ChatGPT requests actually cost to create? Is it less expensive to use the ChapGPT console or integrate with the API:

Overall, the costings for the OpenAI API is related to the number of tokens used, and which is roughly related to the number of words in a query. A basic benchmark is that 10 words lead to around 13 tokens. So, let’s investigate the costs.

DALLE-3

With DALLE-3, we can produce high-quality graphics, and which we access from the GPT-4 API or from a ChatGPT subscription. With a subscription, the ChatGPT Plus subscription is $20/month:

The current limit on the creation of images is 40 messages over three hours:

DALLE-3 API

So, is it cheaper to use the API? For this, we can create a Python program of:

from openai import OpenAI
import sys

client = OpenAI(api_key='API KEY HERE')

msg="."

if (len(sys.argv)>1):
msg=str(sys.argv[1])



try:

response = client.images.generate(model="dall-e-3",prompt=msg,
size="1024x1024",quality="standard",n=1,)

print(f"<img src='{response.data[0].url}' width=800px />")



except Exception as e:
print("An error occurred:", str(e))

This produces an image of 1K x 1K, and costs $0.03 per image. For my account, I generated 99 images on 5 March, and it cost $4.04 to generate these:

This gives a cost of around $0.04 per image generated. Thus, for a $20 subscription, you could generate up to 500 images per month for the same cost.

Here are my examples:

  • Examples. Examples. This generates some images.
  • Blockchain. Examples. This generates some images.
  • Hashing. Examples. This generates some images.
  • Symmetric. Examples. This generates some images.
  • Homomorphic. Examples. This generates some images.
  • Public key. Examples. This generates some images.

ChatGPT API

What about ChatGPT? For this, we get a cost of:

  • gpt-4: $0.03 per 1K tokens.
  • gpt-3.5-turbo-0125: $0.0005 / 1K tokens.

We can then use:

from openai import OpenAI
import sys

client = OpenAI(api_key='API KEY HERE')

msg="."

if (len(sys.argv)>1):
msg=str(sys.argv[1])



try:

completion = client.chat.completions.create(messages=[{ "role": "user",
"content": msg, } ],model="gpt-3.5-turbo",)
str = completion.choices[0].message.content
print(str)



except Exception as e:
print("An error occurred:", str(e))

On 4 March 2024, I generated 120 API calls, and it cost $0.03. The cost per call is approximately $0.00025. With this rate, we could get 80,000 API calls for the $20 subscription.

Here are my examples:

  • Blockchain. Terms. This defines some terms.
  • Hashing. Terms. This defines some terms.
  • Homomorphic. Terms. This defines some terms.
  • Key exchange. Terms. This defines some terms.
  • Light-weight cryptography. Terms. This defines some terms.
  • PQC. Terms. This defines some terms.
  • Public key. Terms. This defines some terms.
  • Symmetric key. Terms. This defines some terms.

Conclusions

If you do not produce thousands of ChatGPT queries each month and less than 100 images, then you are better off going with an API approach.

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.