adrianhajdin / project_ai_mern_image_generation

Build and Deploy a Full Stack MERN AI Image Generation App MidJourney & DALL E Clone
https://jsmastery.pro
1.09k stars 303 forks source link

Hello, when I create a new image, the following error appears in the alert: SyntaxError: Unexpected token 'B', "Billing yes"... is not valid JSON #3

Open ergashev2000 opened 1 year ago

Jayakrishna20 commented 1 year ago

Same here!! No typos not know what to do

adxxtya commented 1 year ago

yup, same problem here error - SyntaxError: Unexpected token 'B', "Billing ha"... is not valid JSON

RvDstudio commented 1 year ago

Also got the same error. SyntaxError: Unexpected token 'B', "Billing ha"... is not valid JSON

image

Jayakrishna20 commented 1 year ago

what does it mean by right api keys ??? I took the api key exacting like told in video ... even tried another time by creating a new key didnt work

shivvvuu commented 1 year ago

use right api key becouse when we copy it last 2-3 words don't copy so create new api key from dell-e and copy to the last

shivvvuu commented 1 year ago

and check when you made the function it gots an empty arrry

Jayakrishna20 commented 1 year ago

and check when you made the function it gots an empty arrry

in the server right?

ergashev2000 commented 1 year ago

There is a limitation of open ai api. Payment must be made and Open ai does not work in our country :(

adxxtya commented 1 year ago

Just learned it only works with paid account By "use right api key", Adrian meant "use paid api key" source - https://openai.com/api/pricing/

Screenshot 2023-01-24 120342

It's obvious when you think about it, when you use dall-e, you have limited queries to work with and you can't just infinitely query images using their api on your own app, that will be just as equal to abusing the api if they'd allow that.

matteoangeloni-jpeg commented 1 year ago

Ho appena appreso che funziona solo con account a pagamento Con "usa la chiave API corretta", Adrian intendeva la fonte "usa la chiave API a pagamento" - https://openai.com/api/pricing/[](https://openai.com/api/pricing/)

Schermata 24-01-2023 120342

È ovvio quando ci pensi, quando usi dall-e, hai query limitate con cui lavorare e non puoi semplicemente interrogare all'infinito le immagini usando la loro API sulla tua app, che sarà uguale ad abusare dell'API se lo permetterebbero.

hi! you are probably right but for example I ( in europe) have a credit of 18 dollars to use with the API even without having paid in advance. When I tested the code, the first few times the API worked and I was charged 0.02 cents per image. Today I spent a total of 0.10 cents so I still have plenty of credit to use but I still get the same error.

rookasrudzianskas commented 1 year ago

For anyone who is having the problem, OpenAI has two versions of accounts, free and paid. For certain API's as in this case DALL-E image generation you need paid account. Open AI, turns your account state into paid account, then you add your card information in billing section. So, to solve this error, you just have to add your card information to Open AI billing section, and it is going to work, without any more hassle. Yes, it is paid API, but if you have credits, it is going to use them first, and if you do not, then you are going to pay for the image. Happy coding 👋

matteoangeloni-jpeg commented 1 year ago

hi! I ( in europe) have a credit of 18 dollars to use with the API even without having paid in advance. When I tested the code, the first few times the API worked and I was charged 0.02 cents per image. Today I spent a total of 0.10 cents so I still have plenty of credit to use but I still get the same error.

chun-eric commented 1 year ago

Use the backend server url endpoint we created for dalleRoutes --> http://localhost:8080/api/v1/dalle

-> put the above url in the generateImage function in CreatePost.jsx.

const response = await fetch('http://localhost:8080/api/v1/dalle',

this worked for me. It may work for you.

TidbitsJS commented 1 year ago

hi! I ( in europe) have a credit of 18 dollars to use with the API even without having paid in advance. When I tested the code, the first few times the API worked and I was charged 0.02 cents per image. Today I spent a total of 0.10 cents so I still have plenty of credit to use but I still get the same error.

Exactly. OpenAI offers free credits when you create an account. To pay them later or not is your choice. Initially, you shouldn't have any problem. No cents needed

TidbitsJS commented 1 year ago

@ergashevislomjon, @rookasrudzianskas, @RvDstudio, and @shivvvuu, the reason you might be facing this issue can be the cause of Cloudinary. It's used to host images. And for that, you need your API keys as well. Or else, even if the image generates, you won't be able to share it with the community.

The functionality works like this:

  1. Generate image (You need OpenAI key) - This will send back the base64 data of the generated image to client-side
  2. Share image (You need both Cloudinary API Keys & MongoDB URL) - We're sending the selected generated image data, i.e., that base64, back to the server. Over here, using Cloudinary, we're first converting this base64 into an image URL. After that, we call MongoDB to store the post with this new image URL, not base64 data.

Note: Again, for all these services, you don't need to pay anything. They offer free credits.

We did the same. Sadly, everyone copy pasted the same API keys used in the Video leading to the free credits exhaustion we had. So kindly create your accounts & use your own API keys. Make sure to use the same API keys while deploying with Render as well.

Thank you!

shivvvuu commented 1 year ago

and check when you made the function it gots an empty arrry

in the server right?

I don't know why but openai api key keeps changing ,not in the server when you make the function at the end of it

shivvvuu commented 1 year ago

Just learned it only works with paid account By "use right api key", Adrian meant "use paid api key" source - https://openai.com/api/pricing/

Screenshot 2023-01-24 120342

It's obvious when you think about it, when you use dall-e, you have limited queries to work with and you can't just infinitely query images using their api on your own app, that will be just as equal to abusing the api if they'd allow that.

That's not the case here it also got free trial I'm using it

shivvvuu commented 1 year ago

https://main.d1fpkqmfq4v7da.amplifyapp.com/

this is my portfolio

Check this give a star on my github project and connect with me on LinkedIn

sankyrajeev commented 1 year ago

Its a billing issue. In his video. He created a new account on open AI. If you have used any of the OpenAI products in the past. Its likely you have run out of the trial version time. Your best bet would be to use an alternate email id to create a new account on openAI or buy a plan. This definitely works as i ran into the same issue. Hope this helps. Thank you

PedroLab0 commented 1 year ago

OpenAI gives $18 to new users. You have probably already spent it using one of their services. I recommend you to create another account and generate a new api key or pay to use it. Once it is set up it will not give you any more problems.

saurav4geeks commented 1 year ago

Greetings, Credits granted/purchased on labs.openai.com do not apply to DALL·E API. You need to add a payment method and pay $0.02 per image.

saurav4geeks commented 1 year ago

Greetings, Credits granted/purchased on labs.openai.com do not apply to DALL·E API. You need to add a payment method and pay $0.02 per image.

Ugyenwangdi commented 1 year ago

Hi friends,

in order to solve this issue we need to create a new account on openapi platform. Don't use Continue with google, we need to signup by providing our email address and password and then verify our account through email.

kumaresh-rgb commented 1 year ago

Same here!! No typos not know what to do

add your debit card and create new key that all

kumaresh-rgb commented 1 year ago

There is a limitation of open ai api. Payment must be made and Open ai does not work in our country :(

Add your debit card and create new key that all

kumaresh-rgb commented 1 year ago

Hi friends,

in order to solve this issue we need to create a new account on openapi platform. Don't use Continue with google, we need to signup by providing our email address and password and then verify our account through email.

Add your debit card and create new key that all

kumaresh-rgb commented 1 year ago

use right api key becouse when we copy it last 2-3 words don't copy so create new api key from dell-e and copy to the last

Add your debit card and create new key that all

kumaresh-rgb commented 1 year ago

what does it mean by right api keys ??? I took the api key exacting like told in video ... even tried another time by creating a new key didnt work

Add your debit card and create new key that all

roy9495 commented 1 year ago

can we do this with stable diffusion ai? it is free as of now.