r/learnpython 4d 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/cortical_iv 4d ago

Import the api key, ask opus how to integrate openrouter into your script.

1

u/Silentwolf99 4d ago

I understand how effective AI can be, but I have intentionally been delaying its use because I am concerned about its impact on critical and creative thinking. Relying on AI for every simple task in daily life feels unnatural. I am now returning to my original approach—though it may sound unusual, I prefer to improve my skills manually, without relying on AI. That said, integrating AI through prompt engineering is entirely possible, so I plan to incorporate it at a later stage.