A FastAPI-based web service that generates beautiful haikus about any theme using OpenAI's GPT-3.5 model.
- Generate unique haikus based on user-provided themes
- RESTful API endpoints
- Powered by OpenAI's GPT-3.5 model
- Health check endpoint
- Python 3.8+
- OpenAI API key
- Clone the repository:
git clone <your-repo-url>
cd AI-Haiku-Poet
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
- Copy
.env_example
to.env
- Add your OpenAI API key to the
.env
file:
- Copy
OPENAI_API_KEY=your_api_key_here
- Run the application:
uvicorn main:app --reload
GET /haiku?theme={theme}
theme
(optional): The theme for the haiku
Example response:
{
"Haiku": "Inkling in the woods\nWhispers of the ancient trees\nNature's secrets told"
}
GET /health
Example response:
{
"Health": "Ok"
}
The application uses Gunicorn as the WSGI server for production deployment:
- Install Gunicorn if not already installed:
pip install gunicorn
- Start the application with Gunicorn:
gunicorn main:app -c gunicorn.conf.py
Key considerations for production:
- Ensure your
.env
file is properly configured with production settings - Use appropriate security headers and CORS settings
- Set up proper monitoring and logging
- Consider using a reverse proxy like Nginx in front of Gunicorn
MIT License