#API key
1 messages · Page 1 of 1 (latest)
Hi @deep valley. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
No, the ChatGPT Plus subscription does not include access to the ChatGPT API. They are billed separately. The API has its own pricing, which can be found at OpenAI Pricing (https://openai.com/pricing). The ChatGPT Plus subscription covers usage on chatgpt.com only and costs $20/month.
To access the API, you need to visit the OpenAI Platform (https://platform.openai.com/signup) and sign up or log in. You can create an API key in the dashboard, which you’ll use to securely access the API. Once you’ve generated an API key, you should export it as an environment variable in your terminal.
Here is an example of how to set the API key as an environment variable on Unix systems:
export OPENAI_API_KEY="your_api_key_here"
Remember to replace "your_api_key_here" with your actual API key.
Sources:
- How can I access the ChatGPT API? (https://help.openai.com/en/articles/7039783-how-can-i-access-the-chatgpt-api)
- Is the ChatGPT API included in the ChatGPT Plus subscription? (https://help.openai.com/en/articles/6950777-what-is-chatgpt-plus#h_e3d911c532)
- Developer quickstart (https://platform.openai.com/docs/quickstart)
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@deep valley Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@wide dew Do I get free messages with the API key in the beginning?
Let me check the knowledge base for you again. One moment! :books:
No, OpenAI does not provide free messages or credits with the API key. They used to offer free credits to new account creators, but that is no longer the case. Now, they use a prepaid pricing model. You need to pay for credits to start using the API. Once you’ve purchased credits, you should be able to start using the API. Note that there may be a couple of minutes of delay while the systems update to reflect your credit balance.
Please note that any purchased credits will expire after 1 year and they are non-refundable. Once you’ve consumed all your credits, your API requests will start returning an error letting you know you’ve hit your billing quota. If you’d like to continue your API usage, you can return to the billing portal (https://platform.openai.com/account/billing) and use the “Add to balance” button to purchase additional credits.
Sources:
- Forum Post: I am unable to get 5 USD free credit upon signup (https://community.openai.com/t/964343)
- Forum Post: OpenAI API Free plan error 429 (https://community.openai.com/t/956146)
- How can I set up prepaid billing (https://help.openai.com/en/articles/8264644-how-can-i-set-up-prepaid-billing)
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@deep valley Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@wide dew If I got 1M tokens, how many messages would that be ?
Let me check the knowledge base for you again. One moment! :books:
The number of messages that 1M tokens would translate to depends on the length of each message. In OpenAI's models, a token can be as short as one character or as long as one word. For example, "a" is one token, "apple" is also one token, and "a apple" is two tokens.
To see how many tokens are in a text string without making an API call, you can use OpenAI’s tiktoken (https://github.com/openai/tiktoken) Python library. Example code can be found in the OpenAI Cookbook’s guide on how to count tokens with tiktoken (https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken).
Each message passed to the API consumes the number of tokens in the content, role, and other fields, plus a few extra for behind-the-scenes formatting.
If a conversation has too many tokens to fit within a model’s maximum limit (e.g., more than 4097 tokens for gpt-3.5-turbo or more than 128k tokens for gpt-4o), you will have to truncate, omit, or otherwise shrink your text until it fits. Beware that if a message is removed from the messages input, the model will lose all knowledge of it.
So, if you have 1M tokens, the number of messages you can send will depend on the number of tokens each of your messages consumes.