InvalidRequestError: Must provide an 'engine' parameter while invoking openAI API for text generation

Viewed 2596

I was trying this code given in OpenAI.

Link:- API for text generation

Code

import openai

prompt = """We’re releasing an API for accessing new AI models developed by OpenAI. Unlike most AI systems which are designed for one use-case, the API today provides a general-purpose “text in, text out” interface, allowing users to try it on virtually any English language task. You can now request access in order to integrate the API into your product, develop an entirely new application, or help us explore the strengths and limits of this technology."""

response = openai.Completion.create(model="davinci", prompt=prompt, stop="\n", temperature=0.9, max_tokens=100)

print(response)

I'm getting an error

Error

"Must provide an 'engine' parameter to create a %s" % cls, "engine". openai.error.InvalidRequestError: Must provide an 'engine' parameter to create a <class 'openai.api_resources.completion.Completion'>

I'm using python 3.7.6

2 Answers

If you get the error code:

...
InvalidRequestError: Engine not found

One possible problem could be your account setting does not offer you access to the engine. For example, embedding engines are only available for "private beta." You may need to request access to it for your account. The following code may get you the available engines to your account:

import openai

openai.api_key = your_openai_api_key

data = openai.Engine.list() for eng in data['data']:
    print(eng['id'])
Related