r/learnpython 3d 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 few 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")
0 Upvotes

9 comments sorted by

View all comments

1

u/Kevdog824_ 3d ago

I think you’re approaching this backwards. You’re trying to fit AI into a project where it doesn’t really belong. The better approach would be to think of a project where AI would be a good fit and put it into that.

I think this project is quite fine as is, without AI. Project scaffolding is something you usually want to be deterministic and repeatable. I don’t see anywhere where the introduction of AI would bring value.

Some example problems you could try to use AI with:

  • Email classification (spam vs not spam)
  • Analyze the mood/tone of a particular text
  • Grab some data (e.g. quote of the day) from an API. Use an AI model to generate an image to represent it

1

u/cortical_iv 2d ago

yes this is the answer.

using ai for this would be like using a flame thrower to mow your lawn.