OPENAI command for finetune

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

Welcome to the developer forum!

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

One can also run line-by-line tedious commands from within the python shell.

In your operating system:
C:\users\yourname>python

Then a series of commands entered one at a time (or they can be concatenated with semicolon):

>>> import openai
>>> openai.api_key = "sk-12345xxxxx"
>>> models = openai.Model.list()
>>> print(models)

The above prints a long list of all AI models supported by an account.

Even the command for making a question to the AI is more typing than I want to do. Write a script/program that you just need to edit when you mess up.

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

Ahh, I see, have you done a

pip install --upgrade openai

?

openai tools should give a response like

image