• bitcoinBitcoin(BTC)$60,550.00-0.43%
  • ethereumEthereum(ETH)$1,690.20-0.82%
  • tetherTether(USDT)$1.000.00%
  • binancecoinBNB(BNB)$554.28-0.50%
  • usd-coinUSDC(USDC)$1.000.01%
  • rippleXRP(XRP)$0.94-0.03%
  • solanaSolana(SOL)$71.10-0.08%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.070.87%
  • tronTRON(TRX)$0.3037140.08%
  • HyperliquidHyperliquid(HYPE)$62.610.35%
  • zcashZcash(ZEC)$690.20-11.01%
  • dogecoinDogecoin(DOGE)$0.056465-0.17%
  • moneroMonero(XMR)$460.14-10.75%
  • leo-tokenLEO Token(LEO)$9.090.86%
  • whitebitWhiteBIT Coin(WBT)$61.103.58%
  • chainlinkChainlink(LINK)$9.311.85%
  • USDSUSDS(USDS)$1.000.02%
  • cardanoCardano(ADA)$0.1487281.26%
  • Ethena USDeEthena USDe(USDE)$1.00-0.05%
  • stellarStellar(XLM)$0.126822-1.95%
  • daiDai(DAI)$1.00-0.01%
  • bitcoin-cashBitcoin Cash(BCH)$209.820.98%
  • nearNEAR Protocol(NEAR)$3.05-1.13%
  • litecoinLitecoin(LTC)$43.882.04%
  • CantonCanton(CC)$0.074930-4.05%
  • avalanche-2Avalanche(AVAX)$6.60-1.11%
  • tether-goldTether Gold(XAUT)$3,562.60-0.17%
  • USD1USD1(USD1)$1.00-0.03%
  • uniswapUniswap(UNI)$4.66-2.30%
  • Ripple USDRipple USD(RLUSD)$1.000.01%
  • suiSui(SUI)$0.67-0.83%
  • the-open-networkGram (prev. Toncoin)(GRAM)$0.95-1.18%
  • Global DollarGlobal Dollar(USDG)$1.000.00%
  • hedera-hashgraphHedera(HBAR)$0.0541522.59%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.150.05%
  • paypal-usdPayPal USD(PYUSD)$1.000.02%
  • BittensorBittensor(TAO)$183.730.23%
  • quant-networkQuant(QNT)$147.791.61%
  • shiba-inuShiba Inu(SHIB)$0.0000040.30%
  • Spiko Amundi Overnight Swap Fund (EUR)Spiko Amundi Overnight Swap Fund (EUR)(EURSAFO)$1.12-0.05%
  • Circle USYCCircle USYC(USYC)$1.150.00%
  • crypto-com-chainCronos(CRO)$0.039975-0.57%
  • MemeCoreMemeCore(M)$0.82-2.77%
  • RainRain(RAIN)$0.002485-10.26%
  • okbOKB(OKB)$82.770.89%
  • Falcon USDFalcon USD(USDF)$1.000.02%
  • United StablesUnited Stables(U)$1.000.05%
  • pax-goldPAX Gold(PAXG)$3,559.42-0.28%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • BitwayBitway(BTW)$1.0011.88%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

How to Build a Cost-Aware LLM Routing System with NadirClaw Using Local Prompt Classification and Gemini Model Switching

