OP

openrouter-model-availability

Implement health checks and model status monitoring for OpenRouter integrations to ensure system reliability.

Install

mkdir -p .claude/skills/openrouter-model-availability && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/8568" && unzip -o skill.zip -d .claude/skills/openrouter-model-availability && rm skill.zip

Installs to .claude/skills/openrouter-model-availability

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Monitor OpenRouter model availability and implement health checks. Use
70 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Query model catalog status
  • Probe live model health
  • Implement automated failover logic
  • Monitor latency and availability
  • Suggest model replacements

How it works

The skill uses the OpenRouter models endpoint to verify existence and sends minimal token requests to probe live health. It provides scripts to log availability and trigger alerts based on consecutive failures.

Inputs & outputs

You give it
List of critical model IDs
You get back
Health status report with latency and availability metrics

When to use openrouter-model-availability

  • Building resilient AI model fallbacks
  • Probing model health before API requests
  • Monitoring status of specific models
  • Implementing cost-effective availability checks

About this skill

OpenRouter Model Availability

Overview

OpenRouter's /api/v1/models endpoint is the source of truth for model availability. Models can be temporarily unavailable, have degraded performance, or be permanently removed. This skill covers querying model status, building health probes, tracking availability over time, and automating failover.

Prerequisites

  • An OpenRouter API key exported as OPENROUTER_API_KEY for live probes (the catalog query itself needs no auth) — see the openrouter-install-auth skill for setup
  • curl and jq for the catalog status queries and the cron monitoring script
  • Python 3.8+ with the OpenAI SDK and requests (pip install openai requests) for the health-check service
  • A small credit balance — each max_tokens: 1 probe costs roughly $0.0001

Instructions

  1. Confirm your models exist in the catalog with curl -s https://openrouter.ai/api/v1/models | jq ... per Query Model Status — pull context_length and per-million pricing without spending any tokens.
  2. For a zero-cost existence check inside code, use check_model_exists() from Catalog-Based Availability Check; on a miss it calls find_similar() to suggest same-provider replacements.
  3. Probe live health with probe_model() from Health Check Service — a max_tokens: 1 request that returns a HealthStatus with available, latency_ms, and checked_at.
  4. Sweep your critical set with check_critical_models(), which logs OK/FAIL plus latency per model.
  5. Automate via the Availability Monitoring Script as a */5 * * * * cron job appending timestamped status lines to /var/log/openrouter-health.log.
  6. Tune alerting per Error Handling — require 2-3 consecutive failures before marking a model down to avoid false positives.

Query Model Status

# Check if specific models exist and their status
curl -s https://openrouter.ai/api/v1/models | jq '[.data[] | select(
  .id == "anthropic/claude-3.5-sonnet" or
  .id == "openai/gpt-4o" or
  .id == "openai/gpt-4o-mini"
) | {
  id,
  context_length,
  prompt_per_M: ((.pricing.prompt | tonumber) * 1000000),
  completion_per_M: ((.pricing.completion | tonumber) * 1000000)
}]'

# List all available models (just IDs)
curl -s https://openrouter.ai/api/v1/models | jq '[.data[].id] | sort'

# Count models by provider
curl -s https://openrouter.ai/api/v1/models | jq '[.data[].id | split("/")[0]] | group_by(.) | map({provider: .[0], count: length}) | sort_by(-.count)'

Health Check Service

import os, time, logging
from datetime import datetime, timezone
from dataclasses import dataclass
import requests
from openai import OpenAI, APIError, APITimeoutError

log = logging.getLogger("openrouter.health")

@dataclass
class HealthStatus:
    model: str
    available: bool
    latency_ms: float
    checked_at: str
    error: str = ""

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key=os.environ["OPENROUTER_API_KEY"],
    timeout=15.0,
    default_headers={"HTTP-Referer": "https://my-app.com", "X-Title": "health-check"},
)

def probe_model(model_id: str) -> HealthStatus:
    """Send a minimal request to test model availability."""
    start = time.monotonic()
    try:
        response = client.chat.completions.create(
            model=model_id,
            messages=[{"role": "user", "content": "hi"}],
            max_tokens=1,  # Minimal cost
        )
        latency = (time.monotonic() - start) * 1000
        return HealthStatus(
            model=model_id, available=True, latency_ms=round(latency, 1),
            checked_at=datetime.now(timezone.utc).isoformat(),
        )
    except (APIError, APITimeoutError) as e:
        latency = (time.monotonic() - start) * 1000
        return HealthStatus(
            model=model_id, available=False, latency_ms=round(latency, 1),
            checked_at=datetime.now(timezone.utc).isoformat(),
            error=str(e),
        )

