Add Rig native model providers

This commit is contained in:
2026-08-06 15:03:00 -05:00
parent 634ce7ba00
commit 3fda5d414b
34 changed files with 2134 additions and 452 deletions
+17
View File
@@ -926,6 +926,13 @@ pub enum OpenAIProviderKind {
OpenAICompatible,
/// The ChatGPT subscription backend, authenticated with ChatGPT OAuth.
ChatGPTSubscription,
/// Anthropic's native Messages API.
Anthropic,
/// Google's Gemini API.
Gemini,
/// Google's Gemini models hosted through Vertex AI.
#[serde(rename = "vertex_ai", alias = "vertex_a_i")]
VertexAI,
}
/// Configuration for a single OpenAI-compatible provider endpoint.
@@ -951,6 +958,12 @@ pub struct OpenAIProviderConfig {
#[schemars(description = "API key for this endpoint (optional if the proxy handles auth).")]
pub api_key: Option<String>,
#[serde(default)]
#[schemars(description = "Google Cloud project ID for Vertex AI providers.")]
pub project_id: Option<String>,
#[serde(default)]
#[schemars(description = "Google Cloud location for Vertex AI providers.")]
pub location: Option<String>,
#[serde(default)]
#[schemars(description = "Models available from this provider.")]
pub models: Vec<OpenAIModelConfig>,
}
@@ -1021,6 +1034,8 @@ pub(crate) fn default_chatgpt_provider() -> OpenAIProviderConfig {
name: "ChatGPT Subscription".to_string(),
base_url: String::new(),
api_key: None,
project_id: None,
location: None,
models: default_chatgpt_models(),
}
}
@@ -1035,6 +1050,8 @@ fn default_openai_providers() -> Vec<OpenAIProviderConfig> {
// Credentials are deliberately never committed. Set this locally in
// ~/.galaxy/settings.toml before sending a request.
api_key: None,
project_id: None,
location: None,
models: vec![OpenAIModelConfig {
model_id: INITIAL_RIG_MODEL_ID.to_string(),
display_name: "Codex GPT-5.6 SOL (xhigh)".to_string(),
+28
View File
@@ -423,6 +423,34 @@ fn initial_litellm_provider_maps_codex_model_to_rig_without_a_committed_key() {
assert!(instant.reasoning_efforts.is_empty());
}
#[test]
fn native_provider_settings_roundtrip_with_vertex_configuration() {
let provider: OpenAIProviderConfig = serde_json::from_value(serde_json::json!({
"kind": "vertex_ai",
"enabled": true,
"name": "Vertex production",
"base_url": "",
"project_id": "galaxy-project",
"location": "us-central1",
"models": []
}))
.expect("Vertex provider settings should deserialize");
assert_eq!(provider.kind, OpenAIProviderKind::VertexAI);
assert_eq!(provider.project_id.as_deref(), Some("galaxy-project"));
assert_eq!(provider.location.as_deref(), Some("us-central1"));
let legacy: OpenAIProviderConfig = serde_json::from_value(serde_json::json!({
"name": "Legacy provider",
"base_url": "http://localhost:4000/v1",
"models": []
}))
.expect("Legacy provider settings should remain compatible");
assert_eq!(legacy.kind, OpenAIProviderKind::OpenAICompatible);
assert_eq!(legacy.project_id, None);
assert_eq!(legacy.location, None);
}
#[test]
fn codex_litellm_model_infers_missing_system_message_capability() {
let mut model = default_openai_providers().remove(0).models.remove(0);