Skip to content
TuffTasks, docs and chat for teams and AI agents

Conversation

Model Picker

Model choice from a composer pill as a real comparison — search, providers, speed, price and context bars, capability badges, a pick for the task, and what this chat would cost.

1 variantMIT

Preview

checkout-1.pngcheckout-2.pngcheckout-3.png

Review the checkout flow in these screenshots and file an issue for anything broken.

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://tuffui.com/r/model-picker.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { ModelPicker } from "@/components/ui/model-picker";

// In the composer's bottom row, next to Attach and Send.
export function ComposerModel({ chat, catalog }: Props) {
  return (
    <ModelPicker
      models={catalog.map((m) => ({
        id: m.id,
        name: m.displayName, // "Vela"
        provider: m.vendor, // "Meridian" → monogram "M"
        speed: m.tokensPerSecond,
        price: { input: m.usdPer1MIn, output: m.usdPer1MOut },
        context: m.contextWindow,
        capabilities: m.capabilities, // ["vision", "tools"]
      }))}
      value={chat.model}
      onValueChange={chat.setModel}
      // Tokens so far: each row prices this conversation on that model.
      usage={{ input: chat.usage.inputTokens, output: chat.usage.outputTokens }}
      // From your router: the best fit for what's in the chat.
      recommended={{ id: "vela", reason: "reads screenshots, ¼ the cost" }}
      requires={
        chat.images.length
          ? [{ capability: "vision", reason: `can't read the ${chat.images.length} images` }]
          : []
      }
    />
  );
}

Props

PropTypeDefaultDescription
models*PickerModel[]—Every model, grouped by `provider` in the order given. Speed is drawn on a linear scale, price (input and output blended 3:1) and context on log scales, each as five segments across all models.
valuestring—Controlled selected model id. Shown in the pill with a check in the list.
defaultValuestringmodels[0].idStarting model when uncontrolled.
onValueChange(id: string) => void—Called when a row is clicked or picked with Enter. The panel closes.
openboolean—Controlled open state. Opening from the pill focuses search; opening from props doesn't steal focus.
defaultOpenbooleanfalseStarting open state when uncontrolled.
onOpenChange(open: boolean) => void—Called on the pill, Escape, a pick, or a press outside.
highlightedstring | null—Controlled highlighted row: the one the cost preview and details are for. Hover and ↑ ↓ move it.
onHighlightChange(id: string | null) => void—Called when the highlight moves.
recommended{ id: string; reason: string }—Pinned at the top under "Recommended for this task", tinted, with the reason.
usage{ input: number; output: number }—Tokens this conversation has used. Shows "This chat: $1.15 → $0.27 −76%" for the highlighted model, rolling as the highlight moves. Omit to hide the footer.
requiresModelRequirement[][]What this chat needs, e.g. vision for attached images. Rows without it show a struck warning badge, and the footer says why.
side"top" | "bottom""top"Where the panel opens. It renders inline (no portal), sized to the nearest container, up to 29rem.
formatCost(usd: number) => string"$0.27"Formats the conversation cost.
classNamestring—Extra classes for the root element.
type ModelCapability = "vision" | "tools" | "reasoning";

type PickerModel = {
  id: string;
  name: string;                 // "Vela"
  provider: string;             // "Meridian"; first letter is the monogram
  speed: number;                // output tokens per second
  price: { input: number; output: number }; // USD per 1M tokens
  context: number;              // context window in tokens
  capabilities?: ModelCapability[];
};

type ModelRequirement = {
  capability: ModelCapability;
  reason: string;               // "can't read the 3 screenshots in this chat"
};