/openrouter

LLM Operations L2+ Production low usage

/openrouter

Overview

/openrouter is a production command in the LLM Operations category of the Prismatic Platform. It manages OpenRouter LLM provider operations, providing a unified interface to access hundreds of large language models from multiple providers through OpenRouter's aggregation API, with intelligent model selection, cost optimization, and quality monitoring.

OpenRouter serves as a meta-provider in the Prismatic LLM infrastructure, offering access to models from OpenAI, Anthropic, Google, Meta, Mistral, and dozens of other providers through a single API endpoint. The /openrouter command manages this integration, handling model discovery, routing configuration, usage tracking, and cost optimization. It enables the platform to dynamically select the optimal model for each task based on quality requirements, latency constraints, and budget parameters.

The command plays a critical role in the platform's multi-provider LLM strategy. While Claude serves as the primary AI engine and Ollama provides local model capabilities, OpenRouter fills the gap for specialized models, experimental providers, and cost-sensitive bulk operations. The routing intelligence ensures that each request reaches the most appropriate model without manual provider management.

This command operates under the L2+ authority level and is executed by the openrouter-llm-specialist agent. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. Its low usage frequency reflects its management-oriented nature -- configuration happens infrequently while the configured routing operates continuously.

Architecture

The /openrouter command interfaces with the OpenRouter API through a provider abstraction layer that integrates with the platform's multi-provider LLM routing system.

Provider Architecture

/openrouter Command --> OpenRouter Provider Manager
                              |
              +---------------+---------------+
              |               |               |
        Model Registry   Cost Tracker    Quality Monitor
              |               |               |
        +-----+-----+   +----+----+     +----+----+
        |     |     |   |    |    |     |    |    |
      Disc  Select Route Usage Budget  Score Bench Compare
      overy tion   Config Track Alerts  card  mark  Models
              |               |               |
              +---------------+---------------+
                              |
                    OpenRouter API (openrouter.ai/api)

Core Components

ComponentModuleResponsibility
Provider ManagerPrismaticLLM.OpenRouter.ManagerLifecycle management and configuration
Model RegistryPrismaticLLM.OpenRouter.ModelRegistryAvailable model catalog with capabilities
Cost TrackerPrismaticLLM.OpenRouter.CostTrackerUsage metering and budget management
Quality MonitorPrismaticLLM.OpenRouter.QualityMonitorOutput quality assessment and tracking
RouterPrismaticLLM.OpenRouter.RouterIntelligent model selection and routing
Rate LimiterPrismaticLLM.OpenRouter.RateLimiterRequest rate management per model

Usage

Service Management

# Check OpenRouter connection status and API health
/openrouter status

# View account information and credits
/openrouter account

# Test API connectivity
/openrouter test-connection

Model Operations

# List available models
/openrouter models

# List models filtered by provider
/openrouter models --provider anthropic

# List models filtered by capability
/openrouter models --capability code-generation --max-cost 0.01

# Get detailed model information
/openrouter info anthropic/claude-3.5-sonnet

# Compare models on specific benchmark
/openrouter compare meta-llama/llama-3.1-70b openai/gpt-4o --benchmark code-quality

Routing Configuration

# Set default routing rules
/openrouter route --task code-generation --model anthropic/claude-3.5-sonnet
/openrouter route --task summarization --model meta-llama/llama-3.1-70b
/openrouter route --task translation --model openai/gpt-4o-mini

# Configure cost-optimized routing
/openrouter route --mode cost-optimized --max-cost-per-1k 0.005

# Configure quality-first routing
/openrouter route --mode quality-first --min-quality 0.9

# View routing table
/openrouter routes

# Remove a routing rule
/openrouter route --remove --task summarization

Cost Management

# View current usage and costs
/openrouter usage

# View usage by model
/openrouter usage --by model --period monthly

# Set budget alerts
/openrouter budget --monthly-limit 50.00 --alert-threshold 0.8

# Export usage report
/openrouter usage --export csv --file openrouter-usage.csv

Options & Parameters

ParameterTypeDefaultDescription
statusSubcommand-Check API status and connectivity
modelsSubcommand-List available models
infoSubcommand-Get detailed model information
compareSubcommand-Compare models on benchmarks
routeSubcommand-Configure routing rules
routesSubcommand-Display routing table
usageSubcommand-View usage statistics and costs
budgetSubcommand-Configure budget limits and alerts
accountSubcommand-View account information
--providerStringAllFilter by model provider
--capabilityStringAllFilter by model capability
--max-costFloat-Maximum cost per 1K tokens
--taskString-Task type for routing rules
--modelString-Target model identifier
--modeEnumbalancedRouting mode: cost-optimized, balanced, quality-first
--min-qualityFloat0.7Minimum acceptable quality score
--periodEnumdailyReporting period: daily, weekly, monthly
--byEnumtotalGroup usage by: total, model, task, day
--monthly-limitFloat-Monthly budget limit in USD
--alert-thresholdFloat0.8Budget alert at this fraction of limit

