Skip to content

Problems with connecting to chatGPT #114

Closed Answered by GreyDGL
wardellcastles asked this question in Q&A
Discussion options

You must be logged in to vote

Could you please send a sample request through your OPENAI_API? I guess that you did not link your payment method to OpenAI, but only subscribed for GPT-plus. In this case, your OpenAI key is not activated. You may try with this:

import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")

completion = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "user", "content": "Tell the world about the ChatGPT API in the style of a pirate."}
  ]
)

print(completion.choices[0].message.content)

If your key is valid, you should see a sample response.

Replies: 5 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@GreyDGL
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@wardellcastles
Comment options

@GreyDGL
Comment options

@GreyDGL
Comment options

@GreyDGL
Comment options

Answer selected by GreyDGL
Comment options

You must be logged in to vote
1 reply
@GreyDGL
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants