Commit a92672619ff3

Vincent Demeester <vincent@sbr.pm>
2026-04-23 14:50:19
fix: handle global Vertex AI endpoint URL
The global endpoint is aiplatform.googleapis.com, not global-aiplatform.googleapis.com. Regional endpoints use the {location}- prefix pattern.
1 parent 48840f0
Changed files (1)
tools
readwise-reader
tools/readwise-reader/readwise-reader.py
@@ -183,7 +183,10 @@ def _call_vertex_claude(model_id, prompt, max_tokens):
     import requests
     project = os.environ.get("GOOGLE_CLOUD_PROJECT", "itpc-gcp-pnd-pe-eng-claude")
     location = os.environ.get("GOOGLE_CLOUD_LOCATION", "global")
-    url = f"https://{location}-aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/publishers/anthropic/models/{model_id}:rawPredict"
+    if location == "global":
+        url = f"https://aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/publishers/anthropic/models/{model_id}:rawPredict"
+    else:
+        url = f"https://{location}-aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/publishers/anthropic/models/{model_id}:rawPredict"
     for attempt in range(MAX_RETRIES):
         token = _get_vertex_token()
         try: