Skip to content

[AISAGE-707] feat(admin): configure custom model pricing in the gateway admin panel - #7499

Closed
chrarnoldus wants to merge 8 commits into
mainfrom
feat/admin-custom-pricing
Closed

chrarnoldus wants to merge 8 commits into
mainfrom
feat/admin-custom-pricing

Conversation

@chrarnoldus

@chrarnoldus chrarnoldus commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Custom Pricing tab to Admin → Gateway. Admins can add, edit and remove per-model custom pricing without a deploy:
    • $/1M prompt, completion, cache read and cache write prices
    • an optional "N% off" name label
    • fallback-only billing
  • Pricing is stored in a new nullable ai_gateway_config.custom_pricing jsonb column (generated migration 0305_custom_pricing). CustomPricingConfigSchema validates it: lowercase gateway model IDs, finite non-negative prices, an integer discount from 1 to 100, no duplicate models, at most 200 models. New admin tRPC router: admin.gatewayCustomPricing (get / set).
  • Configured pricing first, hardcoded pricing as the fallback.
    • getCustomPricing(modelId, configuredCustomPricing) returns the configured entry for a model if there is one. Otherwise it returns the built-in customPricingByModelId entry (currently Gemini 3.8 Flash and Gemini 4 Argon), which this PR does not change.
    • The tab lists the built-in entries read-only and marks the ones that are overridden.
  • Configured pricing is passed explicitly to every lookup; there is no hidden module state.
    • Server code gets it from getConfiguredCustomPricing(), a DB read cached for 60s, the same pattern as the Vercel model ID overrides. If the stored config is invalid, the last valid value is kept.
    • Every caller now passes it, so a new caller that forgets it fails typecheck:
      • billing and the billed cost reported in responses (applyUsagePricing, called by processTokenData and rewriteUsage). FIM, edit, embedding and System One billing now go through applyUsagePricing too, so configured pricing applies to every billing path.
      • the model catalog (applyCustomPricingToModel)
      • the endpoints API (applyCustomPricingToPricing)
      • service_tier stripping (removeUnsupportedRequestServiceTier)
      • the request spend safeguard (pickerRequestPrice in enforceRequestCostLimit) and the agent briefing price bound (briefingPriceRates). For a ~ alias, the safeguard prices both the requested alias ID, which billing uses, and the target, so pricing configured for either raises the ceiling.
    • On the client, the new public query models.customPricing returns the configured map. The organization Providers & Models page passes it to getOfferingPricing.
  • The agent briefing price bound includes fallback-only configured pricing, because billing charges it when the upstream reports no cost.
  • getConfiguredCustomPricing() reads through readDb, like the other gateway config getters.
  • While a save is pending, the tab disables editing until the stored config has reloaded.
  • Fallback-only entries behave like built-in fallback-only pricing:
  • Configured pricing is a single tier from context length 0. No current custom pricing uses more than one tier.
  • services/kilo-mcp/catalog.json includes the new models.customPricing query.

Verification

  • Local checks:
    • pnpm --filter @kilocode/web-shared typecheck, pnpm --filter @kilocode/db typecheck, pnpm --filter ai-gateway typecheck and the apps/web tsgo typecheck all passed.
    • After rebasing on main, the apps/web Jest suites under packages/web-shared/src/lib/ai-gateway/, src/lib/agent-briefing, src/components/organizations/providers-and-models, src/app/admin/gateway, src/routers/admin and src/routers/models-router passed against a local Postgres. The exception is extend-claw-trial-router.test.ts, whose one-year ceiling assertion is off by an hour around the DST change; it does not touch custom pricing.
    • New tests cover:
      • configured pricing overriding built-in pricing, and falling back to it, in billing and the catalog
      • configured pricing in service_tier stripping
      • configured pricing raising the spend-safeguard ceiling
    • The packages/db schema.test, migration-journal and schema-types tests passed.
    • oxlint and oxfmt on changed files are clean.
  • Manually tested the tab in a local browser: added a discounted and a fallback-only model, saved, edited a saved model, and cleared stored pricing.

Visual Changes

