Skip to content

feat(api): expose cached model endpoints - #4859

Merged
chrarnoldus merged 5 commits into
mainfrom
add-openrouter-gateway-endpoints
Jul 29, 2026
Merged

feat(api): expose cached model endpoints#4859
chrarnoldus merged 5 commits into
mainfrom
add-openrouter-gateway-endpoints

Conversation

@chrarnoldus

@chrarnoldus chrarnoldus commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add OpenRouter-compatible per-model endpoints metadata routes, including /v1 aliases for OpenRouter and gateway
  • serve endpoint metadata from the cached models_by_provider.openrouter snapshot
  • normalize ordinary OpenRouter discounts and apply Kilo custom pricing to every cached endpoint using the same pricing precedence as /models
  • return OpenRouter-shaped 404s for absent and forbidden free models
  • add 60-second CDN caching with 60-second stale-while-revalidate for successful and 404 responses

Testing

  • focused Jest route, alias, cache-header, and custom-pricing tests
  • focused oxlint
  • web typecheck

@chrarnoldus chrarnoldus self-assigned this Jul 29, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The latest commit adds versioned /v1 alias routes (openrouter and gateway) that re-export the canonical handler, and applies a 60s CDN cache with 60s stale-while-revalidate to both success and 404 responses, matching the PR description and the new tests exactly; no issues found in the changed lines.

Files Reviewed (5 files)
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.test.ts
  • apps/web/src/app/api/openrouter/v1/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/gateway/v1/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/gateway/models/[provider]/[model]/endpoints/route.ts (unchanged since last review)
Previous Review Summaries (4 snapshots, latest commit 6a46f90)

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

Previous review (commit 6a46f90)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The latest commit adds an early 404 for forbidden free models before touching the cached metadata, matching the PR description and the new test's expectations; no issues found in the changed lines.

Files Reviewed (4 files)
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.test.ts
  • apps/web/src/lib/ai-gateway/custom-pricing.ts (unchanged since last review)
  • apps/web/src/app/api/gateway/models/[provider]/[model]/endpoints/route.ts (unchanged since last review)

Previous review (commit e587585)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.test.ts
  • apps/web/src/lib/ai-gateway/custom-pricing.ts
  • apps/web/src/app/api/gateway/models/[provider]/[model]/endpoints/route.ts (unchanged since last review)

Previous review (commit a2c85e0)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental change correctly extends the per-model endpoints route to undo OpenRouter pricing discounts using the existing getModelDisplayPricing helper, and the updated test's expected values match the discount math exactly.

Files Reviewed (2 files)
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.test.ts

Previous review (commit 7e51201)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the new per-model endpoints metadata routes and their re-export/gateway alias; the implementation is consistent with existing unauthenticated OpenRouter metadata endpoints in this codebase and the test coverage matches the observable behavior.

Files Reviewed (3 files)
  • apps/web/src/app/api/gateway/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.ts
  • apps/web/src/app/api/openrouter/models/[provider]/[model]/endpoints/route.test.ts

Reviewed by claude-sonnet-5 · Input: 22 · Output: 2.5K · Cached: 382.7K

Review guidance: REVIEW.md from base branch main

@chrarnoldus
chrarnoldus merged commit 2fb2e0c into main Jul 29, 2026
16 checks passed
@chrarnoldus
chrarnoldus deleted the add-openrouter-gateway-endpoints branch July 29, 2026 14:53
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.

2 participants