Xzero UI
Pro library

Provider keysPro

A settings card for bring-your-own-key AI products. Each provider row shows its real mark, the masked key, a status and when the key was last used. You can reveal a key for five seconds, copy, rotate or remove it with undo. Adding or rotating a key opens an inline form that checks the format as you type, then tests the connection before saving.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/provider-keys
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/provider-keys

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { ProviderKeys } from "@/components/xzero/provider-keys/provider-keys";

// Sample workspace, every test simulated
<ProviderKeys />

// Wired to your API
<ProviderKeys
  keys={keys}
  onKeysChange={setKeys}
  testKey={({ provider, key, signal }) =>
    fetch("/api/provider-keys/test", { method: "POST", body: JSON.stringify({ provider, key }), signal }).then(r => r.json())}
  onSave={(provider, key) => saveKey(provider, key)}
  onRemove={provider => deleteKey(provider)}
/>

API reference

ProviderKeys

A settings card for bring your own key AI products. One row per provider (Anthropic, OpenAI, Google AI, Mistral, xAI) with its real mark, the masked key (sk-ant-••••4f2a), a status as icon plus label (Connected, Invalid, Not set), when the key was last used, and four actions: reveal for five seconds with a countdown ring, copy, rotate and remove with undo. Clicking a status retests the stored key. Add key and Rotate open an inline form under the row that checks the key's format as you type, then shows Testing connection and Connected before the row updates. With no props it renders a sample workspace and simulates every test.

PropTypeDefaultDescription
keysProviderKey[]–Controlled keys: { provider, status: "connected" | "invalid" | "unset", value?, last4?, lastUsedAt?, checkedAt?, error? }. Pass value to enable reveal and copy, or only last4 when your server never returns full keys. Providers without an entry read Not set.
defaultKeysProviderKey[]sample workspaceStarting keys when uncontrolled. Pass [] for the empty state, every row Not set with an Add key button.
onKeysChange(keys: ProviderKey[]) => void–Every change: added, rotated, removed, restored with undo, or retested.
providersProviderId[]["anthropic", "openai", "google", "mistral", "xai"]Which providers get a row, in order.
testKey(request: { provider, key?, signal }) => Promise<KeyTestResult>–Tests a key and resolves { ok: true, detail? } or { ok: false, error }. key is the pasted key when adding or rotating, and missing when retesting a stored key (test it on your server by provider). Aborted when the form closes. Leave it out to simulate: stored invalid keys fail again, everything else connects in under a second.
onSave(provider, key, mode: "add" | "rotate") => void–A new key passed its test. Persist it here; the row already shows it as connected.
onRemove(provider) => void–Fires when the undo window closes, so a removal only reaches your server once it sticks.
onCopy(provider) => void–A key was copied to the clipboard, for an audit log.
revealDurationnumber5000Milliseconds a revealed key stays visible before it masks itself again.
undoDurationnumber5000Milliseconds Undo stays after a removal.
loadingbooleanfalsePlaceholder rows with the real row geometry while keys load.
titleReactNode"Provider keys"Card title.
descriptionReactNode–Line under the title. Falsy hides it.
footerReactNode | null–Quiet line under the list. Defaults to an encryption note; null hides it.
classNamestring–Extra class on the card.

Keyboard interactions

KeysAction
TabMoves through each row's status (retest), reveal, copy, rotate and remove, or Add key on an empty row.
EnterIn the form, saves the key and runs the connection test.
EscapeIn the form, cancels and returns focus to the button that opened it.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in ai

Guidance for AI tools

Provider keys: A settings card for bring-your-own-key AI products. Each provider row shows its real mark, the masked key, a status and when the key was last used. You can reveal a key for five seconds, copy, rotate or remove it with undo. Adding or rotating a key opens an inline form that checks the format as you type, then tests the connection before saving. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components