Adds a new "Custom Pricing" tab under Admin > Gateway. It is a form and a table, not a JSON editor. Each model gets prompt, completion and optional cache prices per 1M tokens, an optional discount shown in the model name, and a fallback-only flag. Built-in pricing is listed below with an "Overridden" badge when a configured entry replaces it.

No stored pricing

Custom Pricing tab with no stored pricing

Saved pricing: a discounted model and a fallback-only model

Custom Pricing tab with two saved models

Unsaved edit: the prompt price changed to $2.1, with Discard changes available

Custom Pricing tab with an unsaved edit

Reviewer Notes

  • The branch is rebased on main. The migration was regenerated on top of main's latest migration (0304), and it only adds the custom_pricing column.
  • main moved billed-cost calculation into applyUsagePricing, which also rewrites the cost in responses. Configured pricing is passed to it explicitly; ResponseUsageContext carries it for the response rewriters.
  • main replaced textRequestPriceCeiling with picker-price admission (pickerRequestPrice) and briefingPriceRates. The rebase passes configured pricing into both instead.
  • The org page caches configured pricing for 5 minutes on the client. The gateway applies changes within one minute on warm instances.
  • Moving the built-in entries into the DB and deleting the constants map is left for a follow-up, to keep this change additive.

@chrarnoldus chrarnoldus self-assigned this Oct 13, 2026
@kilo-code-bot

kilo-code-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental fixes now bill configured custom pricing through applyUsagePricing on the FIM, edit, embedding and SystemOne paths, and admission no longer doubles the input rate for blank cache prices, so both previously reported warnings are resolved.

Assumptions: [INFERENCE] Admission (enforceRequestCostLimit) and billing (applyUsagePricing) still read separate cached config snapshots, so an admin price change between the two can briefly make the admitted and billed custom cost disagree; this is bounded by the 60-second cache and is inherent to the existing config pattern.

Files Reviewed (16 files)
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.test.ts
  • packages/web-shared/src/lib/ai-gateway/llm-proxy-helpers.ts
  • packages/web-shared/src/lib/ai-gateway/llm-proxy-helpers.test.ts
  • packages/web-shared/src/lib/ai-gateway/typesafe/handler.ts
  • packages/web-shared/src/lib/ai-gateway/handlers/edit-completions.test.ts
  • packages/web-shared/src/lib/ai-gateway/handlers/fim-completions.test.ts
  • packages/web-shared/src/lib/ai-gateway/usage-cost.ts
  • packages/web-shared/src/lib/ai-gateway/processUsage.ts
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/rewriteModelResponse.ts
  • packages/web-shared/src/lib/ai-gateway/rewriteModelResponse.shared.ts
  • apps/web/src/lib/agent-briefing/summary.ts
  • apps/web/src/lib/agent-briefing/summary.test.ts
  • apps/web/src/app/admin/gateway/CustomPricingContent.tsx
Previous Review Summaries (7 snapshots, latest commit d31d3b6)

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

Previous review (commit d31d3b6)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

Configured custom pricing is threaded through every lookup correctly, but blank (null) cache prices make gateway admission price input at twice the billed rate, and FIM, edit, embeddings and SystemOne still bill upstream cost while advertising the configured price.

