How do I get the Image endpoint working with Postman?

I am getting it to download images with curl like…

curl https://api.openai.com/v1/images/generations \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer ...' \
  -d '{
  "prompt": "A cute baby sea otter",
  "n": 2,
  "size": "1024x1024"
}'

But when I try to do the same with postman I get the error…

{
    "error": {
        "message": "Invalid URL (POST /v1/images/generation)",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}

My request looks like this…

{
    "prompt": "Jackie R. Gleason as a spaceman",
    "n": 4,
    "size": "512x512"
}
2 Likes

Hey @jackiegleason, this is super nonintuitive but the issue is the R. in the prompt. If you omit the period, it will work fine, I just tested it locally. I will try to find out why this is the case and see if we can improve the docs at all here. Thanks for asking this!

2 Likes

Hm, odd, now I am able to get it work with the period included. I will continue to look into this!

1 Like

Yeah, I was gonna say that’s an odd one.

The error message infers it’s not getting the full openai URL, but I’m not that familiar with Postman.

Maybe it’s the way Postman sends authentication?

My gut says this is a weird intermittent failure but I am trying to diagnose further to be sure.

1 Like

Having a similar problem when the search prompt includes a hyphen. It works if I remove the hyphen.

{
“error”: {
“code”: null,
“message”: “Not allowed to GET on /v1/images/generations. (HINT: Perhaps you meant to use a different HTTP method?)”,
“param”: null,
“type”: “invalid_request_error”
}
}

Hey hi, I’ve just started exploring OpenAI models and to me, it is working pretty fine in postman so far, all 3 ImageModels, in can help if you need.

1 Like

Hye dheeraj bro, I got the same error in node

app.post('/', async (req,res)=>{
    try{
    const response = await openai.createImage({
        prompt: "a white cat",
        n: 1,
        size: "1024x1024",
      });
    const image_url = response.data.data[0].url;
    res.send(image_url);
    }
    catch (error) {
        res.send(error);
      }
})

Yes, pls help me. I also encounter this error.
“error”: {
“code”: null,
“message”: “Not allowed to GET on /v1/images/generations. (HINT: Perhaps you meant to use a different HTTP method?)”,
“param”: null,
“type”: “invalid_request_error”

I’m also getting the same error for days now
And I’ve gone through my code over and over
everything running fine:

{
  "error": {
    "code": null,
    "message": "Not allowed to GET on /v1/images/generations. (HINT: Perhaps you meant to use a different HTTP method?)",
    "param": null,
    "type": "invalid_request_error"
  }
}

Good day bro,
Please have you been able to resolve the error?
Thanks

Nope not yet I have moved on to other things for now

How to fix this error message?
Anybody knows how to fix this?
{
“error”: {
“code”: null,
“message”: “Not allowed to GET on /v1/images/generations. (HINT: Perhaps you meant to use a different HTTP method?)”,
“param”: null,
“type”: “invalid_request_error”
}
}

You need to use POST for the API endpoints

1 Like

I’ve got the same issue!
Even when using POST, the API endpoint for images v1 responds with this same error claiming (incorrectly) that a GET request was made.

Attaching a screenshot of the GH issue I opened for it since I’m too tired to retype it out. The code is functionally identical to that from the documentation and the browser console is very clearly showing a POST request.

I even manually constructed the http request to ensure the POST method is set, same result. What on earth is happening here???

2 Likes

same issue here too! Lmk if you figure this out @robriks @roypr0369