← Machine Coding

AI Model Picker + Cost/Latency Badge

mediumAI
Asked at
Google
OpenAI
Google, OpenAI

Problem statement

Every serious AI product eventually lets users pick a model. ChatGPT has GPT-4o vs o-series. Claude has Sonnet vs Opus. Cursor has Auto vs a pinned model. The picker looks like a dropdown — but the interview signal is whether you treat model choice as product state that gates UX, not a decorative select.

Build a chat composer with a keyboard-accessible model menu. Each model has latency, cost, and capability tags. Selecting a model must update a cost/latency badge immediately, and actions the model cannot perform (tools, vision) must be disabled with a clear explanation — never a silent no-op.

The senior insight: model selection is a capability contract. Badges communicate tradeoffs; disabled actions + inline reasons communicate limits; persistence across sends proves you modeled it as session state.

Requirements & constraints

  • →Provide at least 3 mock models with distinct latency, cost, and capability profiles
  • →Header badge updates immediately on model change (latency + relative cost)
  • →Model menu is keyboard accessible: Arrow keys, Enter to select, Escape to close
  • →Capability gating: tools/vision actions disabled when unsupported, with a visible inline reason
  • →Selected model persists across multiple messages in the same session
  • →Assistant messages show which model produced them
  • →Enter sends; Shift+Enter inserts a newline; empty input cannot send

How to approach AI Model Picker + Cost/Latency Badge

The strategy an interviewer expects you to reach for.

How I'd Think About This Problem This is not a dropdown exercise. Interviewers are checking whether you understand that model choice changes the product surface. Latency badges set expectations. Cost chips educate tradeoffs. Capability tags prevent dead-end clicks. If you only change a label in the select and leave the rest of the UI identical, you've missed the point. I split the problem into three layers before coding: config (static model catalog), session state (selected modelId that survives sends), and capability gates (actions that consult the selected model's capabilities before running).

Premium

The full solution is part of HelloFrontend Pro

The question above is free to read in full. Upgrade to unlock the interactive workspace and the senior-level walkthrough that go with it.

  • Live React sandbox pre-wired for this component
  • Time-boxed checkpoints that mirror a real 45-minute round
  • Interviewer scoring criteria and a full reference implementation
Unlock the full solution →

Already a member? Log in to open the workspace.

More Machine Coding questions

View all Machine Coding →
Machine CodingMedium

React Tic-Tac-Toe Engine

Machine CodingMedium

Performant Image Slider

Machine CodingMedium

API Search and Render Image

Machine CodingEasy

Accessible React Tabs

Machine CodingMedium

Recursive File Explorer

Machine CodingEasy

Stopwatch

Explore related prep hubs

  • All machine coding
  • Frontend machine coding guide
  • React machine coding questions
  • UI coding interview questions
  • React UI interview questions
  • Google interview
  • OpenAI interview