This project aims to develop a Python API that generates text based on keywords and/or short input phrases. One potential use case is to dynamically create web pages for affiliate market products.
The project will use Flask as the main framework for the API and ChatGPT as the text generation model.
We currently have a functional prototype in a Jupyter notebook, featuring a single endpoint API. This API receives a JSON payload with user input and returns text generated by the selected AI model.
{
"prompt": "Let's create a page about a product to try and sell on an affiliate marketplace for profit. Generate 2 paragraphs (about 500 words each) for this product based on the following keywords, the first is the product:",
"keywords": "'Led Zeppelin first album', 'rock', 'vinyl', 'classic', 'collector', 'guitar', 'bass', 'band', 'guitarist'",
"system-role": "Act as a helpful assistant for SEO purposes. You will only provide the content of the requested text, without intros or outros. You will speak only in English with an American accent."
}JWT is an open standard that allows information to be transmitted securely in JSON format between two parties.
We need the library Flask JWT Extended:
pip install Flask-JWT-ExtendedThe next step is add user/password real authentication to get the JSON Web Token and add rate limits to API connections.
- 🎓 Python 3.11
- ⚡️ Flask 3
- 📓 Jupyter Notebook or Google Colab
- 🔮 OpenAI API | ChatGPT
Clone this repository, navigate to your local directory and start the Python virtual environment:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCopy .env.example to .env in the root directory and set its values.
Also available in: Spanish