mermaid_cli/proxy/
health.rs

1/// Check if LiteLLM proxy is running
2pub async fn is_proxy_running() -> bool {
3    let proxy_url =
4        std::env::var("LITELLM_PROXY_URL").unwrap_or_else(|_| "http://localhost:4000".to_string());
5
6    let client = reqwest::Client::builder()
7        .timeout(std::time::Duration::from_millis(200))  // Much faster timeout
8        .build();
9
10    if let Ok(client) = client {
11        // Try models endpoint with master key (faster than health endpoint)
12        let master_key =
13            std::env::var("LITELLM_MASTER_KEY").unwrap_or_else(|_| "sk-mermaid-1234".to_string());
14
15        if let Ok(resp) = client
16            .get(&format!("{}/models", proxy_url))
17            .header("Authorization", format!("Bearer {}", master_key))
18            .send()
19            .await
20        {
21            return resp.status().is_success();
22        }
23    }
24
25    false
26}