fix anthropic base url

This commit is contained in:
centdix
2025-08-29 14:02:38 +00:00
parent 901cb716a5
commit 9fd5b9e00d
+7 -1
View File
@@ -156,6 +156,8 @@ impl AIRequestConfig {
let is_azure = matches!(provider, AIProvider::OpenAI) && base_url != OPENAI_BASE_URL
|| matches!(provider, AIProvider::AzureOpenAI);
let is_anthropic = matches!(provider, AIProvider::Anthropic);
let is_anthropic_sdk = headers.get("X-Anthropic-SDK").is_some();
println!("is_anthropic_sdk: {}", is_anthropic_sdk);
let url = if is_azure && method != Method::GET {
if base_url.ends_with("/deployments") {
@@ -167,6 +169,10 @@ impl AIRequestConfig {
} else {
format!("{}/{}", base_url, path)
}
} else if is_anthropic_sdk {
let truncated_base_url = base_url.trim_end_matches("/v1");
println!("truncated_base_url: {}", truncated_base_url);
format!("{}/{}", truncated_base_url, path)
} else {
format!("{}/{}", base_url, path)
};
@@ -304,7 +310,7 @@ impl AIProvider {
AIProvider::Groq => Ok("https://api.groq.com/openai/v1".to_string()),
AIProvider::OpenRouter => Ok("https://openrouter.ai/api/v1".to_string()),
AIProvider::TogetherAI => Ok("https://api.together.xyz/v1".to_string()),
AIProvider::Anthropic => Ok("https://api.anthropic.com".to_string()),
AIProvider::Anthropic => Ok("https://api.anthropic.com/v1".to_string()),
AIProvider::Mistral => Ok("https://api.mistral.ai/v1".to_string()),
p @ (AIProvider::CustomAI | AIProvider::AzureOpenAI) => {
if let Some(base_url) = resource_base_url {