A minimal Flask-based API wrapper for OpenAI, with Swagger UI documentation support.
- Simple
/generateendpoint to send prompts to OpenAI's Chat API. - Swagger UI at
/docsfor testing and visual documentation. - Uses environment variables for security.
- Clean, professional folder structure.
AI-API-Wrapper/
│
├── app.py # Main Flask app
├── .env # Your OpenAI API Key
├── requirements.txt # Dependencies
├── static/
│ └── swagger.json # Swagger specification
├── templates/ # (Optional for HTML, not used here)
└── README.md
git clone https://github.com/your-username/AI-API-Wrapper.git
cd AI-API-Wrapperpython -m venv venv
venv\Scripts\activate # For Windows
source venv/bin/activate # For Linux/Macpip install -r requirements.txtCreate a .env file:
OPENAI_API_KEY=your_openai_key_here
python app.pyGo to: http://localhost:5000/docs for Swagger UI
or POST to http://localhost:5000/generate with JSON body.
POST /generate
{
"provider": "openai",
"prompt": "Tell me a joke",
"model": "gpt-3.5-turbo"
}- Railway
- Render
- EC2
- Fly.io
- Localhost
MIT License. Use it freely.