Assumptions: [INFERENCE] The save fix relies on mutation.isPending staying true while the awaited onSuccess refetch runs; TanStack Query sources are not installed in this checkout, so that internals claim could not be verified, and the residual discard window (if any) is limited to the refetch duration. [INFERENCE] Admission (enforceRequestCostLimit) and billing (processTokenData) read separate 60-second config snapshots, so an admin price change between them can still make the billed custom cost exceed the admitted ceiling; not raised inline. The incremental diff from ae1378400a was unusable because the branch was rebased onto 7245500647 (history rewritten), so the full PR diff was reviewed; the content delta in PR source files since the previous review is limited to regenerated migration metadata.

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/web-shared/src/lib/ai-gateway/processUsage.ts 1502 Configured pricing is applied only in processTokenData (chat, transcription). FIM (countAndStoreFimUsage), edit (countAndStoreEditUsage), embeddings (countAndStoreEmbeddingUsage) and SystemOne (typesafe/handler.ts:226) call logMicrodollarUsageAndReportToBouncer directly, so an admin-configured price is advertised in the catalog and endpoints API but never billed.
packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts 89 ratesForTier turns a null cache price into prompt_per_million and textPricingRates adds prompt + cache, so configured entries with blank cache prices are admitted at 2 x prompt and get an OpenRouter max_price.prompt of twice the configured price, while billing charges the prompt rate once. Requests near the ceiling are refused and the upstream cap exceeds what Kilo bills.
Files Reviewed (39 files)
  • apps/web/src/app/admin/gateway/CustomPricingContent.tsx
  • apps/web/src/app/admin/gateway/custom-pricing-form.ts
  • apps/web/src/app/admin/gateway/custom-pricing-form.test.ts
  • apps/web/src/app/admin/gateway/page.tsx
  • apps/web/src/components/shared/useConfiguredCustomPricing.ts
  • apps/web/src/components/organizations/providers-and-models/offeringPricing.ts
  • apps/web/src/components/organizations/providers-and-models/offeringPricing.test.ts
  • apps/web/src/components/organizations/providers-and-models/OrganizationProvidersAndModelsPage.tsx
  • apps/web/src/lib/agent-briefing/summary.ts
  • apps/web/src/lib/agent-briefing/summary.test.ts
  • apps/web/src/routers/admin-router.ts
  • apps/web/src/routers/admin/gateway-custom-pricing-router.ts
  • apps/web/src/routers/admin/gateway-custom-pricing-router.test.ts
  • apps/web/src/routers/models-router.ts
  • packages/db/src/schema.ts
  • packages/db/src/schema-types.ts
  • packages/db/src/migrations/0304_custom_pricing.sql
  • packages/db/src/migrations/meta/_journal.json
  • packages/db/src/migrations/meta/0304_snapshot.json (generated, presence only)
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.constants.ts
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.test.ts
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.test.ts
  • packages/web-shared/src/lib/ai-gateway/handlers/model-endpoints.ts
  • packages/web-shared/src/lib/ai-gateway/processUsage.ts
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.test.ts
  • packages/web-shared/src/lib/ai-gateway/rewriteModelResponse.ts
  • packages/web-shared/src/lib/ai-gateway/providers/apply-provider-specific-logic.ts
  • packages/web-shared/src/lib/ai-gateway/providers/apply-provider-specific-logic.test.ts
  • packages/web-shared/src/lib/ai-gateway/providers/openrouter/index.ts
  • packages/web-shared/src/lib/ai-gateway/models.client-boundary.test.ts
  • services/kilo-mcp/catalog.json (generated)
  • Plus test-file companions for the admin routers (auto-free-config-router.test.ts, gateway-model-lists-router.test.ts, preferred-provider-order-router.test.ts) reviewed for the shared config pattern.

Fix these issues in Kilo Cloud

Previous review (commit ae13784)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The three follow-up fixes (fallback-only briefing bound, replica config read, in-flight save guards) check out, but configured pricing is still applied only to chat/transcription billing, so FIM, edit, embeddings and SystemOne paths can advertise configured prices they never bill.

Assumptions: [INFERENCE] The save fix relies on mutation.isPending staying true while the awaited onSuccess refetch runs; TanStack Query internals were not verifiable in this environment, so the residual discard window (if any) is now limited to the refetch duration. [INFERENCE] Admission (enforceRequestCostLimit) and billing (processTokenData) read separate 60-second cached config snapshots, so an admin price change between them can still make billed custom cost exceed the admitted ceiling; not raised inline.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/web-shared/src/lib/ai-gateway/processUsage.ts 1502 Configured pricing is only applied in chat/transcription billing; FIM, edit, embeddings and SystemOne still bill the upstream cost while the catalog and endpoints API advertise the configured price.
Files Reviewed (5 files)
  • apps/web/src/app/admin/gateway/CustomPricingContent.tsx
  • apps/web/src/lib/agent-briefing/summary.test.ts
  • apps/web/src/lib/agent-briefing/summary.ts
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts

Fix these issues in Kilo Cloud

Previous review (commit 1cb9c7c)

Status: 4 Issues Found | Recommendation: Address before merge

Executive Summary

