mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
fix: use project-scoped Vertex URL for SA JSON auth and add ?alt=sse for streaming (closes #388)
When using SA JSON + Bearer token, Vertex AI requires a project-scoped URL.
The old code used the global publishers endpoint which only works with a raw API key,
causing RESOURCE_PROJECT_INVALID errors.
Changes in open-sse/executors/vertex.js buildUrl():
- SA JSON path: projects/{projectId}/locations/{location}/publishers/google/models/{model}:{action}
- Appends ?alt=sse for streaming on SA JSON path
- Location defaults to us-central1, overridable via providerSpecificData.location
- Raw API key path unchanged (global publishers + ?key= param)
Co-authored-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
Made-with: Cursor
This commit is contained in:
@@ -53,13 +53,22 @@ export class VertexExecutor extends BaseExecutor {
|
||||
return rawKey ? `${url}?key=${rawKey}` : url;
|
||||
}
|
||||
|
||||
// Gemini on Vertex: always use global publishers endpoint
|
||||
// ?alt=sse is required for proper SSE streaming (matches every other Gemini executor)
|
||||
const action = stream ? "streamGenerateContent?alt=sse" : "generateContent";
|
||||
let url = `https://aiplatform.googleapis.com/v1/publishers/google/models/${model}:${action}`;
|
||||
// Gemini on Vertex
|
||||
const action = stream ? "streamGenerateContent" : "generateContent";
|
||||
|
||||
// rawKey goes as a query param; use & because ?alt=sse already starts the query string
|
||||
if (rawKey) url += `&key=${rawKey}`;
|
||||
if (saJson) {
|
||||
// SA JSON + Bearer token: must use project-scoped path to avoid RESOURCE_PROJECT_INVALID
|
||||
const location = credentials?.providerSpecificData?.location || "us-central1";
|
||||
let url = `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/publishers/google/models/${model}:${action}`;
|
||||
if (stream) url += "?alt=sse";
|
||||
return url;
|
||||
}
|
||||
|
||||
// Raw API key: use global publishers endpoint with ?key= param
|
||||
// ?alt=sse is required for proper SSE streaming (matches every other Gemini executor)
|
||||
let url = `https://aiplatform.googleapis.com/v1/publishers/google/models/${model}:${action}`;
|
||||
if (stream) url += "?alt=sse";
|
||||
if (rawKey) url += stream ? `&key=${rawKey}` : `?key=${rawKey}`;
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user