Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DALL-E API 404 Resrouce Not Found #111250

Closed
alvinvinalon opened this issue Jun 22, 2023 · 4 comments
Closed

DALL-E API 404 Resrouce Not Found #111250

alvinvinalon opened this issue Jun 22, 2023 · 4 comments

Comments

@alvinvinalon
Copy link

[Enter feedback here]
I followed the steps written here (REST) and have confirmed both api-base and api-key are correct multiple times.
But when I run my python app, I get a 404 resource not found error.

I also tried the Python (Openai module) steps, and got a Resource Not Found issue too.

Our DALL-E instance is currently deployed in EAST US and I can successfully generate an image using the Azure OpenAI Studio.

I tested the REST API call in Postman and I get a 202 response with the following response:
{"id":"cf5e4e51-xxxx-xxxx-xxxx-193e338cdf4a","status":"notRunning"}

Is there anything I may have missed when using the DALL-E API in python? Cheers.

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@Naveenommi-MSFT
Copy link
Contributor

@alvinvinalon
Thanks for your feedback! We will investigate and update as appropriate.

@alvinvinalon
Copy link
Author

Hi there. I have fixed the issue. It's with the GET for the image generated that's stored in the storage blob. A mistakenly thought the 'operation-location' is the region and replaced it with 'eastus'. I reverted it back to 'operation-location' and it's working fine now. Thanks.

@RamanathanChinnappan-MSFT
Copy link
Contributor

@alvinvinalon

We are going to close this thread.if there are any further questions regarding the documentation, please tag me in your reply and we will be happy to continue the conversation.

@alduar
Copy link

alduar commented Mar 20, 2024

It appears that we are encountering an issue with the current version of the OpenAI library, which is not functioning as expected in our environment. A potential workaround for this problem is to make a direct REST API request to OpenAI’s service. This approach would allow us to have more granular control over the communication with the service and bypass the limitations we are experiencing with the library.
To implement a REST API request, we would need to construct a proper HTTP request, including the necessary headers and the request body, containing the parameters and information required by OpenAI’s API. We could then send this request using a tool like curl or a Python library such as requests.
Here’s a basic example of what the code might look like using the requests library in Python:
Solution CODE
`def generate_imageByREST(promp_user):
api_base = os.environ.get('OpenAIEndPoint') # Enter your endpoint here
api_key = os.environ.get('API_KEY') # Enter your API key here

    api_version = '2024-02-01'
    url = f"{api_base}openai/deployments/{deployment_ids}/images/generations?api-version={api_version}"
    headers= { "api-key": api_key, "Content-Type": "application/json" }
    body = {
        # Enter your prompt text here
        "prompt": promp_user,
        "size": "1024x1024", # supported values are “1792x1024”, “1024x1024” and “1024x1792” 
        "n": 1,
        "quality": "hd", # Options are “hd” and “standard”; defaults to standard 
        "style": "vivid" # Options are “natural” and “vivid”; defaults to “vivid”
        }
    submission = requests.post(url, headers=headers, json=body)
    image_url = submission.json()['data'][0]['url']
    logging.info(f'Image url: {image_url}')
    return image_url`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants