• bitcoinBitcoin(BTC)$77,659.00-3.06%
  • ethereumEthereum(ETH)$2,244.66-3.33%
  • tetherTether(USDT)$1.000.01%
  • binancecoinBNB(BNB)$701.11-5.29%
  • rippleXRP(XRP)$1.25-2.77%
  • usd-coinUSDC(USDC)$1.000.01%
  • solanaSolana(SOL)$96.96-3.41%
  • tronTRON(TRX)$0.3417643.17%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.030.00%
  • HyperliquidHyperliquid(HYPE)$93.148.22%
  • zcashZcash(ZEC)$1,269.340.53%
  • dogecoinDogecoin(DOGE)$0.075922-3.22%
  • moneroMonero(XMR)$590.85-1.14%
  • USDSUSDS(USDS)$1.000.03%
  • whitebitWhiteBIT Coin(WBT)$74.46-3.22%
  • leo-tokenLEO Token(LEO)$9.42-0.43%
  • chainlinkChainlink(LINK)$11.10-4.05%
  • cardanoCardano(ADA)$0.194630-3.01%
  • stellarStellar(XLM)$0.165365-2.58%
  • bitcoin-cashBitcoin Cash(BCH)$285.921.84%
  • nearNEAR Protocol(NEAR)$4.35-1.25%
  • RainRain(RAIN)$0.006681-1.98%
  • daiDai(DAI)$1.000.04%
  • Ethena USDeEthena USDe(USDE)$1.00-0.08%
  • litecoinLitecoin(LTC)$55.60-3.70%
  • uniswapUniswap(UNI)$6.89-3.39%
  • USD1USD1(USD1)$1.00-0.07%
  • CantonCanton(CC)$0.095868-2.10%
  • avalanche-2Avalanche(AVAX)$8.58-2.20%
  • suiSui(SUI)$0.89-3.37%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.17-3.87%
  • tether-goldTether Gold(XAUT)$3,976.75-1.29%
  • hedera-hashgraphHedera(HBAR)$0.071686-2.87%
  • Global DollarGlobal Dollar(USDG)$1.000.04%
  • paypal-usdPayPal USD(PYUSD)$1.000.03%
  • quant-networkQuant(QNT)$195.050.87%
  • shiba-inuShiba Inu(SHIB)$0.000005-2.70%
  • BittensorBittensor(TAO)$234.43-6.66%
  • crypto-com-chainCronos(CRO)$0.051887-3.23%
  • Ripple USDRipple USD(RLUSD)$1.000.00%
  • EthenaEthena(ENA)$0.188636-7.24%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.15-0.18%
  • Circle USYCCircle USYC(USYC)$1.140.01%
  • okbOKB(OKB)$111.170.25%
  • BitwayBitway(BTW)$1.53-14.68%
  • MemeCoreMemeCore(M)$0.99-6.00%
  • pepePepe(PEPE)$0.00000510.23%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • aaveAave(AAVE)$126.15-4.90%
  • OndoOndo(ONDO)$0.391779-4.85%
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

Waymo And Toyota Will Soon Start Testing Their Robotaxis In Japan

Cognizant Forms OpenAI Frontier Capability Group of 25,000+ Professionals – Unite.AI

ShareTweetSendSharePin

Related Posts

Waymo And Toyota Will Soon Start Testing Their Robotaxis In Japan
AI & Technology

Waymo And Toyota Will Soon Start Testing Their Robotaxis In Japan

October 30, 2026
Cognizant Forms OpenAI Frontier Capability Group of 25,000+ Professionals – Unite.AI
AI & Technology

Cognizant Forms OpenAI Frontier Capability Group of 25,000+ Professionals – Unite.AI

October 30, 2026
Cursor Discloses SSH Backdoor Attempt in Malicious Claude Code Extension – Unite.AI
AI & Technology

Cursor Discloses SSH Backdoor Attempt in Malicious Claude Code Extension – Unite.AI

October 30, 2026
General Motors Agrees To Pay 0 Million To Settle Multi-State Data Privacy Lawsuit
AI & Technology

General Motors Agrees To Pay $220 Million To Settle Multi-State Data Privacy Lawsuit

October 30, 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
Father of two and teacher credited for saving lives at deadly school shooting that killed four

Father of two and teacher credited for saving lives at deadly school shooting that killed four

October 24, 2026
Father fatally shoots gunman during deadly school shooting

Father fatally shoots gunman during deadly school shooting

October 23, 2026
Georgia police identify man in fatal Six Flags incident

Georgia police identify man in fatal Six Flags incident

October 26, 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!