Model arena
Blind side-by-side model bake-off with parallel streaming panes, live first-token, speed, and cost readouts, a reveal-on-vote bar, a spring-reordered leaderboard popover, and narrow-width answer tabs.
import { ModelArena } from '@uthereal/ui/model-arena'Model arena playground
Model arenaRound 1
Two anonymous models answer the same prompt. Vote for the better answer.
The answer streams here
- First token
- –
- Speed
- – tok/s
- Cost
- – $
The answer streams here
- First token
- –
- Speed
- – tok/s
- Cost
- – $
Overview
ModelArena runs two models against the same prompt side by side so evaluators can compare answer quality, latency, throughput, and cost before casting a vote. In blind mode (defaultBlind: true), both panes hide real identities as Model A and Model B until the evaluator votes or toggles the Blind switch off.
| Capability | Behavior |
|---|---|
| Blind privacy | While blind and unvoted, real model names, IDs, and marks never enter the DOM or aria-* attributes. |
| Parallel streams | Streams both panes simultaneously with a shared pacing clock, independent error cards, and per-slot Retry. |
| Live telemetry | Tabular first-token latency (s), rolling throughput (tok/s), and localized cost ($) per million tokens. |
| Vote & reveal | Four outcomes (A is better, Tie, B is better, Both bad) reveal both models and update standings. |
| Leaderboard | Portalled popover ranks contestants by win rate (ties = 0.5 win) with series-colored bars and FLIP reorder. |
| Responsive layout | Collapses side-by-side panes into an accessible two-tab switcher below 560px container width. |
Use ModelArena for human preference evaluations, prompt testing, and model routing comparisons. For single-model multi-turn conversations, use Chat.
Usage
'use client'
import { ModelArena, type ArenaRun } from '@uthereal/ui/model-arena'
const run: ArenaRun = async function* (model, prompt, signal) {
const res = await fetch('/api/arena', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ modelId: model.id, prompt }),
signal,
})
const reader = res.body?.getReader()
const decoder = new TextDecoder()
while (reader) {
const { done, value } = await reader.read()
if (done) break
yield decoder.decode(value, { stream: true })
}
}
export function EvaluationArena() {
return (
<ModelArena
run={run}
voteAction="record_arena_vote"
onVote={(vote) => {
console.log('Vote cast', vote.choice, vote.a.model.id, vote.b.model.id)
}}
/>
)
}Omit run to use the built-in local simulator over the sample prompts (nothing leaves the browser; one scripted model simulates a mid-stream connection drop that recovers when retried). Yield { text, inputTokens, outputTokens } objects from run to report exact provider token usage instead of the 4-characters-per-token estimate.
Examples
Use <SchemaPlayground /> above to inspect recipe, motion, theme, and the default blind seven-model arena. The examples below show non-blind side-by-side mode with preloaded leaderboard standings and an open-prompt blind evaluation without sample chips.
Revealed comparison with seeded leaderboard
Set defaultBlind: false to display model marks and names upfront, and pass initialStandings to hydrate the Leaderboard popover with existing win/tie/loss records from your backend.
Model arenaRound 1
Two models answer the same prompt. Vote for the better answer.
The answer streams here
- First token
- –
- Speed
- – tok/s
- Cost
- – $
The answer streams here
- First token
- –
- Speed
- – tok/s
- Cost
- – $
Open-prompt blind bake-off
Pass prompts: [] to omit sample chips for ad-hoc testing, paired with a focused three-model contestant pool in blind mode.
Model arenaRound 1
Two anonymous models answer the same prompt. Vote for the better answer.
The answer streams here
- First token
- –
- Speed
- – tok/s
- Cost
- – $
The answer streams here
- First token
- –
- Speed
- – tok/s
- Cost
- – $
API reference
Serializable schema arguments and defaults come directly from modelArenaConfigSchema.
| Argument | Type / default | Description |
|---|---|---|
contestants | ArenaModel[]Default: [{"id":"claude-opus-5-5","name":"Claude Opus 5.5","shortName":"Opus 5.5","provider":"Anthropic","markColor":"#d97757","price":{"input":4,"output":20},"color":"series-3"},{"id":"gpt-6-1-sol","name":"GPT-6.1 Sol","provider":"OpenAI","price":{"input":5,"output":30},"color":"series-4"},{"id":"gemini-4-argon","name":"Gemini 4 Argon","provider":"Google","markColor":"#4285f4","price":{"input":3.5,"output":21},"color":"series-1"},{"id":"grok-4-7","name":"Grok 4.7","provider":"xAI","price":{"input":3,"output":15},"color":"series-2"},{"id":"claude-sonnet-5-5","name":"Claude Sonnet 5.5","shortName":"Sonnet 5.5","provider":"Anthropic","markColor":"#d97757","price":{"input":2,"output":10},"color":"series-3"},{"id":"deepseek-v4-1-flash","name":"DeepSeek V4.1 Flash","shortName":"V4.1 Flash","provider":"DeepSeek","markColor":"#4d6bfe","price":{"input":0.14,"output":0.56},"color":"series-1"},{"id":"mistral-large-4","name":"Mistral Large 4","provider":"Mistral AI","markColor":"#ff7000","price":{"input":1.5,"output":6},"color":"series-3"}] | The pool each round draws its blind pair from. Defaults to a seven-model sample with input and output pricing and series colors for the leaderboard bars. |
prompts | ArenaPrompt[]Default: [{"id":"sql","label":"Top customers in SQL","text":"Write a Postgres query for the top 5 customers by revenue in Q3 2026, with their order count."},{"id":"mutex","label":"Mutex or semaphore","text":"Explain the difference between a mutex and a semaphore to a junior engineer, with one example each."},{"id":"decline","label":"Decline a meeting","text":"Write a short, warm reply to Priya declining Thursday's 3pm roadmap sync, and offer async notes instead."}] | Sample prompts shown as chips under the field. The first prefills it and Next round moves through them in order. |
defaultBlind | booleanDefault: true | Hide model names and marks until a vote. The Blind switch flips it at any time; a vote always reveals both models. |
autoStart | booleanDefault: false | Run the first round once the card scrolls into view. Opt-in demo behavior; never fires while a real run function is wired. |
initialStandings | Record<string, ArenaRecord>— | Starting wins, ties, and losses per model id, such as standings loaded from your own store. Without it the leaderboard counts this session from zero. |
voteAction | string— | Registered host action requested when a vote is cast, alongside the onVote callback. |
locale | string— | BCP 47 locale for the cost readout; inherited from the page when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | ModelArenaThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | ModelArenaMotionOptionsDefault: {} | Reveal width, vote-row height, leaderboard reorder, and swap timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
ArenaModelaccepts{ id, name, shortName?, provider, markColor?, price: { input, output }, color?: 'series-1'..'series-8' }. Model IDs must be unique and at least two contestants are required.ArenaPromptaccepts{ id, label, text }(unique IDs, up to 12 items).ArenaRecordaccepts{ wins, ties, losses }keyed by contestant ID insideinitialStandings.
React integration
| Prop | Purpose |
|---|---|
run(model, prompt, signal) | Async iterable yielding string deltas or { text?, inputTokens?, outputTokens? }. Throw ArenaRunError for pane errors. |
onVote(vote) | Called with { choice, round, a, b } before both models are revealed. |
onAction(action) | Host action callback fired with voteAction whenever a vote is cast. |
renderModelMark(model) | Replaces the default provider mark beside revealed model names and leaderboard rows. |
portalContainer | Custom DOM mount target for the portalled leaderboard popover. |
preset | Application defaults merged below explicit instance arguments. |
tokens | --ui-* CSS variables applied after the typed theme on the root and leaderboard popover. |
ref, className, style | Forwarded to the root <section> element. style takes precedence over motion and theme tokens. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
Mod+Enter (in prompt) | Starts a round when idle or stops an active streaming round. |
Enter (in prompt) | Submits the form and starts a round when the prompt is non-empty. |
Escape (in prompt) | Stops an active streaming round so partial answers can still be compared. |
ArrowLeft / ArrowRight | Switches between Model A and Model B tabs below 560px container width (mirrors in RTL). |
Home / End (narrow) | Jumps to the first or last answer tab and moves keyboard focus. |
- Blind privacy guarantee: while
blindis enabled and no vote has been cast, real model names, IDs, and marks are omitted completely from text nodes,aria-label,title, anddata-*attributes. - A pre-mounted polite
role="status"live region announces round start, completion, stop, retry, vote outcomes, and next-round readiness. - Every rolling numeric readout (
Round,tok/s, and$cost) pairs visually hidden full text witharia-hidden="true"rolling digits so screen readers announce one coherent value. - Answer scrollers are keyboard-focusable (
tabIndex={0}) witharia-busywhile streaming; pane errors render inrole="alert"regions. - Container queries switch to tabs below
560pxand stack header and 2×2 vote buttons below480px. All borders, arrows, and highlights respectdir="rtl"andforced-colors: active.
Motion & theming
Model identity swaps and status pills crossfade while springing width on the zero-bounce smooth spring (reveal), the vote bar adjusts height on layout, and leaderboard rows slide smoothly into their new ranks with layout="position" (LazyMotion with domMax) while win-rate bars scale in on open.
Setting motion="none" makes every spring, word fade, spinner, and tab slide immediate (0ms). Under prefers-reduced-motion: reduce, word pacing, travel, FLIP reorders, and shimmer turn off while keeping 120ms opacity crossfades.
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-shadow, --ui-disabled-opacity, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength |
shape | --ui-radius-sm, --ui-popup-radius, --ui-surface-radius |
accentTones | --ui-accent-strong, --ui-accent-subtle |
control | --ui-control-height, --ui-control-padding-x, --ui-control-gap, --ui-icon-size |
type | --ui-font-mono, --ui-font-display |
chart | --ui-series-1 through --ui-series-8 (leaderboard win-rate bar colors by provider) |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, ModelArena is a leaf block (group: 'blocks-agents'). Supply at least two contestants with unique IDs, keep defaultBlind true unless the request specifies upfront visibility, and wire voteAction to a registered host action.
{
"type": "ModelArena",
"props": {
"defaultBlind": true,
"voteAction": "record_arena_vote"
},
"children": []
}