Fix 80-remote-api.sh: stop auto-appending /chat/completions, take FX_REMOTE_API_URL exactly as given -- found by testing live against a real third-party API (a local FastAPI service) whose endpoint path did not match the guessed OpenAI convention

This commit is contained in:
2026-08-18 03:07:40 -04:00
parent f4b6b85bec
commit 1fc1f87be5
+10 -1
View File
@@ -10,6 +10,15 @@
# assumed, since guessing one could silently pick something you don't
# want to pay for. Silently no-ops if any of the three is missing.
#
# FX_REMOTE_API_URL is the exact URL to POST to -- no "/chat/completions"
# auto-appended. An earlier version guessed that suffix onto whatever
# base URL was given, which works for OpenAI/OpenRouter/Groq's actual
# convention but broke, silently, against a real third-party API that
# used a different path (a local FastAPI service with a plain "/chat"
# endpoint, not "/chat/.../completions" -- confirmed live: the guessed
# URL 404'd, the real one worked). Silent failure on a wrong guess is
# worse than requiring the full URL up front.
#
# Numbered 80: after the free local-LLM source (70) and before
# 90-team-shared.sh, which is a human-curated source and gets the final
# word. This is the most expensive tier in latency and real dollar
@@ -63,7 +72,7 @@ payload = {
}
req = urllib.request.Request(
url.rstrip("/") + "/chat/completions" if not url.rstrip("/").endswith("/chat/completions") else url,
url,
data=json.dumps(payload).encode(),
headers={
"Content-Type": "application/json",