The health check endpoint provides a simple way to verify that the Concentrate AI API is operational. This endpoint does not require authentication and is useful for monitoring, uptime checks, and service health verification.
import requestsimport timefrom datetime import datetimedef check_api_health(): try: response = requests.get( "https://api.concentrate.ai/v1/responses/health", timeout=5 ) return response.status_code == 200 except: return False# Monitor every 60 secondswhile True: is_healthy = check_api_health() status = "UP" if is_healthy else "DOWN" print(f"[{datetime.now()}] API Status: {status}") if not is_healthy: # Alert or take action send_alert("Concentrate AI API is down!") time.sleep(60)
Verify API availability before making critical requests:
def make_critical_request(payload): # Check if API is healthy first try: health = requests.get( "https://api.concentrate.ai/v1/responses/health", timeout=3 ) if health.status_code != 200: raise Exception("API is not healthy") except Exception as e: return {"error": f"API unavailable: {str(e)}"} # API is healthy, proceed with main request response = requests.post( "https://api.concentrate.ai/v1/responses", headers={"Authorization": "Bearer YOUR_API_KEY"}, json=payload ) return response.json()
Always use short timeouts for health checks to avoid hanging:
# Good: 3-5 second timeoutrequests.get(url, timeout=5)# Bad: No timeout or very long timeoutrequests.get(url) # May hang indefinitelyrequests.get(url, timeout=30) # Too long for health check
Use exponential backoff
Don’t hammer the health endpoint on failures:
async function checkWithBackoff() { const delays = [1000, 2000, 4000, 8000]; // ms for (let i = 0; i < delays.length; i++) { const isHealthy = await checkHealth(); if (isHealthy) return true; await new Promise(resolve => setTimeout(resolve, delays[i])); } return false;}
Monitor from multiple locations
Check from different regions to detect regional outages:
regions = [ "us-east-1", "us-west-2", "eu-west-1", "ap-southeast-1"]results = {}for region in regions: # Run health check from each region results[region] = check_health_from_region(region)# Alert if multiple regions failfailures = sum(1 for v in results.values() if not v)if failures >= 2: send_alert("Multiple regions reporting API down")
# Test DNS resolutionnslookup api.concentrate.ai# Test connectivityping api.concentrate.ai# Test HTTPScurl -v https://api.concentrate.ai/v1/responses/health# Check SSL certificateopenssl s_client -connect api.concentrate.ai:443