The rebased admin custom-pricing feature is wired consistently through the catalog, endpoint API, spend admission, and chat billing, but configured pricing is not applied to FIM/edit/embeddings/SystemOne billing, the agent-briefing bound ignores fallback-only entries, and the new shared reader uses the primary database on pre-upstream gateway paths.

Assumptions: [INFERENCE] Admission (enforceRequestCostLimit) and billing (processTokenData) read separate 60-second cached config snapshots, so a failed read or an admin price change between them can make the billed custom cost exceed the admitted ceiling; this residual race is not raised as an inline finding. The review basis is a full re-review from the branch base (7c6a424d2) because the branch was rebased and the previously reviewed commit 8a92e9bf7 is no longer an ancestor of HEAD.

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
packages/web-shared/src/lib/ai-gateway/processUsage.ts 1502 Configured pricing is applied only in chat/transcription billing; FIM, edit, embeddings and SystemOne bill the upstream cost while the catalog advertises the configured price.
apps/web/src/lib/agent-briefing/summary.ts 262 The briefing price bound uses applyCustomPricingToPricing, which skips fallbackOnly entries that billing and admission include, so the quote can under-estimate billed cost.
packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.ts 24 The new config reader uses the Frankfurt primary db on pre-upstream gateway paths instead of readDb, against the web-shared AGENTS.md rule.

SUGGESTION

File Line Issue
apps/web/src/app/admin/gateway/CustomPricingContent.tsx 162 The stored-config sync effect discards edits made while a save is in flight, because row actions stay enabled.
Files Reviewed (36 files)
  • apps/web/src/app/admin/gateway/CustomPricingContent.tsx - 1 issue
  • apps/web/src/app/admin/gateway/custom-pricing-form.test.ts
  • apps/web/src/app/admin/gateway/custom-pricing-form.ts
  • apps/web/src/app/admin/gateway/page.tsx
  • apps/web/src/components/organizations/providers-and-models/OrganizationProvidersAndModelsPage.tsx
  • apps/web/src/components/organizations/providers-and-models/offeringPricing.test.ts
  • apps/web/src/components/organizations/providers-and-models/offeringPricing.ts
  • apps/web/src/components/shared/useConfiguredCustomPricing.ts
  • apps/web/src/lib/agent-briefing/summary.ts - 1 issue
  • apps/web/src/routers/admin-router.ts
  • apps/web/src/routers/admin/auto-free-config-router.test.ts
  • apps/web/src/routers/admin/gateway-custom-pricing-router.test.ts
  • apps/web/src/routers/admin/gateway-custom-pricing-router.ts
  • apps/web/src/routers/admin/gateway-model-lists-router.test.ts
  • apps/web/src/routers/admin/preferred-provider-order-router.test.ts
  • apps/web/src/routers/models-router.ts
  • packages/db/src/migrations/0303_custom_pricing.sql
  • packages/db/src/migrations/meta/0303_snapshot.json (generated)
  • packages/db/src/migrations/meta/_journal.json
  • packages/db/src/schema-types.ts
  • packages/db/src/schema.ts
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.test.ts
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.ts - 1 issue
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.constants.ts
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.test.ts
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/handlers/model-endpoints.ts
  • packages/web-shared/src/lib/ai-gateway/models.client-boundary.test.ts
  • packages/web-shared/src/lib/ai-gateway/processUsage.ts - 1 issue
  • packages/web-shared/src/lib/ai-gateway/providers/apply-provider-specific-logic.test.ts
  • packages/web-shared/src/lib/ai-gateway/providers/apply-provider-specific-logic.ts
  • packages/web-shared/src/lib/ai-gateway/providers/openrouter/index.ts
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.test.ts
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts
  • packages/web-shared/src/lib/ai-gateway/rewriteModelResponse.ts
  • services/kilo-mcp/catalog.json (generated)

Previous review (commit 8a92e9b)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The follow-up commit resolves all three earlier findings: the admin tab now refuses to render the editable form until the stored pricing loads, change detection compares fields in a fixed order, and the spend ceiling includes custom pricing for both the requested model ID and the alias target. Remaining incremental changes are tests and a two-argument call site update; no new issues found.

