HTTP status for Chat completion

How do I get HTTP status code with the latest version of OpenAI library 4.4.0 in NodeJS. In the older version, I could use response.status to get the HTTP status to check whether there was an error. How do I check that the response to my API call is correct. For example, I am using NodeJS as follows:

    const request = {
        model: model,
        messages: [
            {
                role: 'user',
                content: prompt,
            },
        ],
    };

    // Call the OpenAI API
    const response = await openai.chat.completions.create(request);

With the previous version I could just do:

    if (response.status === 200) {
        res.status(response.status).json({
            message: response.choices[0].message.content,
        });

But now with 4.4.0 response doesnā€™t have a status field.

1 Like