← Back to articles
Free API Overview

Free Anomaly Detection API Complete Tutorial: Zero-Cost Outlier Detection in Your Data (2026-10-22 Verified)

Free Anomaly Detection API Complete Tutorial: Zero-Cost Outlier Detection in Your Data (2026-10-22 Verified)

Looking for more zero-cost developer resources? Browse our complete free API directory and create a free account to bookmark tutorials, track API quotas, and receive update notifications when vendors change their free tiers.

Anomaly detection (also called outlier detection) is the process of automatically identifying data points that deviate significantly from normal patterns. Unlike standard classification, anomaly detection faces the challenge of extreme class imbalance — anomalous samples may represent less than 1% of total data. This tutorial covers five verified free anomaly detection solutions, from statistical methods to deep learning, with feature tables, Python code, and a decision tree to help you choose the right one. All quotas below were re-verified on 2026-10-22.


Quick Comparison Radar Chart

The chart below scores each solution on six dimensions (1–10 scale) so you can visualize trade-offs at a glance.


1. Hugging Face Inference API

Hugging Face hosts several anomaly detection models including Anomaly Transformer and PatchTST. The free Inference API tier lets you call these models without self-hosting.

Feature Value
Free quota ~1,000 requests/day (soft cap)
Models Anomaly Transformer, PatchTST, custom models
Data types Time series, tabular, text
Response time Medium (queue-based, cold start may be slow)
Commercial use Depends on model license

Step-by-Step

  1. Create a Hugging Face account and generate an access token.
  2. Search Model Hub for anomaly detection models.
  3. POST data as JSON to the inference endpoint.
  4. Parse the returned anomaly scores and labels.

Python Example

import requests
import json

API_URL = "https://api-inference.huggingface.co/models/AnomalyTransformer/Anomaly-Transformer"
HF_TOKEN = "your-huggingface-token"
headers = {"Authorization": f"Bearer {HF_TOKEN}"}

payload = {"inputs": {"data": [45, 43, 44, 95, 43, 98, 44], "threshold": 0.5}}
resp = requests.post(API_URL, headers=headers, json=payload)
print(json.dumps(resp.json(), indent=2))
  • Quick prototyping for time-series anomaly detection
  • Academic research on Transformer-based detection
  • Teams without GPU infrastructure

2. AWS Lookout for Metrics (500 metrics/month free)

AWS Lookout for Metrics is a managed time-series anomaly detection service that automatically analyzes business metrics and identifies anomalies with root-cause analysis.

Feature Value
Free quota 500 metrics/month free
Models AWS internal AutoML
Data types Time series (business and ops metrics)
Special features Automatic root-cause analysis, anomaly grouping, real-time alerts
Response time Near real-time (5–15 min latency)
Commercial use AWS ToS applies

Step-by-Step

  1. Create an AWS account and navigate to Lookout for Metrics.
  2. Create an anomaly detector, selecting your data source (CloudWatch, S3, etc.).
  3. Map data fields to metric dimensions.
  4. The service runs automatically; anomalies are pushed via SNS or email.

Python Example (boto3)

import boto3, time

client = boto3.client("lookoutmetrics", region_name="us-east-1")

# Create detector
resp = client.create_anomaly_detector(
    AnomalyDetectorName="cpu-anomaly-detector",
    AnomalyDetectorConfig={"AnomalyDetectorFrequency": "PT5M"}
)
detector_arn = resp["Arn"]
print(f"Detector ARN: {detector_arn}")

# Wait for activation
while True:
    desc = client.describe_anomaly_detector(AnomalyDetectorName="cpu-anomaly-detector")
    if desc["Status"] == "ACTIVE":
        print("Detector is active!")
        break
    time.sleep(10)

# Get anomaly results
results = client.get_anomaly_group_results(
    AnomalyDetectorName="cpu-anomaly-detector",
    SensitivityThreshold=50
)
for group in results.get("AnomalyGroupScores", []):
    print(f"Anomaly score: {group.get('Score', 'N/A')}")
  • DevOps teams already on AWS
  • Business metrics monitoring with root-cause analysis
  • Enterprise-grade anomaly detection without ML expertise

3. Azure Metrics Advisor (25,000 data points/month free)

Azure Metrics Advisor is a multi-dimensional time-series anomaly detection service from Microsoft. It supports automatic feature extraction, root-cause analysis, and intelligent alerting.

Feature Value
Free quota 25,000 data points/month free
Models Azure internal ML models
Data types Multi-dimensional time series
Special features Auto feature extraction, multi-dimensional root-cause analysis, smart alerts
Response time Near real-time
Commercial use Azure ToS applies

