While trying to create OpenAI client, I get following error
module 'openai' has no attribute 'Client'
This is my code
import openai
client = openai.Client(api_key=os.environ['OPENAI_API_KEY'],)
Output of “pip show openai”
Name: openai
Version: 0.28.0
Summary: Python client library for the OpenAI API
Home-page: https://github.com/openai/openai-python
Author: OpenAI
Author-email: support@openai.com
License:
Location: /usr/local/lib/python3.10/site-packages
Requires: aiohttp, requests, tqdm
Required-by:
I have tried different version of OpenAI suggested in this thread “community.openai[dot]com/t/attributeerror-module-openai-has-no-attribute-chatcompletion/81490” but none worked.
vb
2
Hello and welcome to the forum!
The latest version of the openai library is currently at 1.X
Try updating and see if that solves your issue.
1 Like
I installed to latest version of OpenAI which is “1.2.4” but that didn’t work
N2U
4
Try writing “client” instead of “Client” 
(There’s a difference in capitalization)
2 Likes
Same error persist but this time with “client”.
I was able to get mine working by doing this:
import openai
import requests
from openai import OpenAI
client = OpenAI()
Hopefully that might work for you too.
From what I understand this automatically uses your saved API key
1 Like
This really did work for me. Thank you!
2 Likes
Don’t thank me, GPT-4 told me how to fix it 
1 Like