Branchwell

Inkspring / website / docs / sponsored-services.md

Show the source

Sponsored access (source-only, off by default)

This is an invite-only, capped rollout. A participant uses one revocable InkSpring invitation, not an AI provider key. Never ship an invite shared across installations. The Mac validates an invitation against this service, stores it in this device's Keychain, and asks for disclosure consent before enabling sponsored AI. It does not silently fall back to personal credentials on a sponsored failure. Native iPhone/iPad can only access this through a connected home Mac's authorized companion workflow; there is no standalone hosted login/signup in this change.

Gates and environment

Keep both feature flags at the committed false values until a controlled rollout is explicitly authorized. Use a dedicated Cloudflare D1 database, apply migrations/0001_sponsored.sql and bind it as SPONSORED_DB on the existing Pages project. No database IDs or secret values belong in source. Provision a separate R2 bucket and bind it as SPONSORED_INSTAGRAM_R2 only for a sponsored photo rollout; configure a one-day lifecycle deletion rule on that private bucket before setting the separate SPONSORED_INSTAGRAM_IMAGE_ENABLED=true flag. The image URL stops working after one hour even before deletion, is unlisted with 128 bits of randomness, isn't indexed or cached, and can be fetched by whoever has the exact URL until it expires. Meta's crawler cannot authenticate, so it is not technically restricted to Meta's IPs. Never log or share asset URLs. This supports JPEG feed photos, not Reels or video covers.

Configure each paid vendor independently using dedicated least-privilege app credentials under Cloudflare encrypted bindings (not in desktop bundles, VITE_*, provider responses, logs or public config). Only configure models that were cost-reviewed and tested; missing credentials/model settings fail closed:

VendorSecretFixed model options
OpenAISPONSORED_OPENAI_API_KEYSPONSORED_OPENAI_TEXT_MODEL, SPONSORED_OPENAI_IMAGE_MODEL
AnthropicSPONSORED_ANTHROPIC_API_KEYSPONSORED_ANTHROPIC_TEXT_MODEL
Google GeminiSPONSORED_GEMINI_API_KEYSPONSORED_GEMINI_TEXT_MODEL, SPONSORED_GEMINI_IMAGE_MODEL

Create each member with a stable internal opaque ID, the lowercase SHA-256 hex digest of a unique invitation (the string is1_ followed by 32 cryptographically random bytes encoded as 43 base64url characters), an expiry in integer UNIX milliseconds, and enabled=1. Exchange the raw invitation with its intended recipient through an approved private channel; never store it in D1. Rotate a participant by changing that row's digest and expiry without changing their internal subject. Revoke the row with enabled=0. The app caps writing at 4,000 requested output tokens and forbids client-controlled upstream URLs, model IDs or extra tools. Apify and X search are not sponsored or exposed.

Volume and cost

There are 12 credits per member per UTC day and hard shared counters at 8 paid requests per minute, 120 credits per day, and 1,200 credits per UTC month. A write is 1 credit; generating one 1K image or temporarily hosting one JPEG is 4. Failed upstream calls consume their reservation because they may have been billed. Each check and reservation is one conditional SQLite write; these are usage quotas, not a guaranteed dollar cap. Keep provider-specific spend/rate caps and alerts. Before enabling, estimate and verify the most expensive allowed request rather than relying on dashboard budget alerts. Keep usage rows through the end of the current billing month; add reviewed retention/cleanup rules before scaling. Logs and the D1 tables store no prompts, social posts, provider responses, email addresses, or raw invitations. Quota records contain internal member ID, timestamp buckets, operation, reservation ID and credit count.

Recommended first option: paid Gemini 3.5 Flash-Lite for text, optionally Gemini 3.1 Flash Lite Image, keeping Anthropic/OpenAI off until quality/cost estimates justify them. As checked November 29, 2026, Google lists text at $0.30 per million input tokens and $2.50 per million output tokens, and 1K image output is $0.0336 per image before inputs and extras. At 1,200 all-text calls of 4,000 input and 4,000 output tokens, illustrative vendor usage is $13.44/month; at 300 all-image calls, base image output is $10.08/month, excluding inputs/thinking. Neither is a guarantee. Provider billing keys, account verification and production connectivity were not checked.

Rollout checklist (not performed)

Confirm paid vendor terms, costs, available models and privacy disclosures; credential access scope; D1/R2 isolation, lifecycle and resource limits; staging app consent UI, auth, denial, real test-provider responses and screenshot proof; then deploy with activation disabled first. Verify no provider calls can occur while disabled. Exercise one synthetic staging request per approved provider only with an explicit budget; don't test on a real social account or publish a post. A public rollout requires actual enrollment identity and an abuse response/rotation process instead of distributing pilot invites broadly. Disable through the feature flag when needed.