Environment details
- Programming language: Typescript
- OS: Mac/Linux
- Language runtime version: v20.12.2
- Package version: v1.10.0
Steps to reproduce
- Use the package to make a call to generateContent() with standard config/params with the global endpoint
- Observe 404 Not Found exception
Code Example:
this.vertexAi = new VertexAI({
project: <project_id>
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 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 '<', "<!DOCTYPE "... is not valid JSON
instead of an exception describing the problem, thus making debugging significantly more difficult. This is due to the linked code calling JSON.parse() when the response stream format is an HTML document instead of valid JSON.
Environment details
Steps to reproduce
Code Example:
Upon making a call to Vertex using
generateContent()for a model only supported inglobal(for example gemini-2.5-flash-lite-preview-06-17), the call will fail due to an invalid base URL resolution.When
apiEndpointis not configured when initializingVertexAI, the following code will prependregionto the base path. This will resolve tohttps://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:
instead of an exception describing the problem, thus making debugging significantly more difficult. This is due to the linked code calling
JSON.parse()when the response stream format is an HTML document instead of valid JSON.