Skip to content

feat: add OpenRouter support with catalog-driven model resolution and cost-based routing#109

Open
samueltuyizere wants to merge 25 commits into
mainfrom
add-open-router
Open

feat: add OpenRouter support with catalog-driven model resolution and cost-based routing#109
samueltuyizere wants to merge 25 commits into
mainfrom
add-open-router

Conversation

@samueltuyizere

@samueltuyizere samueltuyizere commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

This PR adds OpenRouter provider support, a local model catalog system, and cost-based routing to routatic-proxy.

What's new

OpenRouter Provider (ba0045c, 1b50001)

  • Adds OpenRouter as a first-class provider alongside OpenCode Go / Zen / AWS Bedrock
  • Provider model index creation and synchronization via a local catalog

Model Catalog System (bdc792f56ed94c)

  • Catalog synchronization with configurable auto-sync intervals and directory resolution
  • Catalog loading, validation, and indexing from JSON-based model manifests
  • Lock file management for concurrent-safe syncs
  • Catalog management CLI commands (routatic-proxy catalog)
  • HTTP serving of catalog data for connected clients

Catalog-Based Model Resolution (bfa3e81, 032c1dd, b6ef72e, 0411bc4)

  • ModelRouter enhanced to resolve models from the catalog instead of static lists
  • Graceful handling of unknown providers with improved error messages
  • Provider filtering in models list command with cleaner output formatting

Cost-Based Routing (b6ecfdf, 3754f07, 4640470)

  • SelectCheapest routing strategy that selects the most cost-effective model satisfying request constraints
  • Respects tool usage, vision, reasoning effort, and context window constraints
  • Config-driven via routing.strategy with fallback to existing scenario-based routing

GUI Updates (56ed94c)

  • Dashboard updates to display catalog and OpenRouter provider status

@samueltuyizere samueltuyizere self-assigned this Jun 30, 2026
Comment thread internal/catalog/sync.go Outdated
Comment thread internal/catalog/sync.go Outdated
Comment thread internal/router/model_router.go Outdated
Comment thread internal/config/config.go
@kilo-code-bot

kilo-code-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

This incremental update is actually clean. I had my flamethrower warmed up and everything, but the previously-flagged "config theater" issue got fixed:

  • ✅ All three CostRoutingConfig fields (prefer_providers, max_context_window, penalty_per_provider) are now wired into the routing logic
  • ✅ Penalty adds per-provider cost deltas during sorting
  • ✅ Max context window filters out oversized models
  • ✅ Global prefer_providers intersects with scenario preferences

🏆 Best part: The fixes are surgical — exactly the minimal changes needed to address each problem. No cargo-culting or over-engineering.

📊 Overall: Like finding a pancake that's actually round — the shape is right and the ingredients are there.

Files Reviewed (1 file)
  • internal/router/selector.go - Previous issues resolved
Previous Review Summaries (5 snapshots, latest commit ce637b4)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit ce637b4)

Verdict: No Issues Found | Recommendation: Merge

This incremental update is actually clean. I had my flamethrower warmed up and everything, but the previously-flagged "config theater" issue got fixed:

  • ✅ All three CostRoutingConfig fields (prefer_providers, max_context_window, penalty_per_provider) are now wired into the routing logic
  • ✅ Penalty adds per-provider cost deltas during sorting
  • ✅ Max context window filters out oversized models
  • ✅ Global prefer_providers intersects with scenario preferences

🏆 Best part: The fixes are surgical — exactly the minimal changes needed to address each problem. No cargo-culting or over-engineering.

📊 Overall: Like finding a pancake that's actually round — the shape is right and the ingredients are there.

Files Reviewed (1 file)
  • internal/router/selector.go - Previous issues resolved

Previous review (commit e625f50)

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this incremental update is actually clean. I had my flamethrower warmed up and everything, but both previously-flagged bugs got fixed:

  • ✅ HTTP timeout added to catalog sync (no more infinite hangs)
  • ✅ Removed the rogue os.Remove(finalPath) that deleted good data on error