Step-by-Step

  1. Create a Metrics Advisor resource in Azure Portal.
  2. Obtain Subscription Key and Endpoint from the resource page.
  3. Create a data feed from CSV, SQL, or Blob Storage.
  4. Configure detection parameters (sensitivity, detection window).
  5. Query detection results via REST API.

Python Example

import requests, json

SUB_KEY = "your-azure-subscription-key"
ENDPOINT = "https://your-metrics-advisor.cognitiveservices.azure.com/"
headers = {"Ocp-Apim-Subscription-Key": SUB_KEY, "Content-Type": "application/json"}

# Create data feed
feed_config = {
    "dataFeed": {
        "dataSourceType": "AzureBlob",
        "dataSourceParameter": {"connectionString": "your-conn-string", "container": "metrics"},
        "granularity": {"granularityType": "Daily"},
        "metrics": [{"name": "cpu_usage", "displayName": "CPU Usage"}],
        "dimension": [{"name": "server", "displayName": "Server"}]
    }
}
resp = requests.post(f"{ENDPOINT}metricsadvisor/v1.0/dataFeeds", headers=headers, json=feed_config)
feed_id = resp.json().get("dataFeedId")
print(f"Data feed ID: {feed_id}")

# Query anomaly results
detection = {
    "name": "cpu-anomaly-config",
    "metricId": "metric-id-from-feed",
    "detectionConfiguration": {"sensitivity": 75, "anomalyDetectionDirection": "Both"}
}
resp2 = requests.post(f"{ENDPOINT}metricsadvisor/v1.0/enrichment/anomalyDetection/configurations",
                      headers=headers, json=detection)
print(json.dumps(resp2.json(), indent=2))
  • Enterprise teams already on Azure
  • Multi-dimensional root-cause analysis for business metrics
  • Smart alerting with incident management

4. Python PyOD Library (50+ Algorithms, Fully Free)

PyOD (Python Outlier Detection) is the most comprehensive open-source anomaly detection library in the Python ecosystem, with 50+ algorithms ranging from classic Z-Score and IQR to deep learning approaches like AutoEncoder and GAN.

Feature Value
Free quota Unlimited (your compute)
Algorithms 50+ (IForest, LOF, OCSVM, AutoEncoder, VAE, GAN, etc.)
Data types Tabular, time series, high-dimensional
Special features Unified API, model combination (average/max), save/load
Response time Fast (local CPU)
Commercial use BSD-2-Clause

Step-by-Step

  1. Install: pip install pyod.
  2. Prepare data as NumPy arrays or Pandas DataFrames.
  3. Choose an algorithm: IForest(), LOF(), etc.
  4. Train: model.fit(X_train).
  5. Predict: model.predict(X_test) returns 0 (normal) or 1 (anomaly).
  6. Get scores: model.decision_scores_ provides continuous anomaly scores.

Python Example

import numpy as np
from pyod.models.iforest import IForest
from pyod.models.lof import LOF
from pyod.models.combination import average

# Generate mock data
np.random.seed(42)
X_train = np.random.randn(1000, 5)
X_test = np.vstack([np.random.randn(950, 5),
                    np.random.uniform(low=10, high=20, size=(50, 5))])

# IForest detection
clf_if = IForest(contamination=0.05, random_state=42)
clf_if.fit(X_train)
y_pred_if = clf_if.predict(X_test)

# LOF detection
clf_lof = LOF(contamination=0.05)
clf_lof.fit(X_train)
y_pred_lof = clf_lof.predict(X_test)

# Combine detectors (average method)
combined = average(clf_if.decision_scores_, clf_lof.decision_scores_)
combined_pred = (combined > np.percentile(combined, 95)).astype(int)

print(f"IForest detected {y_pred_if.sum()} anomalies")
print(f"LOF detected {y_pred_lof.sum()} anomalies")
print(f"Combined detected {combined_pred.sum()} anomalies")
  • Researchers needing flexible algorithm selection
  • Offline detection systems on local or edge devices
  • Tabular data anomaly detection with 50+ algorithm options

5. Python Alibi Detect Library (Deep Learning + Drift Detection)

Alibi Detect is an open-source library from Seldon focused on deep learning anomaly detection and data drift monitoring. It supports TensorFlow and PyTorch backends and includes data drift, concept drift, and adversarial detection capabilities.

Feature Value
Free quota Unlimited (your compute)
Algorithms Isolation Forest, Mahalanobis, AutoEncoder, VAE, Prophet, SR, etc.
Data types Time series, tabular, images, text
Special features Data drift detection, concept drift, adversarial detection
Response time Depends on backend and hardware
Commercial use Apache-2.0