Files Reviewed (6 files)
  • apps/web/src/app/admin/gateway/CustomPricingContent.tsx - error/loading guard verified; no issues
  • apps/web/src/app/admin/gateway/custom-pricing-form.ts - sameCustomPricing verified against stored jsonb key order; no issues
  • apps/web/src/app/admin/gateway/custom-pricing-form.test.ts - reordered-key and change-detection coverage; no issues
  • apps/web/src/lib/agent-briefing/summary.ts - now passes the requested model so alias-configured pricing is bounded; matches billing key in processUsage.ts:1448; no issues
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts - ceiling unions requested and alias-target tiers; max-based and conservative; no issues
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.test.ts - alias case covered; no issues

Note: packages/web-shared/src/lib/ai-gateway/providers/upstream-url-policy.ts and apps/web/src/services/worktree-deletion.ts appear in the local commit range only because main was merged into the branch (PR base 33d283539), not as changes authored by this PR, so they were out of scope.

Previous review (commit a1d5526)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/app/admin/gateway/CustomPricingContent.tsx 157 A failed get query is treated as "no stored pricing": Save stays enabled and one click persists { models: [] }, wiping the stored config.
packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts 40 The spend ceiling keys configured pricing by the alias target while billing keys it by the requested ~alias id, so alias-keyed configured pricing is billed but not bounded (same shape in apps/web/src/lib/agent-briefing/summary.ts).

SUGGESTION

File Line Issue
apps/web/src/app/admin/gateway/CustomPricingContent.tsx 45 samePricing compares JSON.stringify key order, so re-saving an unchanged model with a discount is reported as unsaved changes.
Files Reviewed (33 files)
  • apps/web/src/app/admin/gateway/CustomPricingContent.tsx - 2 issues
  • apps/web/src/app/admin/gateway/custom-pricing-form.ts
  • apps/web/src/app/admin/gateway/page.tsx
  • apps/web/src/routers/admin/gateway-custom-pricing-router.ts
  • apps/web/src/routers/admin-router.ts
  • apps/web/src/routers/models-router.ts
  • apps/web/src/components/shared/useConfiguredCustomPricing.ts
  • apps/web/src/components/organizations/providers-and-models/OrganizationProvidersAndModelsPage.tsx
  • apps/web/src/components/organizations/providers-and-models/offeringPricing.ts
  • apps/web/src/lib/agent-briefing/summary.ts
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.constants.ts
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.ts
  • packages/web-shared/src/lib/ai-gateway/processUsage.ts
  • packages/web-shared/src/lib/ai-gateway/request-cost-limit.ts - 1 issue
  • packages/web-shared/src/lib/ai-gateway/rewriteModelResponse.ts
  • packages/web-shared/src/lib/ai-gateway/providers/apply-provider-specific-logic.ts
  • packages/web-shared/src/lib/ai-gateway/handlers/model-endpoints.ts
  • packages/web-shared/src/lib/ai-gateway/handlers/llm-proxy.ts
  • packages/web-shared/src/lib/ai-gateway/providers/openrouter/index.ts
  • packages/db/src/schema.ts
  • packages/db/src/schema-types.ts
  • packages/db/src/migrations/0292_custom_pricing.sql
  • packages/db/src/migrations/meta/_journal.json
  • .kilo/skills/kilo-mcp/SKILL.md
  • services/kilo-mcp/catalog.json
  • plus the associated test files for the above

Generated files (packages/db/src/migrations/meta/0292_snapshot.json) were not reviewed line by line.

Previous review (commit 8cb2f45)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The only changes attributable to this PR since the previous review are a regenerated Kilo MCP catalog entry (models.customPricing, a read-only query with no write exposure) and its skill count refresh; no new issues were found, and the previously flagged catalog fallbackOnly behavior is a pre-existing, intentional pattern (applyCustomPricingToModel predates this PR and admin entries intentionally match the built-in ones).

Files Reviewed (2 files)
  • .kilo/skills/kilo-mcp/SKILL.md - count refresh, consistent with the added query
  • services/kilo-mcp/catalog.json - new models.customPricing query entry; no issues

Previous review (commit fa77c2c)

Status: 1 Issues Found | Recommendation: Address before merge

