Skip to content

Latest commit

 

History

History
80 lines (63 loc) · 2.42 KB

File metadata and controls

80 lines (63 loc) · 2.42 KB

🚀 LinkedIn Post Generator API (FastAPI + OpenAI)

Typing SVG

This repository provides a FastAPI-based API that automatically generates professional LinkedIn-style posts using OpenAI-compatible models.
The API supports two key domains:

  • 🩺 AI in Healthcare
  • 🧑‍💻 Remote Work Productivity

Each endpoint produces a 2–4 paragraph LinkedIn post written in a professional, engaging tone, complete with hashtags and emojis, in any specified language.


LinkedIn Post Generator

⚙️ Setup Instructions

1️⃣ Clone the Repository

git clone https://github.com/yourusername/LinkedIn-Post-Generator.git
cd LinkedIn-Post-Generator

2️⃣ Create a Virtual Environment

python -m venv venv
source venv/bin/activate   # On macOS/Linux
venv\Scripts\activate      # On Windows

3️⃣ Install Dependencies

pip install -r requirements.txt

requirements.txt

fastapi==0.115.6
uvicorn==0.32.1
openai==1.66.3
python-dotenv==1.0.1
pydantic==2.10.6

4️⃣ Configure Environment Variables

BASE_URL="https://models.github.ai/inference"
API_KEY="your_api_key_here"
MODEL_NAME="openai/gpt-4.1-nano"

▶️ Run the API

uvicorn main:app --reload

Then open your browser and go to:

 http://127.0.0.1:8000/docs

You’ll see the Swagger UI, where you can interact with the API endpoints directly.

🧠 How It Works

  • Loads environment variables from .env.
  • Initializes the OpenAI client using the provided base URL and API key.
  • Builds a prompt dynamically based on the request topic and language.
  • Returns a professional LinkedIn-style post as a JSON response.

🛡️ Security Notes

  • Never expose your .env or API key in public repositories.
  • Use environment variables in deployment environments.
  • Consider adding authentication if deploying publicly.

👨‍💻 Author

Md. Zobayer Ibna Kabir

Let's collaborate, share knowledge, and create amazing projects together!