This is a FastAPI application that allows users to upload an image file and receive a response from OpenAI's GPT-4 model describing the contents of the image. This is a FastAPI application that allows users to upload an image file and receive a response from OpenAI's GPT-4 model describing the contents of the image. The file-uploader folder contains a react application which you can build and run locally along with the main.py which happens to be the server.
cd file-uploader
npm install
npm startReturns a simple "Hello World" message to test the API.
Accepts an image file upload and returns a response from OpenAI's GPT-4 model describing the contents of the image.
OPENAI_API_KEY: Your OpenAI API key, loaded from a.envfile.
- FastAPI
- OpenAI
- dotenv
- cors
- Create a
.envfile with your OpenAI API key:OPENAI_API_KEY=your_api_key_here - Run the application with
uvicorn main:app --reloadorfastapi dev main.py - Use a tool like
curlor a web browser to upload an image file to the/uploadfile/endpoint
curl -X POST -F "file=@/path/to/image.jpg" http://localhost:8000/uploadfile/