diff --git a/src-tauri/src/proxy/providers/transform.rs b/src-tauri/src/proxy/providers/transform.rs index 65fa4784e..3eb6f6565 100644 --- a/src-tauri/src/proxy/providers/transform.rs +++ b/src-tauri/src/proxy/providers/transform.rs @@ -6,6 +6,14 @@ use crate::proxy::error::ProxyError; use serde_json::{json, Value}; +/// Detect OpenAI o-series reasoning models (o1, o3, o4-mini, etc.) +/// These models require `max_completion_tokens` instead of `max_tokens`. +pub fn is_openai_o_series(model: &str) -> bool { + model.len() > 1 + && model.starts_with('o') + && model.as_bytes().get(1).is_some_and(|b| b.is_ascii_digit()) +} + /// Anthropic 请求 → OpenAI 请求 /// /// `cache_key`: optional prompt_cache_key to inject for improved cache routing @@ -50,9 +58,14 @@ pub fn anthropic_to_openai(body: Value, cache_key: Option<&str>) -> Result) -> Result