Allow configuring GCP project and location in provider settings (#56560)

## Why

Deriving a Vertex AI endpoint previously required environment variables. Allow the project and location to be specified directly in GCP provider configuration.

## What changed

- Add `model_providers.gcp.project_id` and `model_providers.gcp.location`, with each taking precedence over its corresponding environment variable. Keep `global` as the default location and preserve explicit `base_url` overrides.
- Validate configured endpoint fields and preserve them through thread configuration serialization.
- Apply built-in GCP defaults, including default command authentication, when checking managed provider requirements so unchanged requirements are accepted.

## Testing

Add coverage for endpoint precedence, invalid explicit configuration, provider construction, thread configuration round trips, and managed GCP requirement checks, including repeated model listing.

GitOrigin-RevId: c3704bcc0b7d4872374e2cae623fd24d75fb02b4
This commit is contained in:
alexsong-oai
2026-10-23 18:50:54 +00:00
committed by copyberry
parent 7848e3393c
commit 970111f6cb
23 changed files with 315 additions and 51 deletions
@@ -50,6 +50,8 @@ message ModelProvider {
bool supports_websockets = 17;
bool supports_standalone_web_search = 18;
optional string model_catalog_url = 19;
optional string project_id = 20;
optional string location = 21;
}
message StringMap {
@@ -79,6 +79,10 @@ pub struct ModelProvider {
pub supports_standalone_web_search: bool,
#[prost(string, optional, tag = "19")]
pub model_catalog_url: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "20")]
pub project_id: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "21")]
pub location: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StringMap {
@@ -196,6 +196,8 @@ fn model_provider_from_proto(
supports_websockets: provider.supports_websockets,
supports_standalone_web_search: provider.supports_standalone_web_search,
capabilities: None,
project_id: provider.project_id,
location: provider.location,
include_internal_metadata: false,
};
Ok((id, info))
@@ -216,6 +218,8 @@ fn model_provider_to_proto(
auth,
gateway_oauth: _,
aws: _,
project_id,
location,
wire_api,
query_params,
http_headers,
@@ -251,6 +255,8 @@ fn model_provider_to_proto(
requires_openai_auth,
supports_websockets,
supports_standalone_web_search,
project_id,
location,
}
}
@@ -446,6 +452,8 @@ mod tests {
#[test]
fn model_provider_proto_roundtrips_through_domain_type() {
let mut expected = expected_provider();
expected.project_id = Some("vertex-project".to_string());
expected.location = Some("us-central1".to_string());
expected.auth = None;
expected.experimental_bearer_token = Some("synthetic-provider-token".into());
let proto = model_provider_to_proto("local", expected.clone());
@@ -520,6 +528,8 @@ mod tests {
requires_openai_auth: false,
supports_websockets: true,
supports_standalone_web_search: true,
project_id: None,
location: None,
}],
features: HashMap::from([
("plugins".to_string(), false),
@@ -585,6 +595,8 @@ mod tests {
gateway_oauth: None,
aws: None,
capabilities: None,
project_id: None,
location: None,
include_internal_metadata: false,
}
}