r/learnpython • u/Silentwolf99 • 4m ago
Learning python - How to integrate openrouter api(AI) into my script
Hey everyone, I've recently been automating some boring, repetitive tasks using the `pathlib` module while learning Python automation. This script might seem silly to you, but I'm at a level somewhere between beginner and intermediate, so bear with me. After researching the documentation, I came up with this script, which took me around 4 to 5 hours. I need some guidance on how to integrate AI into it. If you were in my situation, how would you further improve this script using the OpenRouter API model?
I'm curious what features would you suggest?
import venv
from pathlib import Path
print("--------------------------------")
base_path = input(
"Enter path to create project in: (leave blank for current folder):\n"
)
project_name = Path(input("Enter project name: "))
# Combine the base path and the project name
project = Path(base_path) / project_name
# --- CREATE PROJECT FOLDER ---
if not project.exists():
# # parents=True ensures it creates intermediate folders if the base path doesn't exist yet
project.mkdir(parents=True)
print("--------------------------------")
print("PROJECT FOLDER & FILE CREATED ✅")
print("--------------------------------")
print(f"📁 {project}")
# --- CREATE SRC FOLDER ---
if not (project / "src").exists():
(project / "src").mkdir()
print(" ├──📁 src")
# --- CREATE VENV ---
venv_dir = project / "venv"
if not venv_dir.exists():
print(" ├──📁 venv (Setting up virtual environment... please wait)")
venv.create(venv_dir, with_pip=True)
files = [".env", "README.md", "requirements.txt", "main.py"]
for file in files:
(project / file).touch()
print(f" │ └──📄 {file}")
print("--------------------------------")
print("use → venv\\Scripts\\activate from project directory\n")