Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DALLE API not working #16

Open
SergDeved opened this issue Jun 5, 2023 · 13 comments
Open

DALLE API not working #16

SergDeved opened this issue Jun 5, 2023 · 13 comments

Comments

@SergDeved
Copy link

I have done all the pertinent steps but when I try to send some data to the API the page collapses in the terminal and in the console it returns several errors, I have tried downloading the repo and it gives me exactly the same error, it is not a KEY_API problem because Yes, it is shown as used on the web. Is it possible that the API has changed some configuration or is it paid or something?

@SheikhCodes
Copy link

same bro I m facing the same issue .

@SergDeved
Copy link
Author

I have already solved it, the problem is that I had no credits left in my openai account, well they had expired, I recommend that you create a new account or well add them by paying, if you create a new account they will give you $5.
For each interaction with the API they charge you about 2 cents

@SoumyaSubhrajit
Copy link

@SheikhCodes thank you for sharing but, is openAi not free? can we not used it for daily use cases via api call?

@aynerd2
Copy link

aynerd2 commented Jun 10, 2023

Thanks, I had the same issue. I created a new account, generated the api-key and it worked

@SergDeved
Copy link
Author

@SheikhCodes thank you for sharing but, is openAi not free? can we not used it for daily use cases via api call?

It's not free to use the api

@pradeepthsjain
Copy link

As soon as i click on ai full or ai logo button my screen goes white and i can see errors on the server terminal and even in inspect console.
Screenshot (8)
![Screenshot (9)](https://github.com/adrianhajdin/project_threejs_ai/assets/115602871/712d6f9b-014d-4565-a1fd
Screenshot (10)
-8d91beeafb68)
Screenshot (11)
Can someone please help me out with this....?

@SoumyaSubhrajit
Copy link

@pradeepth02 bruh to use the openAI API key you have to pay for that, otherwise it will not work thats why you get the error.
Suggestion: If you purchase the API key then it's fine otherwise just find another api key for free.

@FredDaFed
Copy link

FredDaFed commented Aug 25, 2023

Issue persists even with credits. Is there a caveat for free credits versus paid? It should work but I have same issue.

image

The API usage doesnt even hit to show stats.

image

Last month it worked:

image

And I still have credit. <======As seen above

Issue seen in devtools in chrome:

image

Full result of issue for DallE API through openAIAPI:

image

UPDATE:
So, there is no issues with the API as I have made a new API key and tested as a bearer key in postman and I got a response.

500 ERROR:


So I am getting a 500 from the code as a createImage function doesnt exist?:
image

openai.createImage() does not exist?:
image
AND the path via file dalle.routes.js
image

API works and tested with postman:
NEW API
image
POSTMAN TEST SUCCESS - so its not an API credit issue.
image

Here is a test for the image creation API call, it works just not through the code of this project:
image

I want to say I screwed up somewhere in the code or something is deprecated or API path is wrong.
Any ideas? Thanks fellas!

@pradeepthsjain
Copy link

pradeepthsjain commented Aug 25, 2023 via email

@FredDaFed
Copy link

FredDaFed commented Aug 25, 2023

I think it has expired your 5 dollar that they had provided

On Fri, 25 Aug 2023 at 12:50 PM, FredTheFed @.> wrote: Issue persists even with credits. Is there a caveat for free credits versus paid? It should work but I have same issue. [image: image] https://user-images.githubusercontent.com/111554585/263195355-2ad0123c-4c59-4bdc-9fbc-304d250ad22b.png The API usage doesnt even hit to show stats. [image: image] https://user-images.githubusercontent.com/111554585/263195835-ba8d0994-df93-4b94-89e7-91aae29ae4d1.png Last month it worked: [image: image] https://user-images.githubusercontent.com/111554585/263195874-e0776432-08d9-41b4-a763-94117a3541a6.png And I still have credit. Issue seen in devtools in chrome: [image: image] https://user-images.githubusercontent.com/111554585/263196435-6b22d760-eab9-40da-90b2-e927d953a59e.png Full result of issue for DallE API through openAIAPI: [image: image] https://user-images.githubusercontent.com/111554585/263196670-179ab2ae-a671-4068-9154-04d6eee2d42e.png Any ideas? Thanks fellas! — Reply to this email directly, view it on GitHub <#16 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3R7LN6EHBCBQAAH3MCZ3ALXXBG2HANCNFSM6AAAAAAY3QXXVI . You are receiving this because you were mentioned.Message ID: @.>

No, it says I still have credit:
image

And I have just shown it works in postman. Please read what I post, its NOT A CREDIT ISSUE. I got like 500 emails and I am testing, its not a credit issue.

This is what it looks like from an account thats expired:
image

image

Here is one that is NOT and this is the account that should work and is not expired yet.
image

image

@FredDaFed
Copy link


UPDATE


ISSUES:

  1. Customizer.jsx:53 POST http://localhost:8080/api/v1/dalle 500 (Internal Server Error)
  2. Server has started on port 8080
    TypeError: openai.createImage is not a function
  3. Internal server error when making a POST request to http://localhost:8080/api/v1/dalle. This error could be due to various reasons, including issues with the API request, server configuration, or the way data is being processed.

CASCADING FILES AFFECTED:

  1. @ the Customizer.js file, the const response = await fetch('http://localhost:8080/api/v1/dalle', {
  2. dalle.routes.js @
import { Configuration, OpenAIApi} from 'openai'`; 

and

const config = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(config); 

NOTE: Follow harshit4317's recommendations
3. server > package.json @ "openai": "^3.2.1" NOTE: The version used is "openai": "^4.0.0"
----> This will change the method call for create.Image() SOLUTION: needs to be images.generate @ the dalle.routes.js file

SOLUTION:

  1. After applying harshit4317's recommendations, issues still occured. I have changed the import to this:
import OpenAi from 'openai'

The block of code affected and modified:

const openai = new OpenAi({
    organization: process.env.ORG_ID,
    apiKey: process.env.OPENAI_API_KEY
})
  1. Changes related to the createImage function, it's recommended to refer to the migration guide for transitioning from v3 to v4 of the OpenAI API.
    Migration guide: v3 to v4 Migration Guide openai/openai-node#217

@dalle.routes.js
BEFORE:

const response = await openai.createImage({
        prompt,
        n: 1,
        size: '1024x1024',
        response_format: 'b64_json'
      })

SOLVED:

const response = await openai.images.generate({
        prompt,
        n: 1,
        size: '1024x1024',
        response_format: 'b64_json'
      })
  1. I still had issues but there was a typo @ const image = response.data.data[0].b64_json
    FIXED:
    const image = response.data[0].b64_json
    Just deleted the extra 'data' typo and issue was fixed. I hope this helps.
    image

@Lupe-Fiasco
Copy link

@FredDaFed Bro, do I need to pay for using api-key? Because I tried your method but it still doesn't work

@jayjay2397
Copy link

@FredDaFed Bro, do I need to pay for using api-key? Because I tried your method but it still doesn't work

you have to fund the openAI API, the funds they provide or the ones you pay for are only valid for a month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants