This example walks through creating a simple calculator app using SuperModel’s zero-inference architecture. You’ll see how routing and UI generation work via MCP sampling.
Input: “Show me a calculator”This simple request triggers SuperModel’s layered architecture to route the request and generate an interactive calculator interface.
SuperModel’s gateway doesn’t decide which tool to use - it asks the client’s LLM:
Copy
{ "method": "sampling/createMessage", "params": { "messages": [{ "role": "user", "content": { "type": "text", "text": "User request: 'Show me a calculator'\n\nAvailable tools:\n- calculator-ui: Interactive calculator with basic arithmetic operations\n- form-builder-ui: Dynamic form generation and validation\n- data-viz-ui: Charts and data visualization\n- product-search-ui: E-commerce product search interface\n\nWhich tool should handle this request? Return JSON with tool name and any relevant parameters." } }], "systemPrompt": "You are a routing assistant. Analyze the user request and return JSON: {\"tool\": \"tool-name\", \"params\": {...}}" }}
Zero Inference Cost: The gateway server made no LLM API calls. The client’s LLM handled the routing decision.
The calculator tool uses MCP sampling to generate the actual UI component:
Copy
{ "method": "sampling/createMessage", "params": { "messages": [{ "role": "user", "content": { "type": "text", "text": "Create an AG-UI calculator component with the following requirements:\n\n- Buttons for numbers 0-9\n- Operation buttons: +, -, *, /, =\n- Clear button (C) and clear all (CA)\n- Display screen showing current number and result\n- Professional, clean design\n- Use AG-UI event system for all button interactions\n\nGenerate a complete React component that follows AG-UI patterns for event handling." } }], "systemPrompt": "You are an expert React developer specializing in AG-UI components. Generate clean, functional code with proper event handlers for the AG-UI protocol.", "maxTokens": 1500 }}
Zero Inference Cost: Again, the calculator tool made no LLM API calls. The client’s LLM generated the entire UI component.