Unable to properly generate dalle-3 logo images using python
The azure open ai studio is using api_version="2024-05-01-preview" the same while i am using in my python the error :resource not found If i change my api version to little lower openai.api_version = "2023-06-01-preview" it is working but the images are not properly/not related to prompt generated. I checked api key and endpoint no issue with that.
code:
import openai
import os
Set your Azure OpenAI credentials and endpoint
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY", "xxxxxxxxxx")
openai.api_base = "xxxxxxxxxxxxxxx"
openai.api_type = "azure"
openai.api_version = "2024-05-01-preview" # Adjust this based on your Azure API version
def generate_image(prompt):
try:
# Make a request to Azure OpenAI to generate an image with DALL-E 3
response = openai.Image.create(
prompt=prompt,
n=1, # Number of images
size="1024x1024" # Adjust size if needed
)
# Extract the URL of the generated image
image_url = response['data'][0]['url']
print(f"Image URL: {image_url}")
return image_url
except Exception as e:
print(f"Error generating image: {e}")
return None
if name == "main":
# Example prompt to generate an image
prompt = " create a circular logo on the name: python - python beginner "
image_url = generate_image(prompt)
if image_url:
print(f"Generated image available at: {image_url}")