def check_critical_models() -> list[HealthStatus]:
    """Probe all critical models."""
    CRITICAL_MODELS = [
        "anthropic/claude-3.5-sonnet",
        "openai/gpt-4o",
        "openai/gpt-4o-mini",
        "google/gemini-2.0-flash-001",
    ]
    results = []
    for model in CRITICAL_MODELS:
        status = probe_model(model)
        log.info(f"{'OK' if status.available else 'FAIL'} {model} ({status.latency_ms}ms)")
        results.append(status)
    return results

Catalog-Based Availability Check

def check_model_exists(model_id: str) -> dict:
    """Check if a model exists in the catalog (no API call cost)."""
    resp = requests.get("https://openrouter.ai/api/v1/models")
    models = {m["id"]: m for m in resp.json()["data"]}

    if model_id in models:
        m = models[model_id]
        return {
            "exists": True,
            "context_length": m["context_length"],
            "pricing": m["pricing"],
        }
    return {"exists": False, "suggestion": find_similar(model_id, models)}

def find_similar(model_id: str, models: dict) -> list[str]:
    """Find models with similar names (for migration when model is removed)."""
    prefix = model_id.split("/")[0]
    return [m for m in models if m.startswith(prefix)][:5]

Availability Monitoring Script

#!/bin/bash
# Run as cron job: */5 * * * * /path/to/check_models.sh

MODELS=("anthropic/claude-3.5-sonnet" "openai/gpt-4o" "openai/gpt-4o-mini")
LOG_FILE="/var/log/openrouter-health.log"

for MODEL in "${MODELS[@]}"; do
  START=$(date +%s%N)
  HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
    https://openrouter.ai/api/v1/chat/completions \
    -H "Authorization: Bearer $OPENROUTER_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"model\":\"$MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}],\"max_tokens\":1}" \
    --max-time 15)
  END=$(date +%s%N)
  LATENCY=$(( (END - START) / 1000000 ))

  STATUS="OK"
  [ "$HTTP_CODE" != "200" ] && STATUS="FAIL"

  echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) $STATUS $MODEL $HTTP_CODE ${LATENCY}ms" >> "$LOG_FILE"
done

Output

  • HealthStatus records per probed model: available, latency_ms, an ISO-8601 checked_at timestamp, and the error string when a model is down
  • Catalog check dicts: {"exists": True, "context_length": ..., "pricing": ...} on a hit, or {"exists": False, "suggestion": [...]} listing similar model IDs on a miss
  • Append-only log lines from the cron script, e.g. 2026-07-02T14:05:01Z OK anthropic/claude-3.5-sonnet 200 842ms, one per critical model every 5 minutes

Examples

Check that a critical model is still in the catalog before spending tokens on a probe:

curl -s https://openrouter.ai/api/v1/models | jq '[.data[] | select(
  .id == "anthropic/claude-3.5-sonnet") | {id, context_length}]'
# [{"id": "anthropic/claude-3.5-sonnet", "context_length": 200000}]

Then run the Python health sweep — run_health_checks() in references/examples.md prints [OK] anthropic/claude-3.5-sonnet: 842.3ms per model, a 3/3 models healthy summary, and the mapped fallback (e.g. openai/gpt-4-turbo) for any failure. More worked examples: references/examples.md.

Error Handling

ErrorCauseFix
Model not in catalogModel renamed or removedUse find_similar() to find replacement
Health check timeout (>15s)Model overloaded or cold-startingDistinguish slow vs down; increase timeout for probes
False positive downTransient network issueRequire 2-3 consecutive failures before alerting
402 on health checkCredits exhaustedHealth checks cost ~$0.0001 each; ensure adequate credits

Enterprise Considerations

  • Health probes cost tokens ($0.0001 or less per probe with max_tokens: 1) -- budget for monitoring
  • Require 2-3 consecutive failures before marking a model as down to avoid false positives
  • Cache the models list and refresh every 5 minutes -- don't hit /api/v1/models on every request
  • Subscribe to OpenRouter announcements for model deprecations and new additions
  • Maintain a model alias map so your code uses logical names (e.g., "primary-chat") that you can remap
  • Alert when critical models disappear from the catalog, not just when they fail probes

References

When not to use it

  • When ignoring credit costs for health probes
  • When failing to account for transient network issues

Prerequisites

OpenRouter API keycurljqPython 3.8+

Limitations

  • Health probes consume credits
  • Requires 2-3 failures to confirm downtime

How it compares

It provides a programmatic way to check model health before execution, preventing runtime errors compared to reactive error handling.

Compared to similar skills

openrouter-model-availability side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
openrouter-model-availability (this skill)027dCautionIntermediate
analyzing-logs1427dReviewBeginner
obsidian-observability527dReviewIntermediate
instruments-profiling32moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

Search skills

Search the agent skills registry