Dall-e API: The server had an error processing your request

Hi friends!

Trying to ping the Dall-e API in node without using the openai module (using a raw POST request). My code looks like this:

const https = require('https');

const reqBody = {
    prompt: "something awesome",
    n: 1,
    size: "256x256",
};

const reqBodyString = JSON.stringify(reqBody);

const reqOptions = {
    host: 'api.openai.com',
    path: '/v1/images/generations',
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
    }
};

const req = https.request(reqOptions, (res) => {
    console.log(`STATUS: ${res.statusCode}`);
    console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
    res.setEncoding('utf8');
    res.on('data', (chunk) => {
        console.log(`BODY: ${chunk}`);
    });
    res.on('end', () => {
        console.log('No more data in response.');
    });
});

req.on('error', (e) => {
    console.error(`problem with request: ${e.message}`);
});

// Write data to request body
req.write(reqBodyString);
req.end();

When calling this script, I get the following error:

STATUS: 500
HEADERS: {"date":"Sun, 06 Nov 2022 22:00:33 GMT","content-type":"application/json","content-length":"366","connection":"close","access-control-allow-origin":"*","openai-version":"2020-10-01","openai-organization":"user-rr54mtqqvw3bewmpqppjqm7p","x-request-id":"808385b1515d5a4bc0b07547ebcc5c32","openai-processing-ms":"4691","strict-transport-security":"max-age=15724800; includeSubDomains"}
BODY: {
  "error": {
    "code": null,
    "message": "The server had an error processing your request. Sorry about that! You can retry your request, or contact us through our help center at help.openai.com if you keep seeing this error. (Please include the request IDXYZ in your email.)",
    "param": null,
    "type": "server_error"
  }
}

Any idea what’s going on? It doesn’t seem like a server outage problem, since I can ping the API using a openai module-based version of the script, and I get an image back…

Thank you!

Same, but different language. Postman works though?

I got it to work in python using requests.post() instead of the openai module. But for some reason, the nodejs example doesn’t quite work…

Just started working for me again after I took a few hour break. Didn’t change anything.

You are right, it started working for me again too!

Apologies, we had an issue with a deploy over the weekend that we rolled back as soon as we discovered this issue.

4 Likes

Hi i have a smilar error using React, but i may have wrong code. Is the server back or still has some issues ? Thanks !

1 Like

Welcome to the forum.

Server is working as far as I know from the outside.

What error are you getting?