Executive Summary

Configured custom pricing is correctly validated and wired through billing, endpoints, and the org page, but the public model catalog applies it without honoring fallbackOnly, so fallback-only models are advertised at a price they are not always billed.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/web-shared/src/lib/ai-gateway/providers/openrouter/index.ts 135 Configured pricing reaches applyCustomPricingToModel, which ignores fallbackOnly; the catalog then shows a custom price and (N% off) suffix for fallback-only models, unlike applyCustomPricingToPricing and getOfferingPricing.
Files Reviewed (26 files)
  • apps/web/src/app/admin/gateway/CustomPricingContent.tsx - reviewed, no issues
  • apps/web/src/app/admin/gateway/custom-pricing-form.ts - reviewed, no issues
  • apps/web/src/app/admin/gateway/custom-pricing-form.test.ts - reviewed, no issues
  • apps/web/src/app/admin/gateway/page.tsx - reviewed, no issues
  • apps/web/src/components/organizations/providers-and-models/OrganizationProvidersAndModelsPage.tsx - reviewed, no issues
  • apps/web/src/components/organizations/providers-and-models/offeringPricing.ts - reviewed, no issues
  • apps/web/src/components/organizations/providers-and-models/offeringPricing.test.ts - reviewed, no issues
  • apps/web/src/components/shared/useConfiguredCustomPricing.ts - reviewed, no issues
  • apps/web/src/routers/admin-router.ts - reviewed, no issues
  • apps/web/src/routers/admin/gateway-custom-pricing-router.ts - reviewed, no issues
  • apps/web/src/routers/admin/gateway-custom-pricing-router.test.ts - reviewed, no issues
  • apps/web/src/routers/admin/auto-free-config-router.test.ts - reviewed, no issues
  • apps/web/src/routers/admin/gateway-model-lists-router.test.ts - reviewed, no issues
  • apps/web/src/routers/models-router.ts - reviewed, no issues
  • packages/db/src/migrations/0278_handy_talkback.sql - reviewed, no issues (nullable add, singleton table)
  • packages/db/src/migrations/meta/0278_snapshot.json - generated, skipped
  • packages/db/src/migrations/meta/_journal.json - generated, skipped
  • packages/db/src/schema-types.ts - reviewed, no issues
  • packages/db/src/schema.ts - reviewed, no issues
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.ts - reviewed, no issues
  • packages/web-shared/src/lib/ai-gateway/configured-custom-pricing.test.ts - reviewed, no issues
  • packages/web-shared/src/lib/ai-gateway/custom-pricing.constants.ts - reviewed, no issues
  • packages/web-shared/src/lib/ai-gateway/handlers/llm-proxy.ts - reviewed, no issues
  • packages/web-shared/src/lib/ai-gateway/handlers/model-endpoints.ts - reviewed, no issues
  • packages/web-shared/src/lib/ai-gateway/processUsage.ts - reviewed, no issues
  • packages/web-shared/src/lib/ai-gateway/providers/openrouter/index.ts - 1 issue

Notes: configured-custom-pricing.ts correctly fails safe via createCachedFetch, and CustomPricingConfigSchema rejects NaN, non-finite, and out-of-range values. No file-listener, timer, or subscription leaks were introduced by the new components.

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 122K · Output: 34.7K · Cached: 3M

Review guidance: REVIEW.md from base branch main

@chrarnoldus chrarnoldus changed the title feat(admin): configure custom model pricing in the gateway admin panel [AISAGE-707] feat(admin): configure custom model pricing in the gateway admin panel Oct 19, 2026
@chrarnoldus
chrarnoldus force-pushed the feat/admin-custom-pricing branch from ae13784 to d31d3b6 Compare October 26, 2026 13:48
@chrarnoldus
chrarnoldus force-pushed the feat/admin-custom-pricing branch from d31d3b6 to 7297587 Compare October 26, 2026 14:12
@chrarnoldus
chrarnoldus force-pushed the feat/admin-custom-pricing branch from 1f9215c to 1a5c4b0 Compare October 26, 2026 15:02
@chrarnoldus
chrarnoldus deleted the feat/admin-custom-pricing branch October 26, 2026 19:43
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