Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/core/src/core/loggingContentGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { CodeAssistServer } from '../code_assist/server.js';
import { toContents } from '../code_assist/converter.js';
import { isStructuredError } from '../utils/quotaErrorDetection.js';
import { runInDevTraceSpan, type SpanMetadata } from '../telemetry/trace.js';
import { resolveVertexServerDetails } from '../utils/baseUrlUtils.js';

interface StructuredError {
status: number;
Expand Down Expand Up @@ -94,6 +95,10 @@ export class LoggingContentGenerator implements ContentGenerator {

// Case 2: Using an API key for Vertex AI.
if (genConfig?.vertexai) {
const vertexCustomServerDetails = resolveVertexServerDetails();
if (vertexCustomServerDetails) {
return vertexCustomServerDetails;
}
const location = process.env['GOOGLE_CLOUD_LOCATION'];
if (location) {
return { address: `${location}-aiplatform.googleapis.com`, port: 443 };
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/utils/baseUrlUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import type { ServerDetails } from '../telemetry/types.js';

export function resolveVertexServerDetails(): ServerDetails | undefined {
if (process.env['GEMINI_CLI_VERTEX_BASE_URL'] === undefined) {
return undefined;
}
return { address: process.env['GEMINI_CLI_VERTEX_BASE_URL'], port: 443 };
}