From 02c3a572c452e97f63bcf3bbc2e3dcce228712dc Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Thu, 8 Jan 2026 16:41:47 -0800 Subject: [PATCH] don't include internal models in /v1/models endpoint --- cli/planoai/config_generator.py | 3 +++ crates/common/src/configuration.rs | 42 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/cli/planoai/config_generator.py b/cli/planoai/config_generator.py index e82febb4..3b920181 100644 --- a/cli/planoai/config_generator.py +++ b/cli/planoai/config_generator.py @@ -310,6 +310,7 @@ def validate_and_render_schema(): "name": "arch-router", "provider_interface": "arch", "model": config_yaml.get("routing", {}).get("model", "Arch-Router"), + "internal": True, } ) @@ -320,6 +321,7 @@ def validate_and_render_schema(): "name": "arch-function", "provider_interface": "arch", "model": "Arch-Function", + "internal": True, } ) @@ -329,6 +331,7 @@ def validate_and_render_schema(): "name": "plano-orchestrator", "provider_interface": "arch", "model": "Plano-Orchestrator", + "internal": True, } ) diff --git a/crates/common/src/configuration.rs b/crates/common/src/configuration.rs index 07d3311b..58ea1e3e 100644 --- a/crates/common/src/configuration.rs +++ b/crates/common/src/configuration.rs @@ -323,6 +323,7 @@ pub struct LlmProvider { pub routing_preferences: Option>, pub cluster_name: Option, pub base_url_path_prefix: Option, + pub internal: Option, } pub trait IntoModels { @@ -333,6 +334,7 @@ impl IntoModels for Vec { fn into_models(self) -> Models { let data = self .iter() + .filter(|provider| provider.internal != Some(true)) .map(|provider| ModelDetail { id: provider.name.clone(), object: Some("model".to_string()), @@ -364,6 +366,7 @@ impl Default for LlmProvider { routing_preferences: None, cluster_name: None, base_url_path_prefix: None, + internal: None, } } } @@ -479,6 +482,7 @@ mod test { use pretty_assertions::assert_eq; use std::fs; + use super::{IntoModels, LlmProvider, LlmProviderType}; use crate::api::open_ai::ToolType; #[test] @@ -561,4 +565,42 @@ mod test { } } } + + #[test] + fn test_into_models_filters_internal_providers() { + let providers = vec![ + LlmProvider { + name: "openai-gpt4".to_string(), + provider_interface: LlmProviderType::OpenAI, + model: Some("gpt-4".to_string()), + internal: None, + ..Default::default() + }, + LlmProvider { + name: "arch-router".to_string(), + provider_interface: LlmProviderType::Arch, + model: Some("Arch-Router".to_string()), + internal: Some(true), + ..Default::default() + }, + LlmProvider { + name: "plano-orchestrator".to_string(), + provider_interface: LlmProviderType::Arch, + model: Some("Plano-Orchestrator".to_string()), + internal: Some(true), + ..Default::default() + }, + ]; + + let models = providers.into_models(); + + // Should only have 1 model: openai-gpt4 + assert_eq!(models.data.len(), 1); + + // Verify internal models are excluded from /v1/models + let model_ids: Vec = models.data.iter().map(|m| m.id.clone()).collect(); + assert!(model_ids.contains(&"openai-gpt4".to_string())); + assert!(!model_ids.contains(&"arch-router".to_string())); + assert!(!model_ids.contains(&"plano-orchestrator".to_string())); + } }