import openai
# Setup
openai.api_key = 'xxxxxxxxxxxxxxxxxxxxxx'
openai.api_base = "xxxxxxxxxxxxxxxxxxxxxx"
openai.api_version = '2024-08-20' # Ensure this is correct
def test_openai():
try:
response = openai.Image.create(
prompt="A dog in rain image",
model="dall-e-3", # Try with a different model ifneeded
n=1,
size="1024x1024"
)
print(response)
except Exception as e:
print(f"Error: {e}")
test_openai()
Error: Resource not found
I have created azure open ai model dall-e-3
the api key and api base both worked with model gpt-35-turbo
2
Answers
As the model name is based on the deployment, please refer to the latest documentation: azure documentation
The error you are getting because you need to use the Deployment name instead of the Model name.
You need to create client to connect to generate result.
Below code worked for me.
I am using a Flask app to use the openai code and view the generated image in
index.html
file.app.py
:templates/index.html
OUTPUT
: