Skip to content

feat(deco-ai-gateway): move billing defaults to database config table#272

Merged
JonasJesus42 merged 2 commits intomainfrom
feat/billing-cost-analytics
Mar 3, 2026
Merged

feat(deco-ai-gateway): move billing defaults to database config table#272
JonasJesus42 merged 2 commits intomainfrom
feat/billing-cost-analytics

Conversation

@JonasJesus42
Copy link
Contributor

@JonasJesus42 JonasJesus42 commented Mar 3, 2026

Create llm_gateway_config singleton table to store configurable billing defaults (prepaid/postpaid limits, hard cap, markup %, min Stripe amount). Replace hardcoded constants with async loadGatewayDefaults() that reads from DB with 5-min cache and falls back to previous hardcoded values.

Made-with: Cursor


Summary by cubic

Moves billing defaults to a DB-backed config so limits, hard cap, markup, and minimum Stripe charge can be changed without deploys. Also removes a duplicate llm_gateway_config schema definition.

  • New Features

    • Added llm_gateway_config singleton table (prepaid/postpaid limits, hard cap, markup %, min Stripe amount) with service_role RLS.
    • Implemented getGatewayDefaults (5‑min cache) and wired it into provisioning, credits, set-limit, and saveApiKey.
  • Migration

    • Run the schema migration to create llm_gateway_config and its policy (inserts the 'global' row).
    • Optionally set custom values in llm_gateway_config; defaults mirror previous hardcoded values.

Written for commit f6ff84e. Summary will update on new commits.

Create llm_gateway_config singleton table to store configurable billing
defaults (prepaid/postpaid limits, hard cap, markup %, min Stripe amount).
Replace hardcoded constants with async loadGatewayDefaults() that reads
from DB with 5-min cache and falls back to previous hardcoded values.

Made-with: Cursor
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🚀 Preview Deployments Ready!

Your changes have been deployed to preview environments:

📦 deco-ai-gateway

🔗 View Preview

These previews will be automatically updated with new commits to this PR.


Deployed from commit: cd6a4ce

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="deco-ai-gateway/server/db/schema.sql">

<violation number="1" location="deco-ai-gateway/server/db/schema.sql:44">
P2: This introduces a duplicated schema/policy definition for `llm_gateway_config` in the same script. Keep a single source of truth to avoid drift when defaults or policy rules change.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

The config table was defined in both PART 1 (main schema) and PART 3
(migrations). Since PART 1 already uses CREATE TABLE IF NOT EXISTS,
the migration block was fully redundant.

Made-with: Cursor
@JonasJesus42 JonasJesus42 merged commit 5b3a5ca into main Mar 3, 2026
5 checks passed
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