Skip to content

A FastAPI-based application that uses OpenAI's GPT-4 model to generate personalized workout routines based on user goals and experience levels.

Notifications You must be signed in to change notification settings

jcreforme/Routine-Generator-API-using-OpenAi

Repository files navigation

Routine Generator API

A FastAPI-based application that uses OpenAI's GPT-4 model to generate personalized workout routines based on user goals and experience levels.

WhatsApp Image 2025-08-09 at 5 48 20 PM WhatsApp Image 2025-08-09 at 5 49 12 PM WhatsApp Image 2025-08-09 at 5 49 53 PM

Author

Juan Carlo Reforme Sueyoshi

Features

  • Generates workout routines tailored to user goals (e.g., weight loss, strength training).
  • Supports different experience levels (e.g., beginner, intermediate, advanced).
  • Leverages OpenAI's GPT-4 model for intelligent and detailed responses.
  • Get exercise from a Database (e.g., Pierna, Abdomen, Pecho)

Requirements

  • Python 3.8 or higher
  • OpenAI Python library (openai)
  • FastAPI (fastapi)
  • Uvicorn (uvicorn)

Installation

  1. Clone the repository:
   git clone https://github.com/your-username/routine-generator.git
   cd routine-generator
  1. Create a virtual environment and activate it:
   python -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install the required dependencies:
   pip install -r requirements.txt
  1. Set your OpenAI API key as an environment variable: bash export OPENAI_API_KEY=your_openai_api_key Or replace your_openai_api_key directly in the code.

Usage

  1. Start the FastAPI server:
   uvicorn routine_generator:app --reload
  1. Access the API documentation at:
   http://127.0.0.1:8000/docs
  1. Use the /generate-routine endpoint to generate a workout routine. Example request:
   {
    "goal": "weight loss",
    "experience": "beginner"
    }

Example Response

    {
        "goal": "weight loss",
        "experience": "beginner",
        "routine": "1. Warm-up: 5 minutes of light jogging...\n2. Strength training: 3 sets of squats..."
    }

Project Structure routine-generator/ ├── routine_generator.py # Main application code ├── requirements.txt # Python dependencies └── README.md # Project documentation

Dependencies OpenAI Python Library FastAPI Uvicorn License This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments OpenAI for providing the GPT-4 model. FastAPI for the web framework.







About

A FastAPI-based application that uses OpenAI's GPT-4 model to generate personalized workout routines based on user goals and experience levels.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published