My development code and this test code (api key valid for gpt-4) worked until last night when I exceeding my credit balance; although I added more monies to the balance over 5 hours ago, I still canât access gpt-4 or 3.5 whilst âDavinciâ works. I have ChatGPTPlus subscription and Credit Balance $20.
import openai
openai.api_key = 'YOUR_API_KEY'
def is_api_key_valid():
try:
response = openai.Completion.create(
model="davinci",
prompt="This is a test.",
max_tokens=5
)
except:
return False
else:
return True
# Check the validity of the API key
api_key_valid = is_api_key_valid()
print("API key is valid:", api_key_valid)
API key is valid: True <â Davinci
API key is valid: False â gpt-4 or gpt-3
This workedâŚ
curl https://api.openai.com/v1/chat/completions
-H âContent-Type: application/jsonâ
-H "Authorization: Bearer âmy api keyâ
-d â{
âmodelâ: âgpt-4â,
âmessagesâ: [{âroleâ: âuserâ, âcontentâ: âSay this is a test!â}],
âtemperatureâ: 0.7
}â
{
âidâ: âchatcmpl-7sxzaBmtUbGAG6Q4QIgdZtiZIRHHsâ,
âobjectâ: âchat.completionâ,
âcreatedâ: 1693334678,
âmodelâ: âgpt-4-0613â,
âchoicesâ: [
{
âindexâ: 0,
âmessageâ: {
âroleâ: âassistantâ,
âcontentâ: âThis is a test!â
},
âfinish_reasonâ: âstopâ
}
],
âusageâ: {
âprompt_tokensâ: 13,
âcompletion_tokensâ: 5,
âtotal_tokensâ: 18
}
}
But I list the models and appears to me no longer have access to gpt-4. I am current on my ChatGPTPlus subscription and it has been over 5 hours since I replenished my balance.
import os
import openai
openai.api_key = âMy API Keyâ
openai.Model.list()
<OpenAIObject list at 0x7f8350083710> JSON: {
âobjectâ: âlistâ,
âdataâ: [
{
âidâ: âdavinciâ,
âobjectâ: âmodelâ,
âcreatedâ: 1649359874,
âowned_byâ: âopenaiâ,
âpermissionâ: [
{
âidâ: âmodelperm-uJaD4C9nXA6tPNoBII9hcYF4â,
âobjectâ: âmodel_permissionâ,
âcreatedâ: 1692634268,
âallow_create_engineâ: false,
âallow_samplingâ: true,
âallow_logprobsâ: true,
âallow_search_indicesâ: false,
âallow_viewâ: true,
âallow_fine_tuningâ: false,
âorganizationâ: â",
âgroupâ: null,
âis_blockingâ: false
}
],
ârootâ: âdavinciâ,
âparentâ: null
},
{
âidâ: âgpt-4-0314â,
âobjectâ: âmodelâ,
âcreatedâ: 1687882410,
âowned_byâ: âopenaiâ,
âpermissionâ: [
{
âidâ: âmodelperm-eJxIX8r0jTNkOTBy09sEo3Cpâ,
âobjectâ: âmodel_permissionâ,
âcreatedâ: 1693326339,
âallow_create_engineâ: false,
âallow_samplingâ: false,
âallow_logprobsâ: false,
âallow_search_indicesâ: false,
âallow_viewâ: false,
âallow_fine_tuningâ: false,
âorganizationâ: "â,
âgroupâ: null,
âis_blockingâ: false
}
],
ârootâ: âgpt-4-0314â,
âparentâ: null
},
{
âidâ: âgpt-4â,
âobjectâ: âmodelâ,
âcreatedâ: 1687882411,
âowned_byâ: âopenaiâ,
âpermissionâ: [
{
âidâ: âmodelperm-tsET7VSHRhiQHP5Qz6TU1FBbâ,
âobjectâ: âmodel_permissionâ,
âcreatedâ: 1693330062,
âallow_create_engineâ: false,
âallow_samplingâ: false,
âallow_logprobsâ: false,
âallow_search_indicesâ: false,
âallow_viewâ: false,
âallow_fine_tuningâ: false,
âorganizationâ: â*â,
âgroupâ: null,
âis_blockingâ: false
}
],
ârootâ: âgpt-4â,
âparentâ: null
},
.
.
.
ChatGPTPlus was not helpful do I call Billing?