I keep getting
error = response: {
status: 400,
statusText: 'Bad Request',
headers: {
date: 'Fri, 21 Jul 2023 04:41:13 GMT',
'content-type': 'application/json',
'content-length': '172',
connection: 'close',
'access-control-allow-origin': '*',
'openai-version': '2020-10-01',
'openai-organization': 'user-1qylvymj1b3srv0efmvejjjh',
'x-request-id': '03c8b1cfdb999d1c8a8b9b86b53a5cef',
'openai-processing-ms': '87',
'strict-transport-security': 'max-age=15724800; includeSubDomains',
'cf-cache-status': 'DYNAMIC',
server: 'cloudflare',
'cf-ray': '7ea0c52e69623ea6-CPT',
'alt-svc': 'h3=":443"; ma=86400'
}
this is my code,
please help me, thank you.
Welcome to the forum!
This post may be of interest to you,
why not getting urls instead of b64_json?
I tried the following example and it works, I’m not sure what your client looks like and what you want to achieve through this api, but in any case the url is best practice.
// Server side
import express from 'express';
import { Configuration, OpenAIApi } from 'openai';
import dotenv from 'dotenv';
// Load environment variables from .env file
dotenv.config();
const app = express();
app.use(express.json());
const configuration = new Configuratio…
1 Like
thank you for the response but the post still didn’t clear the error. this is client side of my code, the post request is made in the handleSubmit function
This is also a screenshot of the post request on postman .
Is this error coming from your client to your backend, or from the backend to the OpenAI API?
It is from the backend to the OpenAI API
it is coming from this " const response = await openai.createImage({
prompt: “A cute baby sea otter”,
n: 2,
size: “1024x1024”,
});" in the post request.
Ok, and have you checked that your API key is getting read in correctly from the environment? i.e. have you logged it to console as a test?
Also things like, making sure your API account has a payment method assigned to it.
The API key is getting read in correctly from the environment, and I haven’t added a payment method yet. Does that mean I can’t make a post request without adding my card to the payment method?
Can you generate an image from the labs site?
I can’t generate an image, it says i don’t have credit and i should buy 1
Ok, then that seems to be the issue, if you add credit you should be able to generate images.