Dall-e-3 Invalid_request_error Issue

Hello, i wanted to generate image but was stuck with 400 status code in my nodejs application. so i decided to first test out api in postman, but was met with “invalid_request_error”.
Here is the curl of the request:

curl --location 'https://api.openai.com/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--data '{
    "model": "dall-e-3",
    "prompt": "A flower",
    "n": 1,
    "size": "1024x1024"
}'

This is the response i receive:

{
    "error": {
        "message": null,
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}

What is the issue here?

If you look REALLY close, you’ll see that you can’t just send the words “API KEY”. I’ll have to assume that you are actually placing your API key.

Nor should you be hard-coding a key if that is meant to be what other code is using for CURL.

The dollar sign is retrieving the key from an environment variable.

We can’t see if the request is malformed or has bad characters because of the forum highlighting itself. Here, I use ```bash to start the code block, and then there aren’t directional quotes.

I observe without looking at the API reference below, the differences. You are not employing the positional URL parameter, and are putting the URL in quotes. Why? Is it that you are on Windows, where the line continuation backslash doesn’t work and then you are just sending the first line? Where you should be using the caret instead “^

curl https://api.openai.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "dall-e-3",
    "prompt": "An ugly baby sea otter",
    "n": 1,
    "size": "1024x1024"
  }'

Hey, thanks for the reply. But it now works with same curl, after only creating a new api key.