summaryrefslogtreecommitdiffhomepage
path: root/cloud
diff options
context:
space:
mode:
Diffstat (limited to 'cloud')
-rw-r--r--cloud/app/src/routes/zen/v1/chat/completions.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/cloud/app/src/routes/zen/v1/chat/completions.ts b/cloud/app/src/routes/zen/v1/chat/completions.ts
index 6f206225c..090f4aaa3 100644
--- a/cloud/app/src/routes/zen/v1/chat/completions.ts
+++ b/cloud/app/src/routes/zen/v1/chat/completions.ts
@@ -56,6 +56,13 @@ const MODELS = {
},
}
+const FREE_WORKSPACES = [
+ "wrk_01K47W3MEXPJZQ8J14B1NNPS9Z", // adam
+ "wrk_01K46F9BS6S1RC2W49CH6KSMDN", // dax
+ "wrk_01K46JDFR0E75SG2Q8K172KF3Y", // frank
+ "wrk_01K484AYAZ8RA7G32ZB93VZX6M", // jay
+]
+
class AuthError extends Error {}
class CreditsError extends Error {}
class ModelError extends Error {}
@@ -66,6 +73,7 @@ export async function POST(input: APIEvent) {
const body = await input.request.json()
const MODEL = validateModel()
const apiKey = await authenticate()
+ const isFree = FREE_WORKSPACES.includes(apiKey?.workspaceID ?? "")
await checkCredits()
// Request to model provider
@@ -195,7 +203,7 @@ export async function POST(input: APIEvent) {
}
async function checkCredits() {
- if (!apiKey || !MODEL.auth) return
+ if (!apiKey || !MODEL.auth || isFree) return
const billing = await Database.use((tx) =>
tx
@@ -229,7 +237,7 @@ export async function POST(input: APIEvent) {
const cacheReadCost = MODEL.cost.cacheRead * cacheReadTokens
const cacheWriteCost = MODEL.cost.cacheWrite * cacheWriteTokens
const costInCents = (inputCost + outputCost + reasoningCost + cacheReadCost + cacheWriteCost) * 100
- const cost = centsToMicroCents(costInCents)
+ const cost = isFree ? 0 : centsToMicroCents(costInCents)
await Database.transaction(async (tx) => {
await tx.insert(UsageTable).values({