Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

feat: support OPENAI_BASE_URL / XAI_BASE_URL for local LLM endpoints (#582)

acc4ever3ecfc9126c40
diff --git a/skills/last30days/scripts/last30days.py b/skills/last30days/scripts/last30days.py
index 6e353cc9..f07019e4 100644
--- a/skills/last30days/scripts/last30days.py
+++ b/skills/last30days/scripts/last30days.py
@@ -577,6 +577,27 @@ def _write_last_run(topic: str, report: "schema.Report") -> None:
pass
+def _propagate_config_to_environ() -> None:
+ """Push relevant env keys to os.environ so provider modules can read them.
+
+ The env.get_config() function reads from a .env file, but providers.py
+ reads from os.environ directly. Without this, OPENAI_BASE_URL and
+ XAI_BASE_URL overrides are silently ignored. This is a no-op for
+ keys that are already set in process env.
+ """
+ try:
+ config = env.get_config()
+ except Exception:
+ return
+ for key in ("OPENAI_BASE_URL", "XAI_BASE_URL"):
+ val = config.get(key)
+ if val and not os.environ.get(key):
+ os.environ[key] = val
+
+
+_propagate_config_to_environ()
+
+
def main() -> int:
parser = build_parser()
# Use parse_known_args so setup sub-flags (--device-auth, --github,
diff --git a/skills/last30days/scripts/lib/env.py b/skills/last30days/scripts/lib/env.py
index 225fbe56..93340f1d 100644
--- a/skills/last30days/scripts/lib/env.py
+++ b/skills/last30days/scripts/lib/env.py
@@ -393,6 +393,8 @@ def get_config() -> dict[str, Any]:
('LAST30DAYS_STORE', None),
('OPENAI_MODEL_PIN', None),
('XAI_MODEL_PIN', None),
+ ('OPENAI_BASE_URL', None),
+ ('XAI_BASE_URL', None),
('SCRAPECREATORS_API_KEY', None),
('APIFY_API_TOKEN', None),
('AUTH_TOKEN', None),
diff --git a/skills/last30days/scripts/lib/providers.py b/skills/last30days/scripts/lib/providers.py
index dffec4b9..9927111c 100644
--- a/skills/last30days/scripts/lib/providers.py
+++ b/skills/last30days/scripts/lib/providers.py
@@ -3,6 +3,7 @@
from __future__ import annotations
import json
+import os
import re
import sys
from typing import Any
@@ -144,7 +145,7 @@ class OpenAIClient(ReasoningClient):
"temperature": 0,
}
response = http.post(
- OPENAI_RESPONSES_URL,
+ os.environ.get("OPENAI_BASE_URL", OPENAI_RESPONSES_URL),
payload,
headers={
"Authorization": f"Bearer {self.token}",
@@ -175,7 +176,7 @@ class XAIClient(ReasoningClient):
"input": [{"role": "user", "content": prompt}],
}
response = http.post(
- XAI_RESPONSES_URL,
+ os.environ.get("XAI_BASE_URL", XAI_RESPONSES_URL),
payload,
headers={
"Authorization": f"Bearer {self.api_key}",