The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Your keys: a new account finds the paid models and adds its key where it is
Adarshdf0005152234
diff --git a/docs/public-signup.md b/docs/public-signup.mdindex 37ed23d4..8a46cd4f 100644--- a/docs/public-signup.md+++ b/docs/public-signup.md@@ -219,14 +219,18 @@ cloudflared tunnel --url http://localhost:8188 # or: ngrok http 8188## Your keysAn account can add its own fal.ai key or Replicate token in **Settings → Your keys** (below Your-GPU), or from the "Add your key" card that opens when it picks a paid model it has no key for. With+GPU), or from the "Add your key" card that opens when it picks a paid model it has no key for (a+search in a model picker lists them, dimmed, and a link to one keeps it, with a note), from the+locked engine switch, or from "No GPU?" on the welcome page and the Connect your GPU card. Witha key it runs that provider's paid models (Nano Banana, Seedream, Kling, Veo…), billed to its ownaccount with that provider. The studio's own keys are never used for an account's run.- **Checked first.** `PUT /api/account/keys/fal` (or `/replicate`) with `{ key }` checks the keywith the provider before it is saved: a free call that runs nothing (fal.ai: the status of arequest that doesn't exist; Replicate: `GET /v1/account`). A refused key answers 422, a provider- out of reach 502, and nothing is saved. `?test=1` only checks. 10 checks a minute per account,+ out of reach 502, and nothing is saved. A key that works on a provider account with no balance+ left is saved, with a `note` that says to top it up. `?test=1` only checks. Only a check that+ reaches the provider counts: 10 a minute per account, 20 per address (behind a trusted proxy),120 for all accounts together.- **Stored encrypted.** The key is sealed with AES-256-GCM under a server key in`data/secrets.key`, made the first time a key is saved, and kept on the account's record in@@ -242,7 +246,9 @@ account with that provider. The studio's own keys are never used for an account'- **Removed with the account.** Deleting an account (by itself or by the owner) switches it off,stops its running jobs at the provider with its own key, then removes its runs, files and record,keys included. Removing or replacing a key that runs are going on answers 409 `runs-going` first;- with `{ stopRuns: true }` those runs are stopped with the old key before it changes.+ with `{ stopRuns: true }` those runs are stopped with the old key before it changes. A run still+ being handed to the provider is stopped there when its submit lands: the key (or the deleted+ account's record) waits for that, up to a minute.- **What it changes in the studios.** `GET /api/status` lists the account's keys(`viewer.keys`) and its engine mode: `both` while it has a key and the studio isn't open-sourceonly, else `open`. The model pickers dim the paid models it has no key for ("Add your Replicatediff --git a/src/app/(studio)/status/page.tsx b/src/app/(studio)/status/page.tsxindex 9119121f..d53117d3 100644--- a/src/app/(studio)/status/page.tsx+++ b/src/app/(studio)/status/page.tsx@@ -121,15 +121,16 @@ export default async function Page() {<Link href="/connect" className={link}>connect your own ComfyUI</Link>{" "}- (Your GPU): your runs go to your GPU.+ (Your GPU): your runs go to your GPU. Or add your own fal.ai or Replicate key in Settings → Your keys to use paid models like Nano Banana, Kling and+ Veo, billed to your own account with them.</li><li><span className="font-medium">The open engine.</span> Each open-source model runs as a ComfyUI workflow; {workflows.validated} of the {workflows.all} graphs areaccepted by a real ComfyUI. Every preview clip and still on this site was rendered locally on ComfyUI, on one RTX 5090.</li><li>- <span className="font-medium">Your own studio.</span> Fuobe is MIT-licensed. Run it yourself to add the cloud engine: frontier models with your own fal.ai or- Replicate key, next to the open ones.+ <span className="font-medium">Your own studio.</span> Fuobe is MIT-licensed. Run it yourself, with no account limits: the open models on your own GPU and the+ frontier ones on your own fal.ai or Replicate key, all on your own machine.</li></ul></section>diff --git a/src/components/command-palette.tsx b/src/components/command-palette.tsxindex 10d5198a..2047fae9 100644--- a/src/components/command-palette.tsx+++ b/src/components/command-palette.tsx@@ -98,6 +98,7 @@ const LICENCES = SETTING_ENTRIES.find((e) => e.key === "setting:models")!;*/const ACCOUNT_SETTINGS = [visitorSetting("your-gpu", "Your GPU", "/settings#your-gpu", Cpu, "comfyui gpu connect own server open source"),+ visitorSetting("your-keys", "Your keys", "/settings#your-keys", KeyRound, "fal fal.ai replicate api key token paid models nano banana kling veo billing"),visitorSetting("account", "Account", "/settings#account", UserRound, "email sign out delete account"),LICENCES,];diff --git a/src/components/gpu/connect-gpu.tsx b/src/components/gpu/connect-gpu.tsxindex 6629695f..9cfd808f 100644--- a/src/components/gpu/connect-gpu.tsx+++ b/src/components/gpu/connect-gpu.tsx@@ -8,6 +8,7 @@ import { useEffect, useRef } from "react";import { PreflightChecklist } from "@/components/gpu/preflight-checklist";import { ReadinessBoard } from "@/components/gpu/readiness-board";import { ConnectChoice } from "@/components/gpu/connect-choice";+import { KeyInstead } from "@/components/keys/your-keys";import { Button } from "@/components/ui/button";import { Skeleton } from "@/components/ui/skeleton";import { useGpuCheck, useGpuReadiness } from "@/hooks/use-gpu";@@ -143,6 +144,8 @@ export function ConnectGpu() {return (<div className="space-y-6">{header(1)}+ {/* Most people have no ComfyUI to hand: their own fal.ai or Replicate key runs paid models now. */}+ <KeyInstead className="bg-background" /><Card><h2 className="mb-1 text-[16px] font-semibold">Where is ComfyUI running?</h2>{reason === "refused" && <p className="mb-3 text-[13px] text-destructive">Fuobe can't use this address. Connect your own ComfyUI.</p>}diff --git a/src/components/gpu/your-gpu.tsx b/src/components/gpu/your-gpu.tsxindex 5235fb07..21982192 100644--- a/src/components/gpu/your-gpu.tsx+++ b/src/components/gpu/your-gpu.tsx@@ -87,7 +87,7 @@ export function YourGpu() {return (<div className="w-full min-w-0 space-y-4 sm:max-w-[36rem]"><p className="text-[13px] text-muted-foreground">- Free accounts run on their own ComfyUI, never on this studio's keys or GPU. Runs from the Image, Video and Audio studios on open-source models go to it. It must be+ Free accounts run on their own ComfyUI, never on this studio's own keys or GPU. Runs from the Image, Video and Audio studios on open-source models go to it. It must bereachable from the internet, for example through a Cloudflare Tunnel or ngrok in front of your ComfyUI.</p>{gpu ? (diff --git a/src/components/guest-prompt.tsx b/src/components/guest-prompt.tsxindex 9ba60e95..b28b33dd 100644--- a/src/components/guest-prompt.tsx+++ b/src/components/guest-prompt.tsx@@ -7,6 +7,7 @@ import { Suspense, useCallback, useEffect, useState } from "react";import { ConnectChoice } from "@/components/gpu/connect-choice";import type { FindReason } from "@/components/gpu/computer-runner";import { takeGpuRetry } from "@/hooks/use-gpu";+import { KeyInstead } from "@/components/keys/your-keys";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { CONNECT_GPU_EVENT, GUEST_PROMPT_EVENT, refusalCard, signInHref, useStatus, watchGuestRefusals, type RefusalCard } from "@/lib/api";@@ -15,11 +16,12 @@ import { CLOUD_KEY } from "@/lib/your-keys";/*** The cards a public studio shows when something is refused (watchGuestRefusals): "Create a free* account to run this" for a guest (public sign-up, signed out) who tries to generate, upload or- * change anything, and "Connect your GPU to run this" for an account (accounts run only on their- * own ComfyUI, never the owner's keys or GPU). Mounted once, in the app's providers, so it outlives- * the page: a card closes when the page changes (its own Sign up or Log in, Back), and never opens- * on the sign-in page (refusalCard). Opened by a run that was refused, "Connect your GPU" keeps that- * run and starts it by itself once the GPU is connected.+ * change anything, and "Connect your GPU to run this" for an account (accounts run on their own+ * ComfyUI, or their own fal.ai or Replicate key, never the owner's keys or GPU), with "No GPU? Add+ * a key" when it has no key yet. Mounted once, in the app's providers, so it outlives the page: a+ * card closes when the page changes (its own Sign up or Log in, Back), and never opens on the+ * sign-in page (refusalCard). Opened by a run that was refused, "Connect your GPU" keeps that run+ * and starts it by itself once the GPU is connected.*/export function GuestPrompt() {// The last card stays while the dialog animates out.@@ -73,22 +75,12 @@ export function GuestPrompt() {<DialogTitle>{TITLES[reason ?? "run"]}</DialogTitle><DialogDescription>Fuobe runs this on the ComfyUI on your computer. It's free and private.</DialogDescription>{/* Paid models run on the account's own key instead (Your keys), when the studio allows them. */}- {viewer?.kind === "account" && viewer.paidAllowed !== false && (- <p className="text-[13px] text-muted-foreground">- {viewer.keys?.length ? (- `Or switch to Cloud to use your ${viewer.keys.map((k) => CLOUD_KEY[k].label).join(" or ")} key.`- ) : (- <>- Or{" "}- <Link href="/settings#your-keys" onClick={close} className="text-brand-text underline underline-offset-4">- add your own fal.ai or Replicate key- </Link>{" "}- to use paid models.- </>- )}- </p>+ {viewer?.kind === "account" && viewer.paidAllowed !== false && !!viewer.keys?.length && (+ <p className="text-[13px] text-muted-foreground">{`Or switch to Cloud to use your ${viewer.keys.map((k) => CLOUD_KEY[k].label).join(" or ")} key.`}</p>)}</DialogHeader>+ {/* No key yet: "Add a key" opens here, over the studio (this card makes room). */}+ <KeyInstead onOpen={close} /><ConnectChoicefromRun={!!retry}kind={retry?.kind}diff --git a/src/components/keys/your-keys.tsx b/src/components/keys/your-keys.tsxindex 2bf5faba..aa793100 100644--- a/src/components/keys/your-keys.tsx+++ b/src/components/keys/your-keys.tsx@@ -9,7 +9,7 @@ import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";-import { ADD_KEY_EVENT, preferEngine, useViewer } from "@/lib/api";+import { ADD_KEY_EVENT, preferEngine, useStatus, useViewer } from "@/lib/api";import { settingProblem } from "@/lib/connections";import { CLOUD_KEY, CLOUD_PROVIDERS, OPEN_ONLY_MESSAGE, type CloudProvider, type KeyInfo, type YourKeys } from "@/lib/your-keys";import { cn } from "@/lib/utils";@@ -98,14 +98,16 @@ function KeyForm({ provider, replacing, onSaved, onCancel, autoFocus }: { providsetBusy(true);setError(null);try {- const r = await call<KeyInfo & { detail?: string }>(`/api/account/keys/${provider}`, "PUT", { key, ...(stopRuns && { stopRuns: true }) });+ const r = await call<KeyInfo & { detail?: string; note?: string }>(`/api/account/keys/${provider}`, "PUT", { key, ...(stopRuns && { stopRuns: true }) });setKey("");setGoing(null);// The person just asked for paid models: the studios start on Cloud.preferEngine("cloud");changed();const who = provider === "replicate" && r.detail?.startsWith("Signed in as ") ? ` (${r.detail.replace("Signed in as ", "signed in as ")})` : "";- toast.success(`Your ${p.label} key works${who}. Paid models on ${p.label} are ready.`);+ // A key that works on a provider account with nothing on it yet: saved, and the next step said.+ if (r.note) toast.warning(r.note, { duration: 10_000 });+ else toast.success(`Your ${p.label} key works${who}. Paid models on ${p.label} are ready.`);onSaved(r);} catch (e) {const k = e as KeyError;@@ -196,7 +198,8 @@ function KeyCard({ provider, info }: { provider: CloudProvider; info: KeyInfo |};return (- <div className="grid gap-3 rounded-xl border p-4">+ // content-start: a taller card beside it (an error under its field) doesn't spread this one's rows apart.+ <div className="grid content-start gap-3 rounded-xl border p-4"><div className="flex items-start justify-between gap-3"><div className="min-w-0"><h3 className="text-[14px] font-medium">{p.label}</h3>@@ -291,7 +294,7 @@ export function AccountKeysSection({ prices }: { prices?: string }) {</li>)}<li>Runs with your key send your prompt and the files you attach to that provider.</li>- <li>Account limits still apply: 4 runs at once, 60 an hour, up to 4 pictures a run, 3 GB of files.</li>+ {q.data && <li>Account limits still apply: {q.data.limits}.</li>}</ul>{q.data && !q.data.paidAllowed && <p className="rounded-lg bg-muted px-3 py-2 text-[13px] text-muted-foreground">{OPEN_ONLY_MESSAGE}</p>}{q.isError ? (@@ -310,6 +313,34 @@ export function AccountKeysSection({ prices }: { prices?: string }) {);}+/**+ * "No GPU? Add your own key": for an account with no key yet, on a studio that allows paid models (nothing for anyone+ * else). The button opens "Add your fal.ai key" where the person is; `onOpen` first (a card closing to make room).+ */+export function KeyInstead({ onOpen, className }: { onOpen?: () => void; className?: string }) {+ const v = useStatus().data?.viewer;+ if (v?.kind !== "account" || v.paidAllowed === false || v.keys?.length) return null;+ return (+ <div className={cn("flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-dashed px-3 py-2.5 text-[13px]", className)}>+ <KeyRound aria-hidden className="mt-0.5 size-4 shrink-0 self-start text-brand-text" />+ <p className="min-w-0 flex-1 basis-56 text-muted-foreground">+ <span className="font-medium text-foreground">No GPU?</span> Add your own fal.ai or Replicate key to use paid models like Nano Banana, Kling and Veo, billed to your+ account with them.+ </p>+ <Button+ size="sm"+ variant="secondary"+ onClick={() => {+ onOpen?.();+ openAddKey("fal");+ }}+ >+ Add a key+ </Button>+ </div>+ );+}+/*** "Add your fal.ai key": opens from a dimmed model in a picker, a paid run the server refused (403 add-key), or an* "Add a key" link. Once the key is saved it closes, and the model it was opened for is picked (never run: the person@@ -338,9 +369,23 @@ export function AddKeyPrompt() {<DialogTitle>Add your {p.label} key</DialogTitle><DialogDescription>Runs on {p.label} are billed to your own {p.label} account. Fuobe checks the key with {p.label}, then stores it encrypted on this server.+ {/* Opened for no model in particular: either provider will do. */}+ {!ask.modelId && (+ <>+ {" "}+ <button+ type="button"+ onClick={() => setAsk({ provider: ask.provider === "fal" ? "replicate" : "fal" })}+ className="text-brand-text underline-offset-2 hover:underline"+ >+ {ask.provider === "fal" ? "Have a Replicate token instead?" : "Have a fal.ai key instead?"}+ </button>+ </>+ )}</DialogDescription></DialogHeader><KeyForm+ key={ask.provider}provider={ask.provider}autoFocusonSaved={() => {diff --git a/src/components/owner-settings.tsx b/src/components/owner-settings.tsxindex a2715059..c059949d 100644--- a/src/components/owner-settings.tsx+++ b/src/components/owner-settings.tsx@@ -16,7 +16,7 @@ export function SettingsIntro() {if (!hydrated || !v) return null;if (v.owner)return "Choose open source, paid APIs or both, connect providers, point Fuobe at your ComfyUI server, and choose how prompts get enhanced. Keys stay on this server.";- return v.account ? "Your account and your GPU. The studio's own settings, keys and tokens are its owner's." : "Create a free account and connect your own GPU.";+ return v.account ? "Your account, your GPU and your own keys. The studio's own settings are its owner's." : "Create a free account and connect your own GPU.";}/**@@ -114,7 +114,7 @@ function AccountSection({ email }: { email: string }) {<p className="mt-1 text-[13px] [overflow-wrap:anywhere] text-muted-foreground">{email}</p></div><div className="min-w-0 space-y-2">- <p className="max-w-xl text-[13px] text-muted-foreground">Deleting your account removes your uploads, your runs and their files, and your GPU connection, and signs you out. It can't be undone.</p>+ <p className="max-w-xl text-[13px] text-muted-foreground">Deleting your account removes your uploads, your runs and their files, your GPU connection and your saved fal.ai and Replicate keys, and signs you out. It can't be undone.</p><Button size="sm" variant="outline" className="text-destructive" onClick={() => setOpen(true)}><Trash2 /> Delete account</Button>diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsxindex c6420b76..769a45e1 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -6,6 +6,7 @@ import Link from "next/link";import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import { flushSync } from "react-dom";import { toast } from "sonner";+import { openAddKey } from "@/components/keys/your-keys";import { Button } from "@/components/ui/button";import { Kbd } from "@/components/ui/kbd";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";@@ -320,10 +321,21 @@ export function Composer({ docked }: { docked: boolean }) {// the engine changes; the same Original on the other engine takes that engine's defaults (480p on the GPU, 720p in the// cloud) for the settings the person left alone.const seen = useRef<{ engine: Engine; model?: ModelDef }>({ engine, model });+ // An account's paid model it has no key for yet (from a link, ⌘K or a Reuse) stays picked while its switch is held on+ // open source: the note under the composer says how to run it, where a swap to an open model would say nothing. The+ // studio's untouched cloud default still gives way, unless the link names it. Until the status is known, it waits.+ const heldForKey =+ !!model &&+ !lockedModel &&+ model.engine !== "open" &&+ engine === "open" &&+ engineMode === "open" &&+ (!status || (!!needsKey(model, status) && status.viewer?.paidAllowed !== false));useEffect(() => {const before = seen.current;seen.current = { engine, model };if (!model) return;+ if (heldForKey && (model.id !== config.defaultModels.cloud || new URLSearchParams(window.location.search).get("model") === model.id)) return;const next = engineSwitchModel({ model, preset, engine, from: before.engine, defaults });const m = next ? catalog.getModel(next) : undefined;if (!m) {@@ -340,7 +352,7 @@ export function Composer({ docked }: { docked: boolean }) {// replaced it, and swapping it for the engine's default would undo the link (it landed on Z-Image Turbo).const route = m.id === presetModel(preset, engine) ? presetParams(preset, engine) : {};setDraft((d) => (d.modelId !== model.id ? {} : { modelId: m.id, params: { ...m.defaults, ...route, numOutputs: d.params.numOutputs, enhancePrompt: d.params.enhancePrompt }, ...lookCleared(model, m) }));- }, [engine, model, preset, defaults, setDraft, catalog]);+ }, [engine, model, preset, defaults, setDraft, catalog, heldForKey, config.defaultModels.cloud]);// Where the server can't write Ideogram 4's caption (writesCaptions), the studio's untouched default moves to its stand-in// once the status is known. Ideogram 4 picked after that stays.@@ -550,9 +562,13 @@ export function Composer({ docked }: { docked: boolean }) {openGpuSetup({ ref: gpuRef, name: preset?.open ? preset.name : model?.name });};+ // An account's paid model it has no key for yet: Generate asks for the key (the note below says so too).+ const keyToAdd = model && status?.viewer?.paidAllowed !== false ? needsKey(model, status)?.[0] : undefined;+// `skip` is true only from the guided fix's "Run anyway" (a click handler passes its event here).const submit = (skip?: unknown) => {const skipGpu = skip === true;+ if (keyToAdd && model && !create.isPending) return openAddKey(keyToAdd, model.id);if (!blocker && gpuSetup && !skipGpu && !create.isPending) return openGpuFix();if (blocker || create.isPending || signature.lock.isPending) {if (blocker) {@@ -1221,6 +1237,16 @@ export function Composer({ docked }: { docked: boolean }) {)}</div>)}+ {keyToAdd && model && (+ <div role="note" className="mx-1 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1.5 rounded-xl border border-dashed px-3 py-2 text-[12px] leading-snug text-muted-foreground">+ <p className="min-w-0 flex-1 basis-56">+ {model.name} runs on {CLOUD_KEY[keyToAdd].label}, billed to your own {CLOUD_KEY[keyToAdd].label} account. Add your {CLOUD_KEY[keyToAdd].label} key to run it.+ </p>+ <Button size="sm" variant="secondary" className="h-7" onMouseDown={(e) => e.preventDefault()} onClick={() => openAddKey(keyToAdd, model.id)}>+ Add key+ </Button>+ </div>+ )}{sketched.note && <p className="px-2 pt-1 text-[12px] text-muted-foreground">{sketched.note}</p>}{signed.notes.length > 0 && <p className="px-2 pt-1 text-[12px] text-muted-foreground">{signed.notes.join(" · ")}</p>}{model && op && model.options.endFrame === undefined && draft.slots.endImage?.ref && (diff --git a/src/components/studio/engine-switch.tsx b/src/components/studio/engine-switch.tsxindex 64bcc2b8..89be82c1 100644--- a/src/components/studio/engine-switch.tsx+++ b/src/components/studio/engine-switch.tsx@@ -2,6 +2,7 @@import { Cloud, Cpu, Lock } from "lucide-react";import Link from "next/link";+import { openAddKey } from "@/components/keys/your-keys";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import type { Engine } from "@/lib/catalog/types";import { useEngineMode, useStatus, useViewer } from "@/lib/api";@@ -48,14 +49,26 @@ export function EngineSwitch({<><o.icon className="size-3.5" /><span className={cn(compact && "hidden sm:inline")}>{text}</span>+ {/* A phone has room for two words: what to do about the lock. */}+ {compact && locked?.addKey && <span className="sm:hidden">Add key</span>}</>);- // An account opens Your keys (or Your GPU) from here: the way to paid models is its own key.+ // An account opens "Add your key" right here (a plain click; Settings → Your keys in a new tab), or Your GPU when+ // the studio runs open-source models only: the way to paid models is its own key.if (locked) {return (<Tooltip><TooltipTrigger asChild>- <Link href={locked.href} aria-label={`${text}. ${locked.tip}`} className={cn(cls, "hover:text-foreground")}>+ <Link+ href={locked.href}+ aria-label={`${text}. ${locked.tip}`}+ className={cn(cls, "hover:text-foreground")}+ onClick={(e) => {+ if (!locked.addKey || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;+ e.preventDefault();+ openAddKey("fal");+ }}+ >{body}<Lock className="size-3 opacity-60" /></Link>diff --git a/src/components/studio/feed.tsx b/src/components/studio/feed.tsxindex fd4a9570..3e83dcdf 100644--- a/src/components/studio/feed.tsx+++ b/src/components/studio/feed.tsx@@ -325,7 +325,12 @@ export const GenerationGroup = memo(function GenerationGroup({ g, newest }: { g:</span>))}<span className="before:mr-1.5 before:content-['·']">{timeAgo(g.createdAt)}</span>- {g.costUsd ? <span className="font-mono before:mr-1.5 before:content-['·']">{formatCost(g.costUsd)}</span> : null}+ {/* A run its provider never took (a refused key, an empty balance) cost nothing: said, not priced. */}+ {g.costUsd && g.notBilled ? (+ <span className="before:mr-1.5 before:content-['·']">Not billed</span>+ ) : g.costUsd ? (+ <span className="font-mono before:mr-1.5 before:content-['·']">{formatCost(g.costUsd)}</span>+ ) : null}</p></div><div className="flex shrink-0 items-center gap-0.5 opacity-100 transition-opacity sm:opacity-0 sm:group-hover/gen:opacity-100 sm:focus-within:opacity-100 [@media(hover:none)]:opacity-100">diff --git a/src/components/studio/model-picker.tsx b/src/components/studio/model-picker.tsxindex 813031e8..0d9e1bd9 100644--- a/src/components/studio/model-picker.tsx+++ b/src/components/studio/model-picker.tsx@@ -106,7 +106,14 @@ function ModelRow({{m.name}{starred && <span className="sr-only">, starred</span>}</span>- <ModelBadges model={m} max={2} />+ {/* A dimmed row on a phone: the name first (its badges would cut it to "Na…"). */}+ {needs ? (+ <span className="contents max-sm:hidden">+ <ModelBadges model={m} max={2} />+ </span>+ ) : (+ <ModelBadges model={m} max={2} />+ )}{gpu && <RowDot badge={gpu} gpu={gpuName} />}{showEngine && (<span className="inline-flex shrink-0 items-center gap-0.5 rounded-[4px] bg-muted px-1 text-[10px] leading-4 font-medium text-muted-foreground">@@ -126,7 +133,11 @@ function ModelRow({)}</span>{needs ? (- <span className="shrink-0 text-right text-[11px] font-medium text-brand-text">{addKeyLabel(needs[0])}</span>+ // On a phone the short words, so the model's name keeps its room.+ <span className="shrink-0 text-right text-[11px] font-medium text-brand-text">+ <span className="sm:hidden">Add key</span>+ <span className="max-sm:hidden">{addKeyLabel(needs[0])}</span>+ </span>) : (<span className="shrink-0 text-right text-[11px] text-muted-foreground tabular-nums">{pickerPrice(m, today)}</span>)}@@ -172,18 +183,28 @@ interface PickerProps {export function ModelPicker(props: PickerProps) {const [open, setOpen] = useState(false);const { value, models, onChange } = props;- // The model a dimmed row was chosen for: picked once its key is saved (by this picker only).+ // The model a dimmed row was chosen for (by this picker only): picked once its key is saved and the studio knows it+ // (the status has the key, so the engine switch is on Cloud and nothing swaps the model back to an open one).const waiting = useRef<string | null>(null);+ const saved = useRef<string | null>(null);useEffect(() => {const added = (e: Event) => {const id = (e as CustomEvent<{ modelId?: string }>).detail?.modelId;- const m = id && id === waiting.current ? models.find((x) => x.id === id) : undefined;+ if (id && id === waiting.current) saved.current = id;waiting.current = null;- if (m) onChange(m);};window.addEventListener(KEY_ADDED_EVENT, added);return () => window.removeEventListener(KEY_ADDED_EVENT, added);- }, [models, onChange]);+ }, []);+ // (Saving a key refreshes the status, which runs this again.)+ const status = useStatus().data;+ const mode = useEngineMode();+ useEffect(() => {+ const m = saved.current ? models.find((x) => x.id === saved.current && !needsKey(x, status) && (x.engine === "open" || mode !== "open")) : undefined;+ if (!m) return;+ saved.current = null;+ onChange(m);+ }, [models, status, mode, onChange]);return (<ResponsivePanelopen={open}@@ -243,14 +264,27 @@ function PickerList({const noneForEngine = !q && !models.some((m) => m.engine === engine);// An account (public sign-up): paid models it has no key for are dimmed; choosing one asks for the key first.- const keys = status?.viewer?.kind === "account" ? (status.viewer.keys ?? []) : null;+ const viewer = status?.viewer?.kind === "account" ? status.viewer : null;+ const keys = viewer ? (viewer.keys ?? []) : null;const payer = keys?.length && engine === "cloud" ? keys : null;+ // With no key yet it is on open models only: a search lists the paid models it matches too (dimmed), so "nano+ // banana" finds Nano Banana and the way to run it.+ const keyless = !!viewer && !keys?.length && viewer.paidAllowed !== false;+ const paid = useMemo(+ () => (keyless && q.trim() && !engines.includes("cloud") ? (groupModels({ models, engine: "cloud", engines: ["cloud"], query: q, recent: [], starred: [], best: [] }).groups[0]?.models ?? []) : []),+ [keyless, q, engines, models],+ );+ const listed = paid.length ? [...groups, { id: "paid" as const, label: "Paid models · with your own key", models: paid }] : groups;const pick = (m: ModelDef) => {const needs = needsKey(m, status);if (needs && onNeedsKey) return onNeedsKey(m, needs[0]);onChange(m);onPicked();};+ const addKey = () => {+ onPicked();+ openAddKey("fal");+ };return (<Command shouldFilter={false} loop label="Models" onKeyDown={(e) => starKey(e, (id) => setStarred((s) => toggleIn(s, id)))} className="rounded-none! bg-transparent p-0">@@ -261,18 +295,31 @@ function PickerList({<EngineSwitch value={engine} onChange={onEngineChange} size="sm" /></div><div className="flex items-baseline gap-x-2 px-3 pb-1.5 leading-snug text-[11px] text-muted-foreground sm:px-3.5">- <span className="shrink-0 whitespace-nowrap tabular-nums">{q ? `${count} result${count === 1 ? "" : "s"}` : `${count} ${engine === "open" ? "open-source" : "cloud"} model${count === 1 ? "" : "s"}`}</span>- {keys && engine === "cloud" && (+ <span className="shrink-0 whitespace-nowrap tabular-nums">+ {q ? `${count + paid.length} result${count + paid.length === 1 ? "" : "s"}` : `${count} ${engine === "open" ? "open-source" : "cloud"} model${count === 1 ? "" : "s"}`}+ </span>+ {payer ? (<><span aria-hidden>·</span><span className="min-w-0">- {payer ? `Paid models are billed to ${payer.length > 1 ? "your fal.ai and Replicate accounts" : billedTo(payer[0])}` : "Add a fal.ai or Replicate key to run paid models"}- {" · "}+ {`Paid models are billed to ${payer.length > 1 ? "your fal.ai and Replicate accounts" : billedTo(payer[0])} · `}<Link href="/settings#your-keys" className="text-brand-text underline underline-offset-2">- {payer ? "Your keys" : "Add a key"}+ Your keys</Link></span></>+ ) : (+ keyless && (+ <>+ <span aria-hidden>·</span>+ <span className="min-w-0">+ Paid models like Nano Banana and Kling need your own fal.ai or Replicate key ·{" "}+ <button type="button" onClick={addKey} className="text-brand-text underline underline-offset-2">+ Add a key+ </button>+ </span>+ </>+ ))}{demo && !keys && (<>@@ -290,7 +337,7 @@ function PickerList({</span></div><CommandList className="max-h-[min(52vh,420px)] border-t sm:max-h-[min(56vh,440px)]">- {groups.map((g) => (+ {listed.map((g) => (<CommandGroup key={g.id} heading={g.label}>{g.models.map((m) => (<CommandItem@@ -305,7 +352,7 @@ function PickerList({m={m}selected={value?.id === m.id}starred={starred.includes(m.id)}- showEngine={!!q || m.engine !== engine}+ showEngine={g.id !== "paid" && (!!q || m.engine !== engine)}today={today}onStar={() => setStarred((s) => toggleIn(s, m.id))}gpu={m.engine === "open" ? badgeFor(badges, { modelId: m.id }) : null}@@ -316,7 +363,7 @@ function PickerList({))}</CommandGroup>))}- {!groups.length && (+ {!listed.length && (<div className="flex flex-col items-center gap-2 px-4 py-10 text-center"><SearchX className="size-5 text-subtle-foreground" />{noneForEngine ? (diff --git a/src/lib/composer.ts b/src/lib/composer.tsindex 455e4b77..733fcb54 100644--- a/src/lib/composer.ts+++ b/src/lib/composer.ts@@ -952,7 +952,7 @@ export function studioBest(models: ModelDef[], engine: Engine, defaultId: string}export interface ModelGroup {- id: "recent" | "starred" | "best" | "all" | "results";+ id: "recent" | "starred" | "best" | "all" | "results" | "paid";label: string;models: ModelDef[];}diff --git a/tests/command-palette.test.ts b/tests/command-palette.test.tsindex 865ce99d..8a6c76de 100644--- a/tests/command-palette.test.ts+++ b/tests/command-palette.test.ts@@ -209,11 +209,15 @@ describe("palette index", () => {});describe("palette settings by viewer", () => {- it("offers the install's settings to its owner only; a visitor gets its own GPU, its account and the licences", async () => {+ it("offers the install's settings to its owner only; an account gets its own GPU, its own keys, its account and the licences", async () => {const { settingEntries } = await import("@/components/command-palette");const hrefs = (v: Parameters<typeof settingEntries>[0]) => settingEntries(v).map((e) => e.href);expect(hrefs({ owner: true })).toEqual(expect.arrayContaining(["/settings#engine", "/settings#cloud", "/settings#security", "/settings/models"]));- expect(hrefs({ owner: false, account: { email: "[email protected]" } })).toEqual(["/settings#your-gpu", "/settings#account", "/settings/models"]);+ expect(hrefs({ owner: false, account: { email: "[email protected]" } })).toEqual(["/settings#your-gpu", "/settings#your-keys", "/settings#account", "/settings/models"]);+ // "api key", "fal", "nano banana": an account finds where its own key goes.+ const keys = settingEntries({ owner: false, account: { email: "[email protected]" } }).find((e) => e.href === "/settings#your-keys");+ expect(keys?.keywords).toMatch(/api key/);+ expect(keys?.keywords).toMatch(/nano banana/);expect(hrefs({ owner: false })).toEqual(["/connect", "/settings/models"]);// Not known yet: nothing of the owner's.expect(hrefs(undefined)).toEqual(["/connect", "/settings/models"]);