Commit 3896130
Fix Vertex AI Global Endpoint URL Construction (#553)
### Problem
When configuring `RubyLLM` with `vertexai_location: "global"`, the
`VertexAI` provider incorrectly constructs the API URL as
`https://global-aiplatform.googleapis.com/v1beta1`. This hostname does
not exist, causing requests to fail with a 404 error.
According to the [Google Cloud Vertex AI
documentation](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/learn/locations#global-endpoint),
the global endpoint should use the base hostname
`https://aiplatform.googleapis.com/v1beta1` without a location prefix.
### Solution
Updated `RubyLLM::Providers::VertexAI#api_base` to handle `"global"` as
a special case:
- **Global:** Returns `https://aiplatform.googleapis.com/v1beta1`
- **Regional:** Continues to return
`https://{location}-aiplatform.googleapis.com/v1beta1` (e.g.,
`us-central1`)
### Changes
- Modified `lib/ruby_llm/providers/vertexai.rb` to conditionally build
the base URL.
- Added `spec/ruby_llm/providers/vertexai_spec.rb` to verify the URL
construction logic for both global and regional configurations.
### Verification
- [x] Added unit tests confirming correct URL generation for `global` vs
`us-central1` locations.
Co-authored-by: Carmine Paolino <carmine@paolino.me>1 parent bf218bd commit 3896130
2 files changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments