Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: remove buy credits button from pipes, fix cost cap for cheap models

Louis Beaumonte98eeb316c4c
diff --git a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
index 421a39f24..6ae995c03 100644
--- a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
@@ -1256,20 +1256,12 @@ export function PipesSection() {
<div className="flex items-center gap-2 text-xs px-4 py-2">
<span className="text-muted-foreground">
{limitError.type === "credits_exhausted"
- ? "no credits remaining — buy more at screenpi.pe"
+ ? "daily ai usage limit reached — try a lighter model or wait until tomorrow"
: limitError.message}
{limitError.resets_at && (
<> · resets {new Date(limitError.resets_at).toLocaleTimeString()}</>
)}
</span>
- <Button
- variant="outline"
- size="sm"
- className="h-6 text-[11px] px-2"
- onClick={() => openUrl("https://screenpi.pe/billing")}
- >
- buy credits →
- </Button>
</div>
);
})()}
diff --git a/packages/ai-gateway/src/index.ts b/packages/ai-gateway/src/index.ts
index 60f5e5708..c07087623 100644
--- a/packages/ai-gateway/src/index.ts
+++ b/packages/ai-gateway/src/index.ts
@@ -85,14 +85,19 @@ async function handleRequest(request: Request, env: Env, ctx: ExecutionContext):
})));
}
- // Per-user daily cost cap — skip for zero-cost models (they're free to us)
- if (!isZeroCostModel(body.model)) {
+ // Per-user daily cost cap — only for expensive models (weight >= 3).
+ // Cheap models (weight 0-1) like qwen3.5-flash, haiku, deepseek-chat
+ // should not trigger cost caps — they're affordable and pipes need them.
+ // Subscribed users get 5x higher cap.
+ const modelWeight = getModelWeight(body.model);
+ if (!isZeroCostModel(body.model) && modelWeight >= 3) {
const dailyCost = await getDailyUserCost(env, authResult.deviceId);
- const maxCost = getMaxDailyCostPerUser(env);
+ const baseCap = getMaxDailyCostPerUser(env);
+ const maxCost = authResult.tier === 'subscribed' ? baseCap * 5 : baseCap;
if (dailyCost >= maxCost) {
return addCorsHeaders(createErrorResponse(429, JSON.stringify({
error: 'daily_cost_limit_exceeded',
- message: `You've reached your daily AI usage limit. Try a free model or come back tomorrow.`,
+ message: `You've reached your daily AI usage limit. Try a free model or wait until tomorrow.`,
free_models: ['qwen/qwen3-coder:free', 'stepfun/step-3.5-flash:free', 'gemini-3-flash'],
})));
}
@@ -317,14 +322,16 @@ async function handleRequest(request: Request, env: Env, ctx: ExecutionContext):
// If body parse fails, let the proxy handle the error downstream
}
- // Per-user daily cost cap — all paid models
- if (!isZeroCostModel(parsedModel)) {
+ // Per-user daily cost cap — only expensive models (weight >= 3)
+ const msgModelWeight = getModelWeight(parsedModel);
+ if (!isZeroCostModel(parsedModel) && msgModelWeight >= 3) {
const dailyCost = await getDailyUserCost(env, authResult.deviceId);
- const maxCost = getMaxDailyCostPerUser(env);
+ const baseCap = getMaxDailyCostPerUser(env);
+ const maxCost = authResult.tier === 'subscribed' ? baseCap * 5 : baseCap;
if (dailyCost >= maxCost) {
return addCorsHeaders(createErrorResponse(429, JSON.stringify({
error: 'daily_cost_limit_exceeded',
- message: `You've reached your daily AI usage limit. Try a free model or come back tomorrow.`,
+ message: `You've reached your daily AI usage limit. Try a free model or wait until tomorrow.`,
free_models: ['qwen/qwen3-coder:free', 'stepfun/step-3.5-flash:free', 'gemini-3-flash'],
})));
}
@@ -415,14 +422,16 @@ async function handleRequest(request: Request, env: Env, ctx: ExecutionContext):
// body parse failure — proceed with defaults
}
- // Per-user daily cost cap — all paid models
- if (!isZeroCostModel(ocModel)) {
+ // Per-user daily cost cap — only expensive models (weight >= 3)
+ const ocModelWeight = getModelWeight(ocModel);
+ if (!isZeroCostModel(ocModel) && ocModelWeight >= 3) {
const dailyCost = await getDailyUserCost(env, authResult.deviceId);
- const maxCost = getMaxDailyCostPerUser(env);
+ const baseCap = getMaxDailyCostPerUser(env);
+ const maxCost = authResult.tier === 'subscribed' ? baseCap * 5 : baseCap;
if (dailyCost >= maxCost) {
return addCorsHeaders(createErrorResponse(429, JSON.stringify({
error: 'daily_cost_limit_exceeded',
- message: `You've reached your daily AI usage limit. Try a free model or come back tomorrow.`,
+ message: `You've reached your daily AI usage limit. Try a free model or wait until tomorrow.`,
free_models: ['qwen/qwen3-coder:free', 'stepfun/step-3.5-flash:free', 'gemini-3-flash'],
})));
}