May 10, 2026
in AI & Technology
Reading Time: 2 mins read
A A
How to Build a Cost-Aware LLM Routing System with NadirClaw Using Local Prompt Classification and Gemini Model Switching
ShareShareShareShareShare
if proxy_alive():
   print("\n[10] Mixed 10-prompt workload…")
   workload = [
       "Capital of France?",
       "Read foo.py",
       "Type hint for a list of dicts",
       "Lowercase: HELLO",
       "One-sentence summary of REST",
       "Refactor a callback chain into async/await with proper error handling",
       "Design a sharded multi-region key-value store with linearizable reads",
       "Analyze the asymptotic complexity of this code and prove the bound rigorously",
       "Debug why our gRPC stream stalls when the client TCP window saturates",
       "Compare and contrast B-trees and LSM-trees for write-heavy workloads",
   ]
   runs = []
   client = OpenAI(base_url=f"http://localhost:{PORT}/v1", api_key="local")
   for p in workload:
       t0 = time.time()
       try:
           r = client.chat.completions.create(
               model="auto",
               messages=[{"role": "user", "content": p}],
               max_tokens=140,
           )
           usage = getattr(r, "usage", None)
           runs.append({
               "prompt": p[:55],
               "model": r.model,
               "latency_s": round(time.time() - t0, 2),
               "in_tok": getattr(usage, "prompt_tokens", 0) if usage else 0,
               "out_tok": getattr(usage, "completion_tokens", 0) if usage else 0,
           })
       except Exception as e:
           runs.append({"prompt": p[:55], "model": "ERROR",
                        "latency_s": None, "in_tok": 0, "out_tok": 0,
                        "error": str(e)[:80]})
   rdf = pd.DataFrame(runs)
   print(rdf.to_string(index=False))
   PRICE = {
       "flash": {"in": 0.30 / 1e6, "out": 2.50 / 1e6},
       "pro":   {"in": 1.25 / 1e6, "out": 10.0 / 1e6},
   }
   def price_for(model_str, in_t, out_t):
       m = (model_str or "").lower()
       tier = "flash" if "flash" in m else "pro"
       return in_t * PRICE[tier]["in"] + out_t * PRICE[tier]["out"]
   cost_routed = sum(price_for(r["model"], r["in_tok"], r["out_tok"]) for r in runs)
   cost_no_route = sum(price_for("gemini-2.5-pro", r["in_tok"], r["out_tok"]) for r in runs)
   print(f"\n[10] Cost (NadirClaw routed)        : ${cost_routed:.6f}")
   print(f"     Cost (always-Pro baseline)     : ${cost_no_route:.6f}")
   if cost_no_route > 0:
       print(f"     Estimated savings on this run  : "
             f"{(1 - cost_routed/cost_no_route) * 100:.1f}%")
print("\n[11] `nadirclaw report` (parses the JSONL request log):")
rep = subprocess.run(["nadirclaw", "report"], capture_output=True, text=True, timeout=60)
print(rep.stdout or rep.stderr)
if proxy_alive():
   print("\n[12] Stopping the proxy…")
   try:
       if hasattr(os, "killpg"):
           os.killpg(os.getpgid(server_proc.pid), signal.SIGTERM)
       else:
           server_proc.terminate()
       server_proc.wait(timeout=10)
   except Exception:
       try:
           server_proc.kill()
       except Exception:
           pass
   print("    ✓ proxy stopped.")
print("\nDone. 🎉")

Credit: Source link

YOU MAY ALSO LIKE

Backloggd Urges Users To Change Their Passwords After A Breach

1Password Says It Was Hacked But Users’ Vaults Are Safe

ShareTweetSendSharePin

Related Posts

Backloggd Urges Users To Change Their Passwords After A Breach
AI & Technology

Backloggd Urges Users To Change Their Passwords After A Breach

November 26, 2026
1Password Says It Was Hacked But Users’ Vaults Are Safe
AI & Technology

1Password Says It Was Hacked But Users’ Vaults Are Safe

November 26, 2026
Canada Invests 0 Million More to Expand AI Compute Access Fund – Unite.AI
AI & Technology

Canada Invests $700 Million More to Expand AI Compute Access Fund – Unite.AI

November 26, 2026
Workers At GTA 6 Studio Rockstar Games Vote Overwhelmingly Against Union Recognition
AI & Technology

Workers At GTA 6 Studio Rockstar Games Vote Overwhelmingly Against Union Recognition

November 26, 2026
Next Post
Stay Tuned NOW Streaming Behind The Scenes! – May 01

Stay Tuned NOW Streaming Behind The Scenes! - May 01

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Which Is Better for Teamwork and Project Delivery? – Unite.AI

Which Is Better for Teamwork and Project Delivery? – Unite.AI

November 26, 2026
Abdul El-Sayed, Sen. Kennedy on viability of Medicare for all ideas

Abdul El-Sayed, Sen. Kennedy on viability of Medicare for all ideas

November 25, 2026
ImmunityBio Stock: Q3 ANKTIVA Slowdown And Cash Burn Reaffirm My Sell Rating (NASDAQ:IBRX)

ImmunityBio Stock: Q3 ANKTIVA Slowdown And Cash Burn Reaffirm My Sell Rating (NASDAQ:IBRX)

November 20, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!