Facing problem when deploying the GPT3 application

I am building a story generator application using GPT3. I have built the app using python flask. The application is running fine on the local. I wanted to test it so when I am deploying it on AWS EC2 instance the application is not able to fetch the key. The get and post request for the flask is working on the server. The issue is with the Openai API request. Can anyone help me in this, it would be of great help to me.


If i am not wrong you use .env file to expose your API keys locally it works. but If you are using VPS you need to that manually
may be this can help you


Thanks for your reply. From this document I am not getting how to place the key manually as you said. Can you please help me with this .

run this cmd in linux terminal

in python file test.py

import os

#check your env variable

Thankyou so much. Its fetching the API key and application is running now. :slight_smile:

1 Like

When I am hosting the application using WSGI nginx with the public IP , the application is running but after placing the OpenAI call its giving error in the browser and the error is

" Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."

After hosting it using public IP its not showing any error on the terminal.
Do you have any idea how why its not placing the OpenAI API call. Is it that the key is needed to be placed somewhere in the files of gunicorn or nginx. How can this be fixed. Kindly help me with this .

Hey you should definitely check your logs file there might be some information
Thats message won’t clear what is the cause of your error

Some suggestions

  • Check your browser console see is there is CORS errors so you need to use some pyrhon module

  • when you serve APIs you have to do some configuration in these server files as well I am not sure about ngix but with Apache we have this 000.default.config file where we add one line code to call api things “its hard to explain”

  • seaech for some tutorial thats calls some external api via same config as yours

Hope this help