This is a simple chat application that uses the OpenAI API, Next.js, SWR, TypeScript, Next Auth , and Firebase. The purpose of this application is to showcase how to use the OpenAI API to build a simple chat application.
To install and run the project, please follow these steps:
- Clone the repository.
- Run
npm install
to install the required packages. - In the
src
folder create firebase.ts file:
// Import the functions you need from the SDKs you need
import { getApp, getApps, initializeApp } from "firebase/app";
import { getFirestore } from 'firebase/firestore'
// Your web app's Firebase configuration
const firebaseConfig = {
// Add your own Firebase configuration details here
};
// Initialize Firebase
const app = getApps().length ? getApp() : initializeApp(firebaseConfig);
// Get a reference to the Firestore database
const db = getFirestore(app);
// Export the Firestore database reference
export { db };
- Add your OpenAI API key to the
.env.local
file. Example:
OPENAI_API_KEY=YOUR_API_KEY
- Run
npm run dev
to start the development server.
To use the application, simply login click "+". You can then send messages and receive responses generated by the OpenAI API. The application also supports real-time updates.
If you would like to contribute to this project, please feel free to fork the repository and submit a pull request. We welcome all contributions, big and small!
This project was created by modecode22 to showcase the use of the OpenAI API. We would like to thank the OpenAI team for providing such a powerful tool, as well as the creators of Next.js, SWR, TypeScript, and Firebase for their amazing work.