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

feat: free models bypass limits, remove old GPT models, better error UX

Louis Beaumont20802e238c04
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index 5791d516f..f82d3e2d1 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -85,20 +85,29 @@ const STATIC_MENTION_SUGGESTIONS: MentionSuggestion[] = [
*/
function buildDailyLimitMessage(errorStr: string): string {
try {
+ const isCostLimit = errorStr.includes("daily_cost_limit_exceeded");
+ const isRateLimit = errorStr.includes("rate limit") || errorStr.includes("Rate limit");
+
+ if (isRateLimit) {
+ return "This model is temporarily overloaded. Try switching to another free model like Gemini 3 Flash or Qwen3 Coder.";
+ }
+
+ if (isCostLimit) {
+ return "You've reached your daily usage limit for paid models. Switch to a free model (Qwen3 Coder, Step 3.5 Flash, or Gemini Flash) for unlimited usage.";
+ }
+
const tierMatch = errorStr.match(/"tier":\s*"([^"]+)"/);
- const limitMatch = errorStr.match(/"limit_today":\s*(\d+)/);
const tier = tierMatch?.[1];
- const limit = limitMatch ? parseInt(limitMatch[1]) : null;
if (tier === "subscribed") {
- return `You've hit your daily Pro limit${limit ? ` (${limit} queries)` : ""}. Resets at midnight UTC.`;
+ return "You've hit your daily limit. Switch to a free model (Qwen3 Coder, Gemini Flash) for unlimited usage.";
} else if (tier === "logged_in") {
- return `You've used all ${limit ?? 50} free queries for today. Upgrade to Pro for more.`;
+ return "You've used your free queries for today. Switch to a free model (Qwen3 Coder, Gemini Flash) for unlimited usage, or upgrade to Pro.";
} else {
- return `You've used all ${limit ?? 25} free queries for today. Sign in for more, or upgrade to Pro.`;
+ return "You've used your free queries for today. Sign in for more, or switch to a free model (Qwen3 Coder, Gemini Flash).";
}
} catch {
- return "You've reached your daily query limit.";
+ return "You've reached your daily limit. Try a free model like Qwen3 Coder or Gemini Flash.";
}
}
@@ -3152,8 +3161,10 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
)}
>
<MessageContent message={message} onImageClick={(images, index) => setImageViewer({ images, index })} />
- {/* Upgrade button for daily limit errors */}
+ {/* Upgrade button for daily limit errors (not shown for free model suggestions) */}
{message.role === "assistant" &&
+ !message.content.includes("Switch to a free model") &&
+ !message.content.includes("temporarily overloaded") &&
(message.content.includes("free queries") ||
message.content.includes("daily Pro limit") ||
message.content.includes("daily query limit") ||
diff --git a/packages/ai-gateway/src/index.ts b/packages/ai-gateway/src/index.ts
index 86aac002d..02e27a367 100644
--- a/packages/ai-gateway/src/index.ts
+++ b/packages/ai-gateway/src/index.ts
@@ -10,7 +10,7 @@ import { handleFileTranscription, handleWebSocketUpgrade } from './handlers/tran
import { handleVoiceTranscription, handleVoiceQuery, handleTextToSpeech, handleVoiceChat } from './handlers/voice';
import { handleVertexProxy, handleVertexModels } from './handlers/vertex-proxy';
import { handleWebSearch } from './handlers/web-search';
-import { logCost, getModelCost, inferProvider, getSpendSummary, getDailyUserCost, getMaxDailyCostPerUser } from './services/cost-tracker';
+import { logCost, getModelCost, inferProvider, getSpendSummary, getDailyUserCost, getMaxDailyCostPerUser, isZeroCostModel } from './services/cost-tracker';
import { trackResponseUsage } from './utils/stream-usage-tracker';
import { getModelWeight } from './services/usage-tracker';
// import { handleTTSWebSocketUpgrade } from './handlers/voice-ws';
@@ -91,16 +91,19 @@ async function handleRequest(request: Request, env: Env, ctx: ExecutionContext):
})));
}
- // Per-user daily cost cap — only check for expensive models to avoid latency on cheap ones
- const modelWeight = getModelWeight(body.model);
- if (modelWeight >= 3) {
- const dailyCost = await getDailyUserCost(env, authResult.deviceId);
- const maxCost = getMaxDailyCostPerUser(env);
- if (dailyCost >= maxCost) {
- return addCorsHeaders(createErrorResponse(429, JSON.stringify({
- error: 'daily_cost_limit_exceeded',
- message: `You've reached your daily AI usage limit. Try again tomorrow or use a lighter model like Haiku.`,
- })));
+ // Per-user daily cost cap — skip for zero-cost models (they're free to us)
+ if (!isZeroCostModel(body.model)) {
+ const modelWeight = getModelWeight(body.model);
+ if (modelWeight >= 3) {
+ const dailyCost = await getDailyUserCost(env, authResult.deviceId);
+ const maxCost = getMaxDailyCostPerUser(env);
+ 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.`,
+ free_models: ['qwen/qwen3-coder:free', 'stepfun/step-3.5-flash:free', 'gemini-3-flash'],
+ })));
+ }
}
}
@@ -293,7 +296,8 @@ async function handleRequest(request: Request, env: Env, ctx: ExecutionContext):
if (dailyCost >= maxCost) {
return addCorsHeaders(createErrorResponse(429, JSON.stringify({
error: 'daily_cost_limit_exceeded',
- message: `You've reached your daily AI usage limit. Try again tomorrow or use a lighter model like Haiku.`,
+ message: `You've reached your daily AI usage limit. Try a free model or come back tomorrow.`,
+ free_models: ['qwen/qwen3-coder:free', 'stepfun/step-3.5-flash:free', 'gemini-3-flash'],
})));
}
}
@@ -391,7 +395,8 @@ async function handleRequest(request: Request, env: Env, ctx: ExecutionContext):
if (dailyCost >= maxCost) {
return addCorsHeaders(createErrorResponse(429, JSON.stringify({
error: 'daily_cost_limit_exceeded',
- message: `You've reached your daily AI usage limit. Try again tomorrow or use a lighter model like Haiku.`,
+ message: `You've reached your daily AI usage limit. Try a free model or come back tomorrow.`,
+ free_models: ['qwen/qwen3-coder:free', 'stepfun/step-3.5-flash:free', 'gemini-3-flash'],
})));
}
}
diff --git a/packages/ai-gateway/src/services/cost-tracker.ts b/packages/ai-gateway/src/services/cost-tracker.ts
index 34e46cb3b..d8b18d9cd 100644
--- a/packages/ai-gateway/src/services/cost-tracker.ts
+++ b/packages/ai-gateway/src/services/cost-tracker.ts
@@ -19,15 +19,6 @@ const MODEL_PRICING: Record<string, ModelPricing> = {
'claude-opus-4-6': { input: 15.00, output: 75.00 },
'claude-3-5-sonnet': { input: 3.00, output: 15.00 },
'claude-3-5-haiku': { input: 0.80, output: 4.00 },
- // OpenAI
- 'gpt-4o': { input: 2.50, output: 10.00 },
- 'gpt-4o-mini': { input: 0.15, output: 0.60 },
- 'gpt-4-turbo': { input: 10.00, output: 30.00 },
- 'gpt-4': { input: 30.00, output: 60.00 },
- 'gpt-3.5-turbo': { input: 0.50, output: 1.50 },
- 'o1': { input: 15.00, output: 60.00 },
- 'o1-mini': { input: 3.00, output: 12.00 },
- 'o3-mini': { input: 1.10, output: 4.40 },
// OpenRouter models
'qwen3.5-flash': { input: 0.065, output: 0.26 },
'qwen3.5-397b': { input: 0.39, output: 2.34 },
@@ -35,7 +26,9 @@ const MODEL_PRICING: Record<string, ModelPricing> = {
'deepseek-v3.2-speciale': { input: 0.40, output: 1.20 },
'llama-4-maverick': { input: 0.20, output: 0.60 },
'llama-4-scout': { input: 0.11, output: 0.34 },
+ 'qwen3-coder:free': { input: 0.00, output: 0.00 },
'qwen3-coder': { input: 0.22, output: 1.00 },
+ 'step-3.5-flash:free': { input: 0.00, output: 0.00 },
'step-3.5-flash': { input: 0.00, output: 0.00 },
// Google Gemini
'gemini-2.5-flash': { input: 0.15, output: 0.60 },
@@ -140,6 +133,12 @@ export function inferProvider(model: string): string {
return 'unknown';
}
+/** Returns true for models that cost us $0 (free on OpenRouter, free Gemini tier, etc.) */
+export function isZeroCostModel(model: string): boolean {
+ const pricing = findPricing(model);
+ return pricing !== null && pricing.input === 0 && pricing.output === 0;
+}
+
// Default max daily cost per user in USD (overridable via env.MAX_DAILY_COST_PER_USER)
const DEFAULT_MAX_DAILY_COST_USD = 5.0;
diff --git a/packages/ai-gateway/src/services/usage-tracker.ts b/packages/ai-gateway/src/services/usage-tracker.ts
index e58d4d5b8..307bfa03f 100644
--- a/packages/ai-gateway/src/services/usage-tracker.ts
+++ b/packages/ai-gateway/src/services/usage-tracker.ts
@@ -118,11 +118,8 @@ const MODEL_WEIGHTS: Record<string, number> = {
'gemini-3-pro': 3,
'gemini-3.1-pro': 3,
'gemini-2.5-pro': 3,
- 'gemini-3-flash': 1,
- 'gemini-2.5-flash': 1,
- 'gpt-4o-mini': 1,
- 'gpt-4o': 3,
- 'gpt-4': 3,
+ 'gemini-3-flash': 0,
+ 'gemini-2.5-flash': 0,
// OpenRouter models
'qwen3.5-flash': 1,
'qwen3.5-397b': 3,
@@ -130,8 +127,10 @@ const MODEL_WEIGHTS: Record<string, number> = {
'deepseek-v3.2-speciale': 3,
'llama-4-maverick': 1,
'llama-4-scout': 1,
+ 'qwen3-coder:free': 0,
'qwen3-coder': 1,
- 'step-3.5-flash': 1,
+ 'step-3.5-flash:free': 0,
+ 'step-3.5-flash': 0,
};
export function getModelWeight(model?: string): number {
@@ -171,7 +170,6 @@ const DEFAULT_TIER_CONFIG: Record<UserTier, TierLimits> = {
allowedModels: [
'claude-haiku-4-5',
'claude-sonnet-4-5',
- 'gpt-4o-mini',
'gemini-3-flash',
'gemini-2.5-flash',
'gemini-3-pro',