Step-by-Step

  1. Install: pip install alibi-detect.
  2. Prepare data as NumPy arrays.
  3. Choose a detector: OutlierVAE, IsolationForest, or Prophet.
  4. Train: detector.fit(X).
  5. Predict: detector.predict(X) returns anomaly flags and scores.

Python Example

import numpy as np
from alibi_detect.od import OutlierVAE

# Generate mock data
np.random.seed(42)
X_train = np.random.randn(2000, 10).astype("float32")
X_test = np.vstack([
    np.random.randn(900, 10).astype("float32"),
    np.random.uniform(low=5, high=15, size=(100, 10)).astype("float32")
])

# Initialize VAE anomaly detector
od = OutlierVAE(threshold=2.0, latent_dim=5, samples=10, input_shape=(10,))

# Train
od.fit(X_train, epochs=10, batch_size=32, verbose=True)

# Predict
preds = od.predict(X_test)
anomaly_flags = preds["data"]["is_outlier"]
anomaly_scores = preds["data"]["instance_score"]

print(f"Detected {anomaly_flags.sum()} anomalies")
print(f"Top 10 scores: {anomaly_scores[:10]}")
  • Deep learning anomaly detection on images or text
  • MLOps data drift monitoring in production pipelines
  • Adversarial sample detection for model security

Decision Tree: Which Anomaly Detection Should You Pick?

flowchart TD A[Need anomaly detection?] --> B{Prefer managed cloud service?} B -- Yes --> C{Which cloud platform?} C -- AWS --> D[Option 2: AWS Lookout] C -- Azure --> E[Option 3: Azure Metrics Advisor] C -- Other --> F[Option 1: Hugging Face] B -- No --> G{Need deep learning support?} G -- Yes --> H[Option 5: Alibi Detect] G -- No --> I[Option 4: PyOD] F -- Small data --> J[Option 1: Hugging Face] F -- Large data --> K{Willing to self-host?} K -- Yes --> I K -- No --> D

Decision Tree Steps:

  1. Deployment preference — If you want managed cloud, go to Options 1–3. If you prefer self-hosting, go to Options 4–5.
  2. Cloud platform — Already on AWS? Choose Option 2. Already on Azure? Choose Option 3. Otherwise, Hugging Face.
  3. Deep learning needs — If you need VAE, AutoEncoder, or drift detection, choose Alibi Detect (Option 5).
  4. Algorithm flexibility — For 50+ algorithm options on tabular data, PyOD (Option 4) is the best choice.

Evaluation Metrics for Anomaly Detection

Anomaly detection evaluation differs from standard classification. Here are the key metrics:

Metric Meaning Best For
Precision Fraction of true anomalies among predicted anomalies High alert cost (false positive is costly)
Recall Fraction of true anomalies detected High miss cost (e.g., fraud detection)
F1-Score Harmonic mean of Precision and Recall Balanced evaluation
ROC-AUC Area under ROC curve across thresholds Model comparison
PR-AUC Area under Precision-Recall curve Extreme class imbalance
Detection Latency Time from anomaly occurrence to alert Real-time monitoring

Best Practices

  • In extreme imbalance scenarios, prioritize PR-AUC over ROC-AUC.
  • In ops monitoring, prioritize Recall (no missed anomalies) and detection latency.
  • In fraud detection, balance Precision and Recall, optimizing for F1-Score.

Conclusion

Anomaly detection is an indispensable capability for data-driven businesses. From Hugging Face's hosted model inference, to PyOD's 50+ algorithm library, to Alibi Detect's deep learning and drift detection support, there is a zero-cost solution for every use case. The key is understanding your data characteristics, choosing the right algorithm, and establishing a scientific evaluation framework.

For a continuously updated list of free APIs across NLP, vision, voice, and beyond, bookmark our free API directory. And if you'd like to save your favorite endpoints and receive quota-change alerts, register a free apishare.cc account today.

More in this category

Free Entity Linking API Complete Tutorial: Link Entities to Knowledge Base at Zero Cost (2026-11-13 Verified)Free Text Summarization API Complete Tutorial: Condense Long Documents into Concise Summaries at Zero Cost (2026-11-11 Verified)Free Part-of-Speech (POS) Tagging API Complete Tutorial: Zero-Cost AI-Powered Grammar Category Labeling (Verified 2026-11-10)Free Named Entity Recognition (NER) API Complete Tutorial: Zero-Cost AI-Powered Person, Location & Organization Extraction (Verified 2026-11-09)Free Keyphrase Extraction API Complete Tutorial: Zero-Cost AI-Powered Article Keyword Discovery (Verified 2026-11-08)

Ready to use free LLM APIs?

APIShare aggregates free AI APIs worldwide — sign up and get bonus credits.