Can you try passing the key directly “in the clear” rather than using the environment variable approach?
python openai --api-key sk-YOURKEYHERE --verbose
I assume that you are within the scripts folder. Set to verbose to see what comes up.
HTH.
Can you try passing the key directly “in the clear” rather than using the environment variable approach?
python openai --api-key sk-YOURKEYHERE --verbose
I assume that you are within the scripts folder. Set to verbose to see what comes up.
HTH.
Thanks a lot. It’s what I did before, but I get the help screen. It doesn’t seem actually to accept the key.

You are almost there. The rest of the arguments are not optional. Once you supply them, the command would work.
For reference, anything in [ ] is optional, anything else in { } is not. You need to use one of the tools or api arguments and proceed from there.
python openai --api-key sk-SOMETHING api answers… and so on.
Worked!
Thanks a lot, I tried to do it in two steps for hours 
Glad it worked.
The commands are atomic, i.e. they do not save state between runs. So everything you do, has to be done in ONE step.
For reference, you can open up the openai file in your favorite editor (its just a .py file, without an extension) and have a look.
Add openai path to your environment variable.
navigate to an environment variable in the control panel, there you will find edit PATH in user variable.
add the path openai exe file.
https://anaconda.org/conda-forge/openai
conda install -c conda-forge openai
works and I tried with Anaconda3-2021.05-Windows-x86_64.exe.
Description
The OpenAI Python library provides convenient access to the OpenAI API from applications written in the Python language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the OpenAI API.
This library additionally provides an
openaicommand-line utility which makes it easy to interact with the API from your terminal. Runopenai api -hfor usage.
Thanks for this, I am running on Power shell, let me try this
Yes! Colab seems to be easy.
I could not do something similar to this is PowerShell.
I navigated to the path open ai is, but couldn’t run any commands from that end
as mentioned in documentation, it is expecting latest version of library.
unfortunately latest version could not be installed in 2.7 / 3.5
installing openai in latest version of python (3.9) resolved this issue.
and you dont need to run openai under python
pip install --upgrade openai
openai api # will return you all parameters supported.
Is it possible to do thoses steps in an usual command prompt?
Thanks
Yes. There in nothing unusual about my command prompt either!
What exactly are you struggling with?
Hi all,
I got a similar issue when I try to run openai in my cmd prompt. I have python 3.9 installed with Anaconda, and I did
pip install --upgrade openai
but then when I run executable like
openai api (...)
I got this error:
'openai' is not recognized as an internal or external command,
operable program or batch file.
I tried also to navigate on the folder where openai is installed, as suggested here, and then tried to run alternatives like
python openai
or
`python -m openai`
but in these cases I got these errors:
C:\ProgramData\Anaconda3\python.exe: can't find '__main__' module in 'c:\\...\\Python39\\site-packages\\openai'
or (in the second case)
C:\ProgramData\Anaconda3\python.exe: No module named openai.__main__; 'openai' is a package and cannot be directly executed
Can anyone help me understand what i’m doing wrong?
Many thanks in advance to whoever can give me a hand
Hi,
Just try this (trick??)
On your Anaconda Prompt, navigate to the root of your C: drive and search for openai.exe

For me, I get three results corresponding to the 3 environments that I have OpenAI package installed in.
Navigate to the one corresponding to your environment, and just run openai from there!
HTH.
In the step 3., I get the following error message
python: can't open file 'C:\Users\user\AppData\Local\Programs\Python\Python39\Scripts\openai': [Errno 2] No such file or directory
Please share the results of dir /s openai.exe as a screenshot.
hey @vaibhav.garg, this is awesome, it worked for me. Thank you very much!!
@julienn try to remove “openai” from your path, that is:
C:\Users\user\AppData\Local\Programs\Python\Python39\Scripts\
it worked for me ![]()
Glad to know it helped! ![]()
@julienn did you miss this part from the original post as @maurizio.ragusa has also pointed out?