• Home
  • About
Book a Discovery Call

Back

Stop Wasting AI Credits: How I Built a Dynamic Agent That Picks Its Own Brain

If you’ve ever been frustrated by paying GPT-4 prices for a task that GPT-3.5 could’ve handled, you’re not alone. I was in the same boat — burning through credits just to have an AI tell me a joke or set a calendar event. That’s when I realized something important:

👉 Not every task needs the same brain.

So I built a system where my AI agent dynamically chooses the best model for the job. And honestly, it changed everything — costs dropped, performance went up, and I finally had visibility into which model was being used, when, and why.

Act 1: The Problem

I started with the usual setup: Slack + an AI agent.

At first, it felt magical. I’d type:

“Tell me a joke.”

And the agent would reply instantly. But then I checked my logs. It was using an expensive reasoning model just to spit out a dad joke. That’s like using a rocket launcher to kill a mosquito.

Worse? I had no control over the credits bleeding away.

Act 2: The Breakthrough

The breakthrough came with OpenRouter — a gateway to 300+ AI models. Instead of hardcoding one model, I added a Model Selector Agent.

  • When I ask a simple task → it routes to Gemini 2.0 Flash (cheap + fast).
  • When I ask something creative or reasoning-heavy → it picks Claude 3.7 Sonnet or OpenAI o1.
  • For balanced tasks → it might choose GPT-4.1 Mini.
  • This way, the AI chooses its brain dynamically — no more wasting money where it isn’t needed.

    Act 3: The Demo

    Here’s how it played out in real life:

    Simple Joke

  • I asked: “Tell me a joke.”
  • The agent used Gemini 2.0 Flash (free/cheap).
  • Reply: “Why don’t scientists trust atoms? Because they make up everything.”
  • 2. Calendar Event

  • I said: “Create a lunch meeting at 1 p.m.”
  • It picked GPT-4.1 Mini, created the event, and synced it to Google Calendar.
  • 3. AI Research Blog

  • I asked: “Write a blog on AI voice agents with trends and case studies.”
  • The agent knew this required depth → used Claude 3.7 Sonnet.
  • It did 4 web searches, pulled case studies, growth stats, ethics — then wrote a full blog post in Slack.
  • 4. Logic Puzzle (Reasoning)

  • I tested it with a riddle about mislabelled fruit boxes.
  • It routed to OpenAI o1 reasoning model.
  • Nailed the solution.
  • Each time, the log told me which model was used, why, and how much it cost.

    Act 4: Why This Matters

    In the fast-moving AI world, new models launch every week. Some are faster, some are smarter, some are just plain cheaper. Locking yourself into one model is like only ever eating at one restaurant.

    Dynamic model routing means: ✅ Save costs by using lightweight models for simple tasks ✅ Boost performance by scaling up when complexity demands it ✅ Maintain control with full transparency in logs

    And the best part? I can add or swap models anytime.

    Act 5: How You Can Try This

    Here’s the stack I used:

  • Slack → interface to talk to the agent
  • n8n → workflow automation (trigger → model selector → agent → logs)
  • OpenRouter → dynamic brain with 300+ LLMs
  • Tavily → web research tool for deeper queries
  • Google Sheets → logging model choices, inputs, outputs
  • I also tested it with RAG agents (knowledge base lookups). If it’s a simple FAQ → cheap model. If it’s a complex query → stronger model.

    Final Thoughts

    This isn’t about just saving money (though that’s a big win). It’s about building smarter AI systems that adapt to the task at hand.

    In the future, agents won’t just be one “brain.” They’ll be orchestrators of multiple brains — choosing the right one at the right time.

    And honestly? Once you experience it, you’ll never go back.

    ✨ If you want the workflow JSON and Google Sheet template, I’ve shared them in my AI University Skool Community.

    Yar Asfand Malik

    Author: Yar Asfand Malik

    Published: 23 Sep, 2025

    © 2025 Yar Malik. All rights reserved. Powered by passion, purpose, and AI.