import os import subprocess import time import gradio as gr # Clone and build FreeLLMAPI if it doesn't exist if not os.path.exists("freellmapi"): subprocess.run(["git", "clone", "https://github.com/tashfeenahmed/freellmapi.git", "freellmapi"]) subprocess.run(["npm", "install"], cwd="freellmapi") subprocess.run(["npm", "run", "build"], cwd="freellmapi") # Start FreeLLMAPI Node process on port 3000 env = os.environ.copy() env["PORT"] = "3000" env["NODE_ENV"] = "production" process = subprocess.Popen(["npm", "start"], cwd="freellmapi", env=env) time.sleep(5) # Render simple Gradio dashboard wrapper with gr.Blocks() as demo: gr.Markdown("# ⚡ FreeLLMAPI Gateway") gr.Markdown("Your OpenAI-compatible `/v1` endpoint is live on this Space's direct URL.") gr.HTML('') demo.launch(server_port=7860)