How shaivpidadi/freeride works
1. What this repo is
- FreeRide is a Python-based CLI skill for OpenClaw that automates model selection for OpenRouter free models.
- It is not an application server or UI app; its core job is to inspect available models, choose/rank them, and rewrite OpenClaw configuration so the gateway can use free models and fallbacks.
2. Primary execution paths
- The main user-facing entrypoint is the freeride CLI.
- A second entrypoint, freeride-watcher, runs the monitoring/rotation loop that reacts to rate limits and switches models automatically.
- These are the two operational subsystems the architecture diagram should show as separate but related command-line tools.
3. Core orchestration flow
- The main flow is: user command → model discovery → ranking → config update → OpenClaw restart.
- FreeRide does not itself serve traffic; it prepares OpenClaw’s model configuration so OpenClaw can route future agent requests through OpenRouter.
4. Model selection subsystem
- FreeRide’s central logic is around enumerating free OpenRouter models, assigning a score, and selecting the best primary model plus fallbacks.
- The README describes the ranking dimensions as context length, capabilities, recency, and provider trust.
- A special router model, openrouter/free, is treated as the first fallback because it dynamically chooses among available free models.
5. Configuration management boundary
- The main persistence boundary is OpenClaw’s local config under the user’s home workspace, specifically the OpenClaw JSON configuration mentioned in the README.
- FreeRide is careful to modify only the model-related parts: agents.defaults.model and agents.defaults.models.
- Everything else in the OpenClaw config is intended to remain untouched, so the diagram should show FreeRide as a targeted config editor, not a full config owner.
6. External service boundary: OpenRouter
- FreeRide depends on OpenRouter’s API as the source of truth for available free models and availability changes.
- The user provides an OPENROUTER_API_KEY via environment variable or OpenClaw config.
- The API boundary matters because model availability and rate limits are external, dynamic inputs to both the auto-configuration and watcher behavior.
7. Watcher / auto-rotation subsystem
- watcher.py backs a daemon-like process that monitors for rate limits and rotates to the next model when needed.
- This subsystem is distinct from the one-time setup commands: it is the runtime resilience layer that keeps OpenClaw usable after the initial config is applied.
- The watcher also supports operational actions like checking status, forcing rotation, and clearing cooldowns.
8. Command surface / user interactions
- The CLI exposes distinct commands for different phases of the workflow:
- auto: full discovery + rank + configure
- list: inspect available models
- switch: choose a specific model
- status: inspect current setup
- fallbacks: update only fallback list
- refresh: rebuild the model cache
- These commands are likely implemented in main.py and should be shown as the primary control surface.
9. Packaging and distribution
- setup.py indicates this is packaged as an installable Python tool, likely with console entrypoints for the two commands.
- requirements.txt defines the runtime dependency set, suggesting the repository is intended to be installed locally into the OpenClaw skill workspace rather than deployed as a service.
10. Skill/marketplace metadata
- skill.json and SKILL.md indicate integration with the ClawHub/OpenClaw skill ecosystem.
- These files are not part of the runtime logic, but they are important architectural metadata for installation, discovery, and documentation in the host platform.
11. Operational dependency on OpenClaw
- FreeRide assumes OpenClaw is already installed and that the operator can run openclaw gateway restart after config changes.
- This makes OpenClaw the downstream consumer of FreeRide’s output: FreeRide prepares the config; OpenClaw actually uses it to route agent traffic.
12. End-to-end data flow to show in a diagram
- Input sources: user CLI command, environment variable/API key, OpenRouter model list, existing OpenClaw config.
- Processing: model ranking, primary/fallback selection, optional watcher-based rotation.
- Output: updated OpenClaw config and, indirectly, model routing behavior inside the OpenClaw gateway.
13. Important architectural takeaway
- The repo is essentially a local automation layer around an external model marketplace and a local agent runtime.
- Its responsibility is limited but critical: keep OpenClaw pointed at the best currently-available free OpenRouter model, and recover automatically when rate limits occur.
Main entry points: main.py freeride CLI · watcher.py Rotation loop · setup.py setup.py · skill.json skill.json
Components 20
CLI surface
User-facing commands and operational entrypoints
- freeride CLI · Primary command surface for discovery, switching, status, and auto-configuration
main.py - Auto setup · End-to-end discover, rank, select, and configure flow
main.py - List models · Inspect available free models
main.py - Switch model · Select a specific model and update the target config
main.py - Status check · Inspect current model selection and runtime state
main.py - Fallbacks · Update the fallback model list without a full refresh
main.py - Refresh cache · Rebuild the cached model list from the upstream API
main.py
Selection logic
Discovery, ranking, and config mutation
- Model discovery · Fetches available free OpenRouter models and availability changes
main.py - Rank models · Scores models by context, capabilities, recency, and provider trust
main.py - Select set · Chooses a primary model plus fallback chain, including openrouter/free
main.py - Config editor · Updates only agents.defaults.model and agents.defaults.models in OpenClaw config
main.py
Watcher runtime
Rate-limit monitoring and rotation loop
- freeride-watcher · Daemon-like watcher for rate limits and automatic rotation
watcher.py - Rotation loop · Detects rate limits, advances to the next model, and manages cooldowns
watcher.py
External systems
Dependencies outside the repository
- Gateway restart · Triggers or expects OpenClaw gateway restart after config changes
- OpenRouter API · Source of truth for free model availability and rate limits
- OpenClaw config · Local gateway configuration that FreeRide targets and OpenClaw consumes
Packaging metadata
Installation and skill ecosystem files
- setup.py · Installable Python package and console entrypoint wiring
setup.py - requirements.txt · Runtime dependency set
requirements.txt - skill.json · ClawHub/OpenClaw skill metadata for discovery and installation
skill.json - SKILL.md · Human-facing skill documentation and usage notes
SKILL.md
Connections 26
- freeride CLI → Auto setup: dispatches · Routes the main CLI into the full automation workflow
- freeride CLI → List models: dispatches · Routes the main CLI to model listing
- freeride CLI → Switch model: dispatches · Routes the main CLI to specific model switching
- freeride CLI → Status check: dispatches · Routes the main CLI to status inspection
- freeride CLI → Fallbacks: dispatches · Routes the main CLI to fallback-only updates
- freeride CLI → Refresh cache: dispatches · Routes the main CLI to cache refresh
- Auto setup → Model discovery: fetches · Starts by discovering available models
- List models → Model discovery: reads · Lists models from the upstream source
- Refresh cache → Model discovery: rebuilds · Refreshes cached model data from the API
- Model discovery → Rank models: feeds · Model inventory becomes ranking input
- Rank models → Select set: produces · Turns scored models into a chosen primary and fallbacks
- Select set → Config editor: writes · Persists selected model set into OpenClaw config
- Config editor → OpenClaw config: targets · Edits the local configuration used by OpenClaw
- Config editor → Gateway restart: after change · Config changes are followed by a gateway restart
- freeride-watcher → Rotation loop: runs · Watcher entrypoint drives the rotation loop
- Rotation loop → OpenRouter API: monitors · Checks for rate limits and changing availability
- Rotation loop → Select set: advances · Moves to the next selected model on failure or cooldown
- Rotation loop → Config editor: updates · Rewrites the model selection in OpenClaw config
- Select set → OpenRouter API: consults · Uses upstream availability as a selection constraint
- freeride CLI → OpenRouter API: auth via key · Relies on OPENROUTER_API_KEY for API access
- setup.py → freeride CLI: installs · Packages the main console entrypoint
- setup.py → freeride-watcher: installs · Packages the watcher console entrypoint
- setup.py → requirements.txt: depends on · Declares runtime dependencies
- skill.json → freeride CLI: describes · Metadata for skill installation and use
- SKILL.md → freeride CLI: documents · Usage guidance for the CLI skill
- OpenClaw config → Gateway restart: consumed by · Gateway restart applies the updated local config