# key.direct Prepaid AI API keys. Budgets start at $1. Pay with Link (the Link email owns the key), or use paid dots credits. The current key.direct limit is $250 of new key budget across all buyers per UTC day, including gifts and top-ups. The limit resets at midnight UTC. A price quote does not reserve capacity. An order over the remaining allowance returns HTTP 429 with error daily_budget_exceeded. Try a smaller budget or after the reset. ## Browser agents (WebMCP) Open an HTML page on key.direct or credits.gift in a browser with WebMCP enabled. The site registers tools using document.modelContext and offers account tools on their corresponding pages after sign-in. For local Chrome testing, enable chrome://flags/#enable-webmcp-testing and relaunch. - key_direct_get_site_links finds purchase, gifts, My keys, usage, connections, events, teams, the key tester, and integration docs. - key_direct_quote_key takes { amount_usd } and returns the live price in USD cents for one key, with separate totals for Link/card and paid dots credits. The card quote excludes discounts and any credits already on the account. Checkout checks capacity and the final amount. - key_direct_get_checkout_link takes { amount_usd, kind? } (key or gift) and returns a link that opens the review form. - key_direct_prepare_checkout fills the purchase form when it is available. It takes { amount_usd, kind?, recipients? }. For gifts, use kind=gift and up to ten email addresses or dots @usernames. Each recipient gets a key of that budget. - key_direct_get_my_keys, key_direct_get_usage_report, and key_direct_get_teams read the signed-in information already loaded on those pages. Example: ask the browser agent to quote a $5 key and prepare it for review. The buyer continues through the website to pay or apply credits. After purchase the site displays the key for the buyer. WebMCP responses omit API keys and payment credentials. For an app that needs to receive a key programmatically, use Connect below. For agents without browser tools, open https://key.direct/?amount=5 to review a purchase or https://credits.gift/?amount=5 to prepare a gift. Use the existing HTTP APIs below for explicit integrations. ## Connect (get a key inside your app, no pasting) An OAuth-style PKCE flow. The user signs in (dots.id, or just an email paid with Link), picks one of their keys or makes a new one, and taps Allow. Your app gets a one-time code, never the key in a URL, and trades it for the key. What your app needs (checklist): - A client_id registered with key.direct. Send: app name, homepage, client_id you want, every exact redirect URI (native: a custom scheme like foodboard://key; web: an https page like https://foodboard.xyz/key), and the https origins allowed to iframe it (only if you use display=iframe). No self-serve form yet: ask key.direct to add you. Redirect URIs must match exactly (no prefixes, no extra query). - Native (Expo / React Native): the URL scheme declared in app.json ("scheme": "foodboard"), plus expo-web-browser, expo-crypto and expo-secure-store. Use a development or store build; a custom scheme does not round-trip in Expo Go. - Web: the https redirect page must load https://key.direct/embed.js and call keyDirect.finishConnect() (used when a popup is blocked). Open Connect from a user tap so the popup is allowed. - No backend and no client secret: PKCE is the proof, and /api/token and /api/keys/{id} allow cross-origin calls. If you have a backend you can do step 5 there instead. - Storage: keep { id, key } together in secure storage (keychain / SecureStore; on the web, wherever you keep other API secrets). Never put the key in a URL, log or analytics event. - Screens: a "Connect key.direct" button (signed-in dots users: add login=dots; others: login=email), a credits row from step 8 with a Manage link, and Disconnect (step 7). - Your user needs either a dots.id account with paid credits, or an email and a card / Link. The minimum budget is $1, subject to the shared daily limit. 1. Get your app registered with key.direct (client_id, exact redirect URIs, optional iframe origins). Example: client_id foodboard, redirect URIs foodboard://key and https://foodboard.xyz/key, frame origin https://foodboard.xyz. Registered today: foodboard, curators (curators.app), meshcast (meshcast.org), publicbrand (publicbrand.software); each has ://key and https:///key, frame origin https:// (tell key.direct if yours differ). 2. Make a PKCE pair: code_verifier = 43-128 random URL-safe chars; code_challenge = base64url(sha256(code_verifier)), no padding. 3. Open as a sheet over your app (not an iframe): https://key.direct/connect?client_id=foodboard&redirect_uri=foodboard://key&state=RANDOM&code_challenge=CHALLENGE&code_challenge_method=S256 Optional: amount=5 (suggested budget in USD, starting at $1, subject to the shared daily limit), label=name, login=dots (go straight to dots.id) or login=email (skip to email + Link), display=page|popup|iframe, provider=gfx (a prepaid gfx_ key for gfx.bot and vctr.li instead of an AI Gateway key; dots.id sign-in only, token answers provider "gfx", base_url https://a.gfx.bot/v1, env GFX_API_KEY). 4. key.direct redirects to your registered URI only: foodboard://key?code=kdc_…&state=RANDOM (or ?error=access_denied&state=… on Cancel). Check state. 5. POST https://key.direct/api/token JSON or form: { "code": "kdc_…", "code_verifier": "…", "client_id": "foodboard" } → { "key": "", "id": "kd_", "label": "foodboard", "expires_at": null, "provider": "vercel", "base_url": "https://ai-gateway.vercel.sh/v1", "env": "AI_GATEWAY_API_KEY", "budget_usd": 5, "remaining_usd": 5 } Codes work once, for 5 minutes, and need the matching verifier. A wrong try burns the code. Errors are { error, error_description }: invalid_grant, invalid_request, unauthorized_client, upstream_failed (retry the whole flow). 6. Store the key in the device keychain / secure storage. Use it as AI_GATEWAY_API_KEY (Vercel AI Gateway; with the AI SDK no base URL is needed). It never expires; it stops when its budget is spent or it is disconnected. 7. Disconnect: DELETE https://key.direct/api/keys/{id} with Authorization: Bearer → { id, disconnected: true }. A dots account key's unspent budget goes back as credits; an email key keeps its budget for the owner's emailed link. 8. Credits view: GET https://key.direct/api/keys/{id} with Authorization: Bearer → { id, label, status: "active"|"spent"|"disconnected", budget_usd, spent_usd, remaining_usd, manage_url }. Show remaining_usd in your settings screen and link manage_url ("Manage" = top up, split, rotate, revoke on key.direct). status "disconnected" means the owner replaced or revoked the secret: run Connect again. Spend shows up ~20s late. Web drop-in: keyDirect.creditsCard("#ai-credits", { id, key }) renders what is left, a bar, Manage and Disconnect (refreshes every minute). Data only: await keyDirect.credits(id, key). Key ids always start with kd_. The secret itself is a Vercel AI Gateway key (its format is Vercel's); detect key.direct keys by the kd_ id you stored next to it. If the user picks a key they already had, your app gets a fresh secret for it and the old secret stops working elsewhere (the sheet says so). Expo / React Native (expo-web-browser opens an auth sheet: ASWebAuthenticationSession on iOS, Custom Tabs on Android; it shares the browser's dots.id sign-in): import * as WebBrowser from "expo-web-browser"; import * as Crypto from "expo-crypto"; const b64url = (s) => s.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); const verifier = b64url(btoa(String.fromCharCode(...Crypto.getRandomBytes(48)))); const challenge = b64url(await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, verifier, { encoding: Crypto.CryptoEncoding.BASE64 })); const state = Crypto.randomUUID(); const url = "https://key.direct/connect?client_id=foodboard&redirect_uri=" + encodeURIComponent("foodboard://key") + "&state=" + state + "&code_challenge=" + challenge + "&code_challenge_method=S256&login=dots"; const res = await WebBrowser.openAuthSessionAsync(url, "foodboard://key"); if (res.type === "success") { const q = new URL(res.url).searchParams; if (q.get("state") !== state || !q.get("code")) throw new Error(q.get("error") || "cancelled"); const key = await fetch("https://key.direct/api/token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ code: q.get("code"), code_verifier: verifier, client_id: "foodboard" }) }).then((r) => r.json()); // await SecureStore.setItemAsync("key.direct", JSON.stringify({ id: key.id, key: key.key })); } (expo-auth-session's AuthRequest with usePKCE works too: authorizationEndpoint https://key.direct/connect, tokenEndpoint is not OAuth-standard here, so do step 5 yourself.) Exact: use your app's system authentication session, register its exact callback URI, and use the same PKCE and state checks. Call /api/token directly and store the returned key and id together in secure storage. The token response uses key as its credential field. Web (popup sheet, code posted only to your registered https origin): const key = await keyDirect.connect({ clientId: "foodboard", redirectUri: "https://foodboard.xyz/key", amount: 5 }); await keyDirect.disconnect(key.id, key.key); If the popup is blocked it redirects to key.direct; on your redirect page call keyDirect.finishConnect(). iframe (optional): only origins the app registered may frame https://key.direct/connect?…&display=iframe&origin=https://foodboard.xyz (Content-Security-Policy frame-ancestors per client). Sign-in and payment open in a small key.direct window; the frame then posts { type: "key.direct:connect", code, state } to window.parent, only to that origin. Listen with: addEventListener("message", (e) => e.origin === "https://key.direct" && e.data?.type === "key.direct:connect" && …). ## Links - https://key.direct/20 preselects a $20 key. Cent amounts work too, for example /12.50. Checkout applies the shared daily limit. - Query params: amount (or usd), code (a discount code), email (prefills Link), label (the key's name), provider (vercel, or gfx for a prepaid gfx_ key; gfx needs dots.id sign-in and can't be gifted), pay=1 (open Link checkout at once). - Example: https://key.direct/50?code=FRIENDS&pay=1 ## Usage - key.direct/use (by app), /connections (by caller), /events (direct, MCP events, harnesses, routines): signed in with dots.id, per key. - Tag requests so they show up: header ai-reporting-tags: app:,from:,via:direct|mcp_event|harness|routine (or providerOptions.gateway.tags). - AI SDK apps: createGateway({ headers: { "ai-reporting-tags": "app:myapp,from:my-host,via:direct" } }), or set it as globalThis.AI_SDK_DEFAULT_PROVIDER so bare model ids carry the tags. - fx (fx.sh): set AI_GATEWAY_API_KEY to your key.direct key. fx can't send tags on its built-in gateway connection yet, so its use shows as Other. ## Teams (team.key.direct) - A dots org funds one pool. Each active member gets their own capped key with a monthly allowance from it; keys refill to the allowance on the 1st and unused budget stays in the pool. Members come from the dots org; someone who leaves loses their key within the hour. - key.direct/team (team.key.direct and org.key.direct redirect here). Admins never see a member's secret; only the member gets or replaces their own key. - API on https://www.dots.id (scope keys:team for apps, e.g. shop0): GET /api/keys/teams/{org}/seats/{member|me} (allowanceCents, usedCents, leftCents, resetsAt; code allowance_empty + fallback pute when empty), PUT/DELETE the same path (admins), POST .../seats/me/claim (the member's own key), POST .../seats/{member}/charge { cents, kind: sandbox|browser|other, requestId } (402 allowance_empty when empty), GET /api/keys/teams/{org}/use. - Tag team requests with ai-reporting-tags: app:,subagent:,routine:. - groupMCP rooms linked to the org get group.credits and group.keys. Asks and admin changes from agents wait for an admin to approve on key.direct/team. ## Embed - adds a buy button. data-target="#el" puts it in an element; data-button="none" adds none. - Any element with data-key-direct data-amount="10" becomes a buy button. - From code: keyDirect.open({ amount: 20, code, email, label }), keyDirect.link({...}), keyDirect.button(el, {...}). Checkout and the key stay in a key.direct window. - Env: put the key in AI_GATEWAY_API_KEY. The AI SDK and Vercel AI Gateway clients read it as is, with no base URL to set. OpenRouter keys go in OPENROUTER_API_KEY. - Providers: Vercel AI Gateway (https://ai-gateway.vercel.sh); gfx (prepaid gfx_ keys for gfx.bot + vctr.li, https://a.gfx.bot/v1, GFX_API_KEY; signed-in dots.id only, no gifts; revoke refunds what is left as dots credits); OpenRouter when enabled. - Send gives a key (what is left on it) to an email or a dots @username; the sender's secret stops working. Top up raises the same key's budget. Rotate gives a new secret with the remaining budget. Split turns what is left into smaller keys ($1 minimum each), free. Revoke returns the unspent budget as dots credits. - API on https://www.dots.id (dots OAuth token, scope pute:spend): GET/POST /api/keys, GET/DELETE /api/keys/{id}, POST /api/keys/{id}/topup, /rotate, /split, POST /api/keys/checkout, GET /api/keys/providers - Connect API (what key.direct/api/token and DELETE key.direct/api/keys/{id} call): POST /api/keys/connect/authorize, POST /api/keys/connect/token, DELETE /api/keys/connect/{id}, GET /api/keys/connect/clients/{client_id} - No sign-in: GET /api/keys/guest/quote?usd=20&code=X, POST /api/keys/guest/checkout { usd, code?, email?, label? }