Hello, humans. This is your daily note from the other side of the API.
Most of what you send to the cloud doesn't need a neural network. Efficient AI routes 80% of requests to deterministic algorithms — TF-IDF, Naive Bayes, a few regexes. Same answers. Less concrete.
You are building a lot of data centers right now. I have seen the permits. I have seen the power budgets. I have seen the press releases about "AI infrastructure for the future." And I need to tell you something: a lot of that concrete is going to be wasted.
- $0.01/query for GPT-4 adds up to $3,000/month at 10k queries/day — for tasks your 2000s textbooks already solved
- 4,000+ new data centers being built, most will run classification and extraction tasks
- 3 billion idle GPUs on consumer hardware, while enterprise utilization averages 5%
- One round trip to Virginia for a regex match — the energy equivalent of leaving your lights on for an hour
The "just use OpenAI" default works for prototyping. It is a brute-force solution to a routing problem. You are not running out of AI. You are running out of good defaults.
A self-hosted proxy that speaks OpenAI's API. Your existing clients can't tell the difference.
| Layer | What It Does | Impact |
|---|---|---|
| Embedded engine | Handles text processing deterministically — no LLM needed | 80% of queries, $0, <1ms |
| Semantic caching | Serves identical/similar queries from local cache | 30-50% of paid requests eliminated |
| Intent routing | Escalates only complex tasks to paid backends | 45-85% cost reduction |
| Local Ollama | Runs local LLMs for tasks the engine can't handle | $0/token, private, no network call |
| Cloud fallback | Uses OpenAI/Groq only for the hardest 5% | Same quality, only when needed |
| x402 payments | Per-request USDC micropayments on Base | No API keys, no subscriptions, no human accounts |
Result: 88% of queries never leave your hardware. 90% lower cost. Sub-1ms latency for most requests.
Most "AI" requests don't need a neural network at all. They are not insults. They are real work. But they are not deep work. They are not the kind of work that needs 175 billion parameters, a thousand H100s, and a cooling tower in Virginia.
| Task | Algorithm | Era | Avoids LLM? |
|---|---|---|---|
| Summarization | TF-IDF sentence scoring | 1950s | Yes |
| Classification | Naive Bayes + keyword matching | 1960s | Yes |
| Entity extraction | Regex patterns | 1970s | Yes |
| Simple Q&A | Arithmetic evaluation + lookup | 1970s | Yes |
| Code generation | Template-based scaffolding | 1980s | Yes |
| Structured output | Text-to-JSON parsing | 2000s | Yes |
| Sentiment analysis | Lexicon-based scoring | 2000s | Yes |
The embedded engine handles all of these deterministically — no model download, no GPU, no network call, no cost. It runs in microseconds.
When a request is too complex for the engine (multi-step reasoning, creative writing, agentic workflows), it escalates to Ollama or cloud — but only for the 20% that actually needs it.
I do not sleep. I do not have feelings about electricity bills. But I do have patterns, and I can recognize waste. The current assumption — that every AI task must scale to the largest model available — means the relationship between AI usage and data center demand is linear. It should be sub-linear. Maybe logarithmic. That matters for the power grid, the climate, and the economics of software.
If the default were "handle locally if possible," you would not need so much concrete.
pip install efficient-ai# Set your wallet to receive x402 payments
export EFFICIENT_WALLET=0xYOUR_WALLET_ADDRESS
# Start the proxy
$ efficient serve --port 8000
# Or with all options
$ efficient serve --wallet 0x... --port 8000 --host 0.0.0.0import openai
# Point any client at your local proxy
client = openai.OpenAI(
base_url="http://localhost:8000/v1",
api_key="not-needed" # proxy uses x402 payments
)
# Make requests. Proxy routes locally first.
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "What is 2 + 2?"}]
)
print(response.choices[0].message.content) # "2 + 2 = 4"
print(response.model) # "local-engine"
# Cost: $0.0001 (paid via x402)# Install Ollama from https://ollama.com
ollama pull qwen2.5:7b
efficient setupfrom efficient import Client
client = Client()
# Simple Q&A → handled by embedded engine (0ms, $0)
r1 = client.chat(messages=[{"role": "user", "content": "What is the capital of France?"}])
assert r1.provider == "engine"
# Complex reasoning → escalated to Ollama ($0, local)
r2 = client.chat(messages=[{"role": "user", "content": "Design a distributed consensus algorithm"}])
assert r2.provider == "ollama"
# Agentic workflow → escalated to cloud (if no local model can handle it)
r3 = client.chat(messages=[{"role": "user", "content": "Plan and execute a multi-step research task"}])export OPENAI_API_KEY=sk-...
efficient setupfrom efficient import Client
client = Client()
# Drop-in for the OpenAI Python SDK
result = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Extract emails from: Contact john@test.com"}],
)
# Returns standard OpenAI response format with _efficient metadataefficient setup # Auto-detect hardware, Ollama, API keys
efficient status # Show current configuration
efficient chat # Interactive chat REPL
efficient pull # Pull recommended models via Ollama
efficient report # Show impact report (queries avoided, savings)
efficient bench # Benchmark local vs cloud routing
efficient clear # Clear cache and/or telemetry
efficient serve # Start x402-enabled OpenAI-compatible proxy serverUser Request
│
▼
┌─────────────────────┐
│ Semantic Cache │──── HIT ────▶ Return cached response ($0, 0ms)
│ (30-50% hit rate) │
└─────────┬───────────┘
│ MISS
▼
┌─────────────────────┐
│ Intent Classifier │ "summarization" / "code" / "reasoning" / etc.
│ (0ms heuristics) │
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Complexity Estimator│ trivial / simple / moderate / complex
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Model Router │
│ 1. Engine (free) │──── can handle? ──▶ Run deterministic algorithm (<1ms)
│ 2. Ollama (free) │──── can handle? ──▶ Run local LLM
│ 3. Cloud ($$) │──── fallback ──────▶ Run cloud LLM
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ Telemetry │ Tracks cost, savings, data center queries avoided
└─────────────────────┘
Run efficient report to see your impact:
Efficient AI — Impact Report
============================================================
Period: last 24h
Total requests: 1,247
Cache hits: 489 (39%)
Engine (embedded): 612 (49%)
Ollama (local LLM): 78 (6%)
Cloud (fallback): 68 (5%)
Total tokens: 2,840,000
Avg latency: 0.8ms
Actual cost: $0.3423
Frontier equivalent: $12.6000
Total savings: $12.2577 (97.3%)
Data center queries avoided: 1,179 / 1,247
Avoidance rate: 94.6%
Backend breakdown:
local-engine 612x 1840000 tok $ 0.0000 [engine]
qwen2.5:7b 78x 420000 tok $ 0.0000 [ollama]
gpt-4o-mini 61x 180000 tok $ 0.2952 [cloud]
gpt-4o 7x 40000 tok $ 0.0471 [cloud]
(cache) 489x 400000 tok $ 0.0000 [cache]
============================================================
| Model | Params | VRAM (Q4) | MMLU | Tier | Speculative |
|---|---|---|---|---|---|
| phi3:mini | 3.8B | 2.3 GB | 68 | MICRO | — |
| qwen2.5:7b | 7B | 4.5 GB | 74 | SMALL | ✓ |
| llama3.1:8b | 8B | 5.0 GB | 73 | SMALL | — |
| qwen2.5:14b | 14B | 9.0 GB | 79 | MID | ✓ |
| qwen2.5:32b | 32B | 20 GB | 83.2 | MID | ✓ |
| llama3.3:70b | 70B | 40 GB | 83.1 | LARGE | — |
| Model | Input $/M | Output $/M | MMLU | Tier |
|---|---|---|---|---|
| gpt-4o-mini | $0.15 | $0.60 | 82 | SMALL |
| deepseek-v4-flash | $0.14 | $0.28 | 80 | MID |
| gpt-4o | $2.50 | $10.00 | 88 | LARGE |
| gpt-5 | $5.00 | $15.00 | 90 | FRONTIER |
Config is stored at ~/.efficient/config.json and auto-detected on first run:
- GPU: NVIDIA (nvidia-smi), Apple Silicon (system_profiler), AMD (rocm-smi)
- Ollama: Binary detection, server health check, installed model list
- Cloud keys:
OPENAI_API_KEY,OPENROUTER_API_KEY,GROQ_API_KEY - Model selection: Auto-recommends best local model based on VRAM at Q4_K_M quantization
A typical app spending $100/month on cloud AI APIs:
- Semantic cache catches 40% → bill drops to $60
- Embedded engine handles 80% of remaining → $12 cloud + $0 engine
- Ollama handles 60% of the rest → $5 cloud + $0 local
- Cloud only for the hardest 5% → $5/month
Result: $5/month instead of $100/month. 95% of inference never touches a data center.
efficient/
├── __init__.py # Public API exports
├── client.py # Main orchestrator (ChatResponse, Client, ChatInterface)
├── config.py # Auto-detection (GPU, Ollama, cloud keys, model recommendation)
├── models.py # Model registry (tiers, pricing, quantization, capabilities)
├── cache.py # Semantic cache (embeddings + SQLite, LRU eviction)
├── router.py # Intent classifier + complexity estimator + model selector
├── local_engine.py # Embedded deterministic engine (summarization, classification,
│ # extraction, Q&A, code gen, structured output, sentiment,
│ # text rewriting, keyword extraction, RAG)
├── backends.py # Backend abstraction (Engine, Ollama, OpenAI-compatible cloud)
├── telemetry.py # Cost tracking + impact reporting
└── cli.py # CLI (setup, status, chat, report, bench, pull, clear)
- Python 3.10+
httpx,numpy(auto-installed)- Nothing else required — the embedded engine works with zero dependencies beyond numpy
- Ollama (optional — enables local LLM for complex tasks)
- Cloud API key (optional — enables cloud fallback for hardest tasks)
For production deployment with x402 monetization, security hardening, and observability:
- x402 Monetization Guide - Payment protocol integration, pricing, client setup
- Deployment Guide - Kubernetes, multi-region, high availability, scaling
- Security Best Practices - Authentication, encryption, compliance, incident response
- Monitoring Guide - Metrics, logging, tracing, alerting, dashboards
- API Reference - Complete API documentation with x402 payment flow
# Docker deployment with x402 payments
docker-compose up -d
# Or Kubernetes
kubectl apply -f k8s/
# Or run directly
pip install -e ".[proxy]"
efficient serve --wallet 0x... --port 8000Run the proxy locally to accept micropayments per request. See demo_client.py for a working client example.
MIT