📘 README available in Spanish
This project implements the backend of a chat system with artificial intelligence using FastAPI and OpenAI. It allows managing conversations between users and an advanced language model, providing automatic responses.
-
FastAPI: Framework for building fast and modern APIs in Python.
-
OpenAI API: For generating automatic responses using language models.
-
Python 3.13.3
-
CORS Middleware: Enables secure communication between frontend and backend.
Create the .env file in the root directory and define the following variable:
OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
- Clone the repository:
git clone https://github.com/nuriadevs/backend-chat.git
cd backend-chat
- Install dependencies:
pip install -r requirements.txt
Start the development server:
uvicorn app.main:app --reload --port 8000
The backend will be available at http://localhost:8000.
-
POST /chat: Send messages and receive responses from the AI model. -
GET /: Test endpoint to verify that the backend is active.
To run the test suite, execute the following in the application's root directory:
pytest or pytest -s
-
Don't forget to create the .env file with the OpenAI variable.
-
This project is designed to be scalable.
If you want to send me any message, suggestion, or collaboration proposal, don't hesitate to write to me through my social networks. Greetings!