惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
The Cloudflare Blog
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
C
Check Point Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
F
Fortinet All Blogs
B
Blog
大猫的无限游戏
大猫的无限游戏
N
Netflix TechBlog - Medium
B
Blog RSS Feed
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

Hacker News: Show HN

PurrrrrFocus: Pomodoro Timer App - App Store Workflow Engine — Multi-Step Orchestration for Bun RapidPhoto: Pro Photo Editor App - App Store GitHub - DheerG/swarms: Achieve extraordinary results with claude code across a variety of tasks SPICE simulation → oscilloscope → verification with Claude Code — Lucas Gerads Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies Show HN: LLMs don't hallucinate because they're bad at math, it's the format GitHub - Agent-FM/agentfm-core: AgentFM is a peer-to-peer network that turns everyday computers into a decentralized AI supercomputer. AgentFM lets you run massive AI workloads directly across a global mesh of idle CPUs and GPUs. Show HN: Tracking Top US Science Olympiad Alumni over Last 25 Years GitHub - Potarix/agent-hub: One place to talk to all your agents Show HN: Runtime security for AI agents(injection,tool abuse, data exfiltration) GitHub - dubeyKartikay/lazyspotify: Terminal Spotify client for macOS and Linux GitHub - the-banana-tool/king-louie: Easy to use GUI Personal AI Assistant. Win/Linux/Mac. Show HN I made my vacation rental bookable by AI agents–no Airbnb, 0% commission GitHub - basteez/jsf-autoreload: maven plugin to enable hot reload on jsf projects uvm32/hosts/host-gdbstub at main · ringtailsoftware/uvm32 GitHub - labsai/EDDI: Config-driven engine that turns JSON into production-grade AI agents. Multi-agent orchestration, 12+ LLM providers, MCP/A2A protocols, RAG, persistent memory, and enterprise compliance (EU AI Act, GDPR, HIPAA). Built on Quarkus. GitHub - glitchnsec/fortyone-oss: AI Executive Assistant Platform Quickstart | Alien GitHub - muxshed/shed: One stream in, or many. Every destination, simultaneously. No cloud middleman, no per-channel fees, no limits. GitHub - ocrbase-hq/ocrbase: 📄 PDF/IMG ->.MD/JSON Document OCR API for PaddleOCR and GLMOCR. Self-hostable. GitHub - impactjo/home-memory: MCP server that lets your AI assistant remember everything about your home. GitHub - Sets88/dbcls: DbCls is a powerful terminal database client that supports various databases GitHub - neptun2000/heor-agent-mcp GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh RollQuation: Math Puzzles - Apps on Google Play GitHub - dropbox/witchcraft Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis GitHub - opentalon/opentalon: OpenTalon is an open-source platform built from the ground up in Go as a robust alternative to OpenClaw LinkedIn™ 职位抓取工具 - Chrome 应用商店
GitHub - Reactance0083/pydantic-ai-multi-llm-cost-optimiz...
reactance008 · 2026-06-23 · via Hacker News: Show HN

Routes every prompt to the cheapest model that can handle it well. Uses pydantic-ai for the routing decision and litellm for unified execution across Claude, GPT-4o, and Groq. Tracks cost per model with a live /stats endpoint.

What It Does

  1. Receives a prompt with a quality tier (fast / standard / quality / max)
  2. Routes to the cheapest appropriate model using claude-haiku-4-5 as the router
  3. Executes via litellm (handles auth + API differences for all providers)
  4. Returns the response with cost breakdown and latency

Quick Start

pip install -r requirements.txt
cp .env.example .env
# Fill in at minimum ANTHROPIC_API_KEY. OPENAI and GROQ are optional.
uvicorn main:app --reload --port 8002

API Usage

POST /complete

curl -X POST http://localhost:8002/complete \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Summarize the key differences between REST and GraphQL",
    "quality": "standard",
    "task_type": "general"
  }'

Response:

{
  "text": "...",
  "model_used": "anthropic/claude-haiku-4-5",
  "input_tokens": 42,
  "output_tokens": 218,
  "cost_usd": 0.000283,
  "latency_ms": 847
}

GET /stats

{
  "models": {
    "anthropic/claude-haiku-4-5": {"calls": 47, "total_cost": 0.0134, "total_tokens": 52400}
  },
  "total_cost_usd": 0.0134,
  "total_calls": 47
}

Cost Table (May 2026)

Model Input/1k Output/1k Best For
groq/llama-3.1-8b-instant $0.00005 $0.00008 Fast, simple tasks
anthropic/claude-haiku-4-5 $0.00025 $0.00125 Structured outputs, classification
openai/gpt-4.1-mini $0.0004 $0.0016 General tasks, good value
anthropic/claude-sonnet-4-6 $0.003 $0.015 Code, complex reasoning
openai/gpt-4.1 $0.002 $0.008 Complex tasks
anthropic/claude-opus-4-7 $0.015 $0.075 Hardest tasks only
openai/gpt-5.5 $0.005 $0.015 Flagship reasoning, hardest tasks

Quality Tiers

Tier Models Considered Use When
fast Groq llama-8b, Claude haiku Low-stakes, high-volume, simple classification
standard Groq llama-70b, GPT-4o-mini, Claude haiku Most production tasks
quality Claude sonnet, GPT-4o Code generation, complex analysis
max Claude opus Hardest problems, highest stakes

Structured Routing (pydantic-ai)

class RoutingDecision(BaseModel):
    model: str           # exact litellm model string
    reason: str          # 1-sentence justification
    expected_tokens: int # rough output estimate

Architecture

POST /complete
  → routing agent (claude-haiku-4-5) → RoutingDecision
  → litellm.completion(model=decision.model, ...)
  → cost calculation → response + /stats update

Requirements

  • Python 3.11+
  • Anthropic API key (required)
  • OpenAI API key (optional, enables GPT routing)
  • Groq API key (optional, enables cheapest tier)

Get the Complete Bundle

All 5 templates are available individually or as a $39 bundle (saves $15 vs individual).

Template Price Link
Slack → Notion Automation $9 Buy on Gumroad
GitHub Issue → Linear Triage $9 Buy on Gumroad
Multi-LLM Cost Optimizer $12 Buy on Gumroad
Web Scraper + Semantic Search $9 Buy on Gumroad
Prompt Engineering Runbook $15 Buy on Gumroad
Complete Bundle (all 5) $39 Buy on Gumroad

Buying includes: all source files, README, requirements.txt, .env.example, and lifetime updates.

Free to use — the source is here on GitHub. Buying supports continued development and gets you a clean download with everything packaged.


Built by Wade Allen — AI Workflow Architect