🏆 Best part: The fixes are surgical — exactly the minimal changes needed to address each problem. No cargo-culting or over-engineering.

�💀 Worst part: The cache invalidation issue in model_router.go and dead config fields in config.go are still lurking in unchanged code. But those weren't part of this incremental diff.

📊 Overall: Like finding a pancake that's actually round — the shape is right and the ingredients are there.

Files Reviewed (1 file)
  • internal/catalog/sync.go - Issues fixed

Previous review (commit b642ab9)

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this incremental update is actually clean. I had my flamethrower warmed up and everything, but both previously-flagged bugs got fixed:

  • ✅ HTTP timeout added to catalog sync (no more infinite hangs)
  • ✅ Removed the rogue os.Remove(finalPath) that deleted good data on error

🏆 Best part: The fixes are surgical — exactly the minimal changes needed to address each problem. No cargo-culting or over-engineering.

�💀 Worst part: The cache invalidation issue in model_router.go and dead config fields in config.go are still lurking in unchanged code. But those weren't part of this incremental diff.

📊 Overall: Like finding a pancake that's actually round — the shape is right and the ingredients are there.

Files Reviewed (1 file)
  • internal/catalog/sync.go - Issues fixed

Previous review (commit e178a78)

Verdict: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 1
⚠️ warning 2
💡 suggestion 1
Issue Details (click to expand)
File Line Roast
internal/catalog/sync.go 100 Deletes successfully-written catalog when index write fails
internal/catalog/sync.go 49 No HTTP timeout on upstream catalog fetch
internal/router/model_router.go 50 Permanent catalog cache ignores GUI-synced updates
internal/config/config.go 33 Dead config fields (prefer_providers, penalty_per_provider, max_context_window) never used

🏆 Best part: The test coverage is surprisingly thorough — someone clearly believed in testing before shipping 37 files of new code.

💀 Worst part: The catalog sync will silently delete your model cache when the index write fails. Nothing says "I care about your data" like an error handler that deletes the good file.

📊 Overall: Like a house with a nice paint job and a termite-infested foundation. Looks great from the street, but one rainy day and you're sleeping in the yard.

Files Reviewed (37 files)
  • internal/catalog/sync.go - 2 issues
  • internal/router/model_router.go - 1 issue
  • internal/config/config.go - 1 issue

Fix these issues in Kilo Cloud

Previous review (commit 4640470)

Verdict: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 1
⚠️ warning 2
💡 suggestion 1
Issue Details (click to expand)
File Line Roast
internal/catalog/sync.go 100 Deletes successfully-written catalog when index write fails
internal/catalog/sync.go 49 No HTTP timeout on upstream catalog fetch
internal/router/model_router.go 50 Permanent catalog cache ignores GUI-synced updates
internal/config/config.go 33 Dead config fields (prefer_providers, penalty_per_provider, max_context_window) never used

🏆 Best part: The test coverage is surprisingly thorough — someone clearly believed in testing before shipping 37 files of new code.

💀 Worst part: The catalog sync will silently delete your model cache when the index write fails. Nothing says "I care about your data" like an error handler that deletes the good file.

📊 Overall: Like a house with a nice paint job and a termite-infested foundation. Looks great from the street, but one rainy day and you're sleeping in the yard.

Files Reviewed (37 files)
  • internal/catalog/sync.go - 2 issues
  • internal/router/model_router.go - 1 issue
  • internal/config/config.go - 1 issue

Fix these issues in Kilo Cloud


Reviewed by step-3.7-flash-20260528 · Input: 139.4K · Output: 21.7K · Cached: 326K

@samueltuyizere samueltuyizere changed the title Add open router feat: add OpenRouter support with catalog-driven model resolution and cost-based routing Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant