Skip to content

feat(byok): free DeepSeek tier — 200K platform-credited tokens#3

Merged
iamjr15 merged 1 commit into
mainfrom
v2
Jun 21, 2026
Merged

feat(byok): free DeepSeek tier — 200K platform-credited tokens#3
iamjr15 merged 1 commit into
mainfrom
v2

Conversation

@iamjr15

@iamjr15 iamjr15 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Every user gets a lifetime 200,000-token free allowance on deepseek-v4-flash via a platform DeepSeek key, so keyless users can build with zero setup. Their own keys always take precedence; explicit non-free picks are never silently swapped to/from free credits.

Key decisions

  • 3-case credential rule (agent-worker/llm-provider.ts): own key → platform-free flash → OpenRouter → error, gated on an explicit modelExplicit flag (Auto vs explicit pick).
  • Free runs are $0 to the user (metered by tokens, not USD) with a synchronous per-step hard stop from DO-local state — the USD cap can't bound a $0 run.
  • Non-thinking mode (@ai-sdk/deepseek@2.0.39) keeps the tool-loop clean; browser tools stay BYOK-only (platform key never reaches the sandbox).

Already done on prod (this PR just deploys the code)

  • ✅ DB migration applied via Supabase (v2_entitlements.free_deepseek_tokens_used, verified; existing rows default 0).
  • DEEPSEEK_PLATFORM_API_KEY created in CF Secrets Store (active); agent-worker binding resolves.
  • ✅ Platform key tested live: auth, $2 balance, deepseek-v4-flash completion, tool calling.

Verification

pnpm turbo typecheck lint build → 41/41 · 41/41 · 23/23. Reviewed across 3 Codex rounds (10 findings, 9 applied + 1 rejected with evidence).

Give every user a lifetime 200,000-token allowance on deepseek-v4-flash
via a platform DeepSeek key, so keyless users can build with zero setup.
Their own keys always take precedence; explicit non-free picks are never
silently swapped to/from free credits.

- types: deepseek provider + catalog entry + FREE_DEEPSEEK_* consts;
  freeDeepseek on profile; deepseek_free_quota_exhausted error code
- byok: DeepSeek key validator (api.deepseek.com/models)
- db: free_deepseek_tokens_used counter (migration 0004) + atomic
  per-step metering in recordAgentRunUsage
- agent-core: @ai-sdk/deepseek model wiring, non-thinking tool-loop
- agent-worker: 3-case credential resolution (own key → platform-free
  flash → OpenRouter), creditSource threading, synchronous DO-local
  free-quota hard stop, $0 cost for free runs, canonical slug attribution
- gateway/web: Models page free-credits row + usage meter + DeepSeek BYOK
- ops: DEEPSEEK_PLATFORM_API_KEY Secrets Store binding + sync-secrets spec
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cheatcode Ready Ready Preview, Comment Jun 21, 2026 9:18am

@iamjr15 iamjr15 merged commit 1a23641 into main Jun 21, 2026
4 of 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