googleapis / googleapis/nodejs-agentplatform
Global location generates invalid request endpoint
- Dominant language
- TypeScript
- Stars
- 182
- Forks
- 69
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
#### Environment details
- Programming language: Typescript
- OS: Mac/Linux
- Language runtime version: v20.12.2
- Package version: v1.10.0
#### Steps to reproduce
1. Use the package to make a call to generateContent() with standard config/params with the global endpoint
2. Observe 404 Not Found exception
Code Example:
```
this.vertexAi = new VertexAI({
project:
location: 'global',
...
});
const generativeModel = this.vertexAi.getGenerativeModel({
model: 'gemini-2.5-flash-lite-preview-06-17',
generationConfig: {
...
});
const result = await generativeModel.generateContent(requestString);
```
Upon making a call to Vertex using `generateContent()` for a model only supported in `global` (for example gemini-2.5-flash-lite-preview-06-17), the call will fail due to an invalid base URL resolution.
When `apiEndpoint` is not configured when initializing `VertexAI`, the [following code](https://github.com/googleapis/nodejs-vertexai/blob/main/src/functions/post_request.ts#L58) will prepend `region` to the base path. This will resolve to `https://global-aiplatform.googleapis.com/v1/projects...` which is not a valid URL and will generate a 404 Not Found upon making the request.
Additionally, the library does not fail gracefully when hitting this issue. It throws the following exception back to the client:
```
Unexpected token '<', "
Contributor guide
Assessment
This issue has not been assessed yet.