i installed openai using “pip install openai” and “pip show openai” show the details.
But when i use openai , getting command not found. It occurs both in window and linux. I could not find better docs or solution.
openai: command not found
result of show command
Name: openai
Version: 0.27.8
Summary: Python client library for the OpenAI API
etc
If I have understood this error correctly, you are trying to run the OpenAI library from the command line, that is not how it should be used, you should use a text editor to create a (in this case python) application that makes use of the OpenAI library.
import openai
openai.api_key = 'your-api-key'
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
]
)
print(response['choices'][0]['message']['content'])
This is a small example that will import the openaiai library, and make a call to the API endpoint and show you the reply. Not that putting your API key in the code like that is NOT best practice, but it is a quick way to check you have installed everything correctly.
You can read the documentation for further study here
And you can make use of the excellent free short courses here
Thanks for your reply. I am trying the below from windows and getting failed as “openai” command not found. Fine tuning the model using “openai tools” command