OpenAI API Quickstart tutorial - POST http://localhost:3000/api/generate 500 (Internal Server Error) - openai-api

Im new to OpenAI's API and am following the Quickstart tutorial found here:
https://beta.openai.com/docs/quickstart/build-your-application
I just cloned their GitHub repo (git clone https://github.com/openai/openai-quickstart-node.git) and when I tried to run it, I got this error.
POST http://localhost:3000/api/generate 500 (Internal Server Error)
Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
I don't understand what I missed, any help would be greatly appreciated.
source code

Encountered the same issue.
I simply just forgot to do the step involving adding the API_KEY to the .env file.
Follow the instructions from the documentation, specifically the title labelled "Add your API key" (https://beta.openai.com/docs/quickstart/add-your-api-key).
I have attached a screenshot of the instructions here. It is quite clear.
Hopefully this works for you!
Edit:
Also encountered the same problem when doing large requests. If there is a large request to the OpenAI API (i.e returning many tokens), then it will also return this same error.

Related

(Asana) XML is invalid: Headers are not supported on this surface

I am pretty sure I am using exactly the same code in the following two cases, as I tested it on Postman first.
The first time I tried to create a task from Postman, it has no issue.
The next time I tried to do the same from my NodeJS server, and it shows this error. I tried the client SDK package and manually calling through Axios, both are not working and throwing the same error.
Is the Asana API not callable from NodeJS server?
It turns out the "Headers" does not indicate the Headers sent with the request, but the "Headers" HTML Element inside the rich text field. Ensure there's no h1-h6 element in your html_notes can solve this issue.

Flutter not able to decode json data

I am currently learning flutter from a udemy course. Following the course now I am building a climate app using openweathermap.org's api. The app was working fine with default location of the emulator but then I followed my instructor and customized the app so that it can use the device current location but the app was not responding and was returning statusCode as 401. I tried running my instructor's code as well but the same problem was there as well so if anyone can tell me the reason of the statusCode being 401 because when I ran the url it gave the correct json data but I think android studio(Flutter) was not able to decode json data.
If someone can please justify the reason for the problem please respond.
Thankyou
This could be caused because of an invalid or bad API key. You can get an API key from the openweathermap.api.
Once it works it will return a 202 status code.

laravel socialite facebook loging error This authorization code has been used

i am using lavel/socialite in laravel project version 5.4
Now i am facing an error
ClientException
Client error: `POST https://graph.facebook.com/v3.0/oauth/access_token`
resulted in a `400 Bad Request` response:{"error":{"message":"This
authorization code has been used.","type":"OAuthException", "code":100,
"fbtrace_id":"F7xwAj18Ez (truncated...)
some times it working and sometimes showing this error.
have any suggestions to solve the issue.
in some cases, you can use a simple condition
if (!$request->has('code') || $request->has('denied')) {
return redirect('/');
}
because when you try more than once facebook will not allow for gave information request.

Node.js Issues with TwitterBot

I created a twitter bot via the instructions here:
https://medium.freecodecamp.com/easily-set-up-your-own-twitter-bot-4aeed5e61f7f#.5ifmh6ihn
I keep getting an error "Cannot read property 'id_str' of undefined Query String". I don't know much about node.js and just want this thing to work. I googled the error and didn't find much help. I left a comment on the post and haven't received any response there. Any help?

How to send POST variables with Nipple on NodeJS

I am trying to use nipple to post to an url within my nodejs application, which itself is running on hapi.js
The documentation essentially doesn't seem to spell it out.
(https://www.npmjs.com/package/nipple)
I tried passing it as payload inside options but that, while not returning an error, returns a 400. Can someone provide a correct example doing a post using nipple?
Essentially, I have two variables that I need to send - let's call the var1 and var2.
Thanks!
That link says that the project has been renamed to wreck. On wreck's github, several of the tests are for a post requests, including this one:
https://github.com/hapijs/wreck/blob/master/test/index.js#L68
If you are still scratching your head, you could also try using curl or postman to sanity check your URL, regardless of any nipple/wreck errors. If that also gives you a 400, nipple/wreck may not be the culprit.

Resources