Skip to main content
Time to complete: 15-20 minutes What you’ll build: A hardware analysis agent that recommends which LLMs you can run What you’ll learn: LemonadeClient APIs, GPU/NPU detection, memory-based recommendations Platform: Runs locally on AI PCs with Ryzen AI (NPU/iGPU acceleration)

Why Build This Agent?

Privacy-First AI: This agent runs entirely on your AI PC. Hardware detection and model recommendations happen locally—no data leaves your machine.
When users ask “What size LLM can I run?”, the answer depends on their actual hardware. Instead of guessing or looking up specifications manually, this agent:
  1. Detects system RAM, GPU, and NPU via Lemonade Server
  2. Queries the available model catalog with size estimates
  3. Calculates which models fit in available memory
  4. Provides personalized recommendations based on real hardware specs
What you’re building: A hardware advisor agent that combines:
  • LemonadeClient SDK - System info and model catalog APIs
  • Platform-specific detection - Windows PowerShell / Linux lspci for GPU info
  • Memory calculations - 70% rule for safe model sizing
  • Interactive CLI - Natural language queries about capabilities
  • Local execution - Runs entirely on your AI PC using Ryzen AI acceleration

The Architecture (What You’re Building)

Flow:
  1. User query → HardwareAdvisorAgent (orchestrator)
  2. Agent selects tool → get_hardware_info / list_available_models / recommend_models
  3. Tools call → LemonadeClient SDK + OS-specific detection
  4. Results aggregated → Agent synthesizes recommendation
  5. User receives personalized advice

Quick Start (5 Minutes)

Get a working agent running to understand the basic flow.
1

Set up your project

Choose your installation path:
2

Start Lemonade Server

Lemonade Server provides AMD-optimized inference for AI PCs with Ryzen AI. It also exposes system info and model catalog APIs that this agent uses.
3

Run the Hardware Advisor

Create hardware_advisor.py in your project folder and follow the step-by-step build below, or copy the complete example from the Building It section.
Try asking:
  • “What size LLM can I run?”
  • “Show me my system specs”
  • “What models are available?”
  • “Can I run a 30B model?”
4

See it in action

Example interaction:
The agent requires Lemonade Server to be running for hardware detection and model catalog queries. GAIA auto-starts it on first use if not running.

Understanding the Components

Before we build step-by-step, let’s understand what each piece does under the hood.

1. LemonadeClient SDK

Why LemonadeClient?
  • Provides unified API for system detection
  • Returns NPU/GPU availability from Lemonade Server
  • Model catalog with size estimates for recommendations

2. Platform-Specific GPU Detection


3. The 70% Memory Rule

Rule: Model size should be less than 70% of available RAM to leave 30% overhead for inference operations.
Why 30% overhead?
  • KV cache for context window
  • Batch processing buffers
  • Runtime memory spikes during generation
Example calculation:

Building It: The Step-by-Step Journey

Now let’s build this agent incrementally using a single file that grows with each step. We’ll build exactly what’s in examples/hardware_advisor_agent.py by adding functionality progressively.
Building Strategy: You’ll create ONE file called hardware_advisor.py and progressively add features to it. Each step builds on the previous one, and by Step 6 you’ll have code that matches the example exactly.

Step 1: Agent Skeleton

Start by creating the file with a minimal agent structure—just the class and a basic system prompt. This creates the foundation, but the agent has no tools yet and cannot answer queries.

Implementation

hardware_advisor.py
Formatting Note: When pasting code, ensure proper Python indentation (4 spaces for class/function bodies). Use an IDE with Python support to avoid alignment issues.

Running It

Expected output:

Progress Check

  • ✓ Basic agent structure
  • ✓ LemonadeClient connection
  • ✓ Minimal system prompt
  • ✗ GPU detection helper (_get_gpu_info())
  • ✗ Hardware detection tool (get_hardware_info())
  • ✗ Model catalog tool (list_available_models())
  • ✗ Smart recommendations tool (recommend_models())
  • ✗ Interactive CLI
Don’t try to query this agent yet! It has no tools, so it cannot check hardware or recommend models. Continue to Step 2 to add GPU detection and hardware tools.

Step 2: GPU & Hardware Detection

Add the _get_gpu_info() helper method and the full get_hardware_info() tool with GPU object, NPU object, and OS field. This makes the agent interactive—you can now query it about system specs!

Implementation

First, update the imports at the top of the file:
Add the _get_gpu_info() helper after the _get_system_prompt() method:
Replace the _register_tools() method with:
Update the __main__ block to enable interactive testing:
Formatting Note: When pasting code, ensure proper Python indentation. Method bodies should be indented 4 spaces from the class level, and nested blocks should maintain consistent 4-space indentation.

Running It

Try asking: “Show me my system specs” Example output:

Progress Check

  • ✓ Basic agent structure
  • ✓ LemonadeClient connection
  • ✓ Minimal system prompt
  • ✓ GPU detection helper (_get_gpu_info())
  • ✓ Hardware detection tool (get_hardware_info())
  • ✗ Model catalog tool (list_available_models())
  • ✗ Smart recommendations tool (recommend_models())
  • ✓ Interactive CLI

Step 3: Model Catalog

Add the list_available_models() tool with labels field and message in the response. Now the agent can tell you what models are available in the Lemonade catalog.

Implementation

Add this tool inside the _register_tools() method (after the get_hardware_info function):
The __main__ block stays the same (already interactive from Step 2)
Formatting Note: When pasting the tool code inside _register_tools(), maintain proper indentation. The @tool decorator and function definition should be indented 4 spaces, with the function body indented 8 spaces.

Running It

Try asking: “What models are available?” Example output:

Progress Check

  • ✓ Basic agent structure
  • ✓ LemonadeClient connection
  • ✓ Minimal system prompt
  • ✓ GPU detection helper (_get_gpu_info())
  • ✓ Hardware detection tool (get_hardware_info())
  • ✓ Model catalog tool (list_available_models())
  • ✗ Smart recommendations tool (recommend_models())
  • ✓ Interactive CLI

Step 4: Smart Recommendations

Add the complete recommend_models() tool with estimated_runtime_gb, fits_in_ram, fits_in_gpu, and constraints object. The agent can now calculate which models fit in your system’s memory!

Implementation

Add this tool inside the _register_tools() method (after the list_available_models function):
The __main__ block stays the same (already interactive from Step 2)
Formatting Note: When pasting the tool code inside _register_tools(), maintain proper indentation. The @tool decorator and function definition should be indented 4 spaces, with the function body indented 8 spaces.

Running It

Try asking: “What size LLM can I run?” Example output:

Progress Check

  • ✓ Basic agent structure
  • ✓ LemonadeClient connection
  • ✓ Minimal system prompt
  • ✓ GPU detection helper (_get_gpu_info())
  • ✓ Hardware detection tool (get_hardware_info())
  • ✓ Model catalog tool (list_available_models())
  • ✓ Smart recommendations tool (recommend_models())
  • ✓ Interactive CLI


Step 5: Production CLI

Replace the simple __main__ block with a full interactive CLI function. This adds a professional banner, better error handling, and graceful exit options.

Implementation

Replace the entire if __name__ == "__main__": block at the end of the file with:
Formatting Note: When pasting the main() function, ensure the function body is indented 4 spaces, and nested blocks (try/except/while) maintain consistent 4-space indentation increments.

Running It

You’ll now get a full interactive session! Expected output:

Progress Check

  • ✓ Basic agent structure
  • ✓ LemonadeClient connection
  • ✓ Minimal system prompt
  • ✓ GPU detection helper (_get_gpu_info())
  • ✓ Hardware detection tool (get_hardware_info())
  • ✓ Model catalog tool (list_available_models())
  • ✓ Smart recommendations tool (recommend_models())
  • ✓ Interactive CLI


Step 6: Final Verification

Verify that your hardware_advisor.py has all the components working together correctly.

Verify Structure

Your file should have:
  1. ✓ Imports: from typing import Any, Dict and from gaia import Agent, tool
  2. ✓ LemonadeClient import: from gaia.llm.lemonade_client import LemonadeClient
  3. HardwareAdvisorAgent class with minimal __init__ and one-line system prompt
  4. _get_gpu_info() helper method (Windows and Linux GPU detection)
  5. _register_tools() method with client = self.client and agent = self
  6. get_hardware_info() tool with GPU object, NPU object, and OS field
  7. list_available_models() tool with labels and message fields
  8. recommend_models() tool with estimated_runtime_gb, fits_in_ram, fits_in_gpu, constraints
  9. main() function with interactive CLI (banner, loop, quit handling)
  10. if __name__ == "__main__": main()

Test Your Implementation

Run your agent:
Try these queries:
  • “What size LLM can I run?”
  • “Show me my system specs”
  • “What models are available?”
  • “Can I run a 30B model?”
Expected behavior:
  • Agent starts with interactive banner
  • Hardware detection returns system specs
  • Model catalog lists available models
  • Recommendations calculate safe model sizes based on your RAM

Complete!

  • ✓ Basic agent structure
  • ✓ LemonadeClient connection
  • ✓ Minimal system prompt
  • ✓ GPU detection helper (_get_gpu_info())
  • ✓ Hardware detection tool (get_hardware_info())
  • ✓ Model catalog tool (list_available_models())
  • ✓ Smart recommendations tool (recommend_models())
  • ✓ Interactive CLI
Congratulations! You’ve built a fully functional hardware advisor agent! Your implementation includes OS-native GPU detection, smart memory-based recommendations, and an interactive CLI—all running locally on AMD hardware with Ryzen AI acceleration.


Under the Hood

Detection sequence:
Platform-specific notes:
  • Windows: Uses WMI queries via PowerShell (wmic deprecated on Windows 11)
  • Linux: Uses lspci for GPU detection (memory not available via this method)
  • NPU: Only available on Ryzen AI processors (8000/9000 series)
Performance:
  • System info query: ~50ms
  • GPU detection: ~200ms (subprocess overhead)
  • NPU detection: ~10ms (cached in Lemonade Server)
Memory calculation logic:
Safety margins explained:
  • 70% rule: Prevents OOM errors during inference peaks
  • 30% overhead: Accounts for KV cache, context window, batch processing
  • GPU 90% rule: Reserves 10% VRAM for driver overhead
Consistent response structure:All tools return dictionaries with this pattern:
Benefits:
  • LLM can check success field before using data
  • Error messages help LLM explain issues to users
  • Consistent pattern across all tools

The Complete Implementation

The full implementation is available at:
Key additions in the complete version:
  • GPU detection for both Windows and Linux
  • Interactive CLI with suggested questions
  • Timeout handling for subprocess calls
  • Graceful error recovery

View Source

See the complete Hardware Advisor Agent implementation on GitHub

Try It Out

Run the agent and try these queries:
Example questions:
  • “What size LLM can I run?”
  • “Show me my system specs”
  • “What models are available?”
  • “Can I run a 30B model?”
  • “Which models are already downloaded?”

Next Steps

You’ve built a hardware advisor agent! Here are ways to extend it:

LLM Integration

Explore LLM client APIs for model management

Voice Integration

Add speech recognition and text-to-speech to your agent