Execution Flow

Phase 1 -- Authentication (0-1s): The command validates the OpenRouter API key from the environment configuration (OPENROUTER_API_KEY). Invalid or expired keys result in immediate rejection with remediation instructions.

Phase 2 -- API Health Check (1-3s): A lightweight health check verifies that the OpenRouter API is accessible and responding within acceptable latency bounds. This check runs before any subcommand execution to provide early failure detection.

Phase 3 -- Subcommand Execution (3s-variable): The specific subcommand is dispatched to the appropriate manager component. Model listing queries the OpenRouter API catalog. Routing configuration updates the local routing table. Usage queries aggregate cost and volume data from the tracking database.

Phase 4 -- Data Enrichment (variable): For model operations, response data is enriched with platform-specific metadata including quality scores from previous usage, compatibility ratings with platform tasks, and cost-efficiency calculations. This enrichment transforms raw API data into actionable intelligence.

Phase 5 -- Result Presentation (1-2s): Results are formatted and displayed according to the specified output format. Tables include sortable columns, and model comparisons include visual quality indicators.

Integration Points

ComponentIntegration TypeDescription
Prismatic AgentsExecutionManaged by openrouter-llm-specialist agent
AIAD RegistryDiscoveryRegistered command with AIAD metadata
TelemetryObservabilityRequest latency, cost, and quality metrics
OllamaFallback partnerLocal models as fallback when cloud unavailable
LLM RouterRouting systemOpenRouter models as routing targets
Quality GatesQuality validationOutput quality gates for model responses
ETS StorageCachingModel catalog and routing table cached in ETS
Budget ManagerCost controlBudget enforcement and alert system

Best Practices

Model Selection Strategy: Do not default to the most expensive model. Many tasks -- summarization, classification, simple code generation -- perform equally well on smaller, cheaper models. Use /openrouter compare to benchmark models against your specific use cases before configuring routing rules.

Cost Monitoring: Set budget alerts at 80% of your monthly limit using /openrouter budget. Review usage patterns weekly with /openrouter usage --by model --period weekly to identify cost optimization opportunities.

Routing Granularity: Define routing rules at the task level rather than using a single default model. Different tasks have different quality-cost trade-off profiles. Code generation may justify premium models while log summarization works fine with economy models.

Quality Baselines: Before configuring quality-first routing, establish baseline quality scores for your target models using /openrouter compare. The --min-quality parameter is only meaningful when calibrated against measured model performance on your specific tasks.

Failover Configuration: Configure at least two routing targets per task type. If the primary model is unavailable or rate-limited, the router automatically fails over to the secondary. This prevents workflow interruptions due to transient provider issues.

Error Handling

Error ConditionHandling StrategyUser Impact
Invalid API keyClear error with configuration instructionsAll operations blocked
API rate limitingAutomatic backoff with queue managementDelayed responses
Model unavailableFailover to next routing targetTransparent model switch
Budget exceededRequests blocked with notificationOperations paused until budget reset
Network timeoutRetry with exponential backoff (3 attempts)Delayed response
Quality below thresholdModel flagged, routing adjustedWarning, alternative model used

Advanced Usage

Bulk Operations

For high-volume operations, configure batch processing:

# Configure batch processing parameters
/openrouter config --batch-size 10 --batch-delay 100ms

# Run batch quality assessment across models
/openrouter benchmark --models "anthropic/*,openai/*" --benchmark-suite standard

Provider Health Monitoring

Track provider reliability over time:

# View provider uptime statistics
/openrouter providers --health --period 30d

# Set provider preference based on reliability
/openrouter config --prefer-provider anthropic --fallback openai

Cost Forecasting

Project future costs based on usage patterns:

# Forecast monthly costs based on current usage
/openrouter forecast --period monthly

# Model cost impact of routing changes
/openrouter simulate-cost --new-route "code-gen -> openai/gpt-4o-mini"

Doctrine Compliance

All commands operate under the NO MERCY, NO DOUBTS doctrine:

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. API interactions must complete or fail explicitly. Budget limits are hard limits, not suggestions. Quality thresholds are enforced without exception.
  • NO DOUBTS: Full investigation before action, evidence-based results. Model selection decisions are backed by benchmark data. Cost projections are based on measured usage patterns. Routing configurations are validated before activation.
  • /llm - Primary LLM operation management and orchestration
  • /local-llm - Execute LLM requests using local providers with zero API cost
  • /ollama - Local AI Ollama model management, installation and optimization
  • /chatgpt-bridge - ChatGPT bridge operations for cross-LLM coordination
  • /code - Core coding implementation and feature development
  • /fix - Bug fix implementation with mandatory regression tests

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL