Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const zen = (sessionId: string) =>
},
});

const MODEL_ID = 'glm-5.3-flash';
const MODEL_ID = 'gpt-6-luna';

const model = (sessionId: string) => zen(sessionId).chatModel(MODEL_ID);

Expand Down
12 changes: 6 additions & 6 deletions src/lib/abuse/__tests__/cost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe('estimateTokens', () => {

describe('calculateCost', () => {
it('scales tokens to USD', () => {
expect(calculateCost(1_000_000)).toBeCloseTo(0.28);
expect(calculateCost(500_000)).toBeCloseTo(0.14);
expect(calculateCost(1_000_000)).toBeCloseTo(0.5);
expect(calculateCost(500_000)).toBeCloseTo(0.25);
});
});

Expand All @@ -31,7 +31,7 @@ describe('checkCostLimit', () => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-01-01T00:00:00Z'));
for (let i = 0; i < 6; i++) {
checkCostLimit('u1', 300_000); // ~$0.084 each
checkCostLimit('u1', 300_000); // ~$0.15 each
}
const result = checkCostLimit('u1', 300_000);
expect(result.allowed).toBe(false);
Expand All @@ -52,9 +52,9 @@ describe('recordActualUsage', () => {
it('corrects the last estimate with actual usage', () => {
checkCostLimit('u1', 40_000);
recordActualUsage('u1', 10_000);
// Exhausting the budget now: ~$0.0589 spent (actual) + next estimate must
// still fit — verifies the estimate was replaced, not appended.
const result = checkCostLimit('u1', 1_000_000);
// ~$0.005 spent (actual) + next estimate must still fit — verifies the
// estimate was replaced, not appended.
const result = checkCostLimit('u1', 900_000);
expect(result.allowed).toBe(true);
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/abuse/cost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

export const MAX_TOKENS_PER_REQUEST = 4000;
const MAX_COST_PER_HOUR_USD = 0.5; // ~$0.50/hour budget
const TOKEN_COST_PER_1M = 0.28; // glm-5.3-flash on OpenCode Go (conservative upper bound)
const TOKEN_COST_PER_1M = 0.5; // gpt-6-luna on OpenCode Zen (output upper bound)
const USAGE_WINDOW_MS = 60 * 60 * 1000; // 1 hour
const CLEANUP_INTERVAL_MS = 300_000; // 5 min

Expand Down
Loading