diff --git a/src-tauri/src/provider.rs b/src-tauri/src/provider.rs index 67616853c..4170dd3f9 100644 --- a/src-tauri/src/provider.rs +++ b/src-tauri/src/provider.rs @@ -282,9 +282,9 @@ pub struct ProviderMeta { /// 是否将 base_url 视为完整 API 端点(不拼接 endpoint 路径) #[serde(rename = "isFullUrl", skip_serializing_if = "Option::is_none")] pub is_full_url: Option, - /// Prompt cache key for OpenAI-compatible endpoints. - /// When set, injected into converted requests to improve cache hit rate. - /// If not set, provider ID is used automatically during format conversion. + /// Prompt cache key for OpenAI Responses-compatible endpoints. + /// When set, injected into converted Responses requests to improve cache hit rate. + /// If not set, provider ID is used automatically during Claude -> Responses conversion. #[serde(rename = "promptCacheKey", skip_serializing_if = "Option::is_none")] pub prompt_cache_key: Option, /// 累加模式应用中,该 provider 是否已写入 live config。 diff --git a/src-tauri/src/proxy/providers/claude.rs b/src-tauri/src/proxy/providers/claude.rs index 52689d3b5..aa9949995 100644 --- a/src-tauri/src/proxy/providers/claude.rs +++ b/src-tauri/src/proxy/providers/claude.rs @@ -81,14 +81,13 @@ pub fn transform_claude_request_for_api_format( provider: &Provider, api_format: &str, ) -> Result { - let cache_key = provider - .meta - .as_ref() - .and_then(|m| m.prompt_cache_key.as_deref()) - .unwrap_or(&provider.id); - match api_format { "openai_responses" => { + let cache_key = provider + .meta + .as_ref() + .and_then(|m| m.prompt_cache_key.as_deref()) + .unwrap_or(&provider.id); // Codex OAuth (ChatGPT Plus/Pro 反代) 需要在请求体里强制 store: false // + include: ["reasoning.encrypted_content"],由 transform 层统一处理。 let is_codex_oauth = provider @@ -102,7 +101,7 @@ pub fn transform_claude_request_for_api_format( is_codex_oauth, ) } - "openai_chat" => super::transform::anthropic_to_openai(body, Some(cache_key)), + "openai_chat" => super::transform::anthropic_to_openai(body), _ => Ok(body), } } diff --git a/src-tauri/src/proxy/providers/transform.rs b/src-tauri/src/proxy/providers/transform.rs index 7380fb860..a41d18501 100644 --- a/src-tauri/src/proxy/providers/transform.rs +++ b/src-tauri/src/proxy/providers/transform.rs @@ -71,10 +71,8 @@ pub fn resolve_reasoning_effort(body: &Value) -> Option<&'static str> { } } -/// Anthropic 请求 → OpenAI 请求 -/// -/// `cache_key`: optional prompt_cache_key to inject for improved cache routing -pub fn anthropic_to_openai(body: Value, cache_key: Option<&str>) -> Result { +/// Anthropic 请求 → OpenAI Chat Completions 请求 +pub fn anthropic_to_openai(body: Value) -> Result { let mut result = json!({}); // NOTE: 模型映射由上游统一处理(proxy::model_mapper),格式转换层只做结构转换。 @@ -175,11 +173,6 @@ pub fn anthropic_to_openai(body: Value, cache_key: Option<&str>) -> Result