Skip to content

ZobayerAkib/LinkedIn-Post-Generation-using-FastApi-and-OpenAI-api-AI-Agent-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 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!

About

Fast API, OpenAI api, Ai agent, Automation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages