powergrid-ai 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +267 -0
  2. package/package.json +2 -1
package/README.md ADDED
@@ -0,0 +1,267 @@
1
+ <p align="center">
2
+ <img src="https://img.shields.io/badge/Local-First-blueviolet?style=for-the-badge" alt="Local-First">
3
+ <img src="https://img.shields.io/badge/OpenAI-Compatible-black?style=for-the-badge" alt="OpenAI-Compatible">
4
+ <img src="https://img.shields.io/badge/Routing-Intelligent-brightgreen?style=for-the-badge" alt="Routing">
5
+ </p>
6
+
7
+ <h1 align="center">PowerGrid</h1>
8
+
9
+ <p align="center">
10
+ <strong>One AI. Many engines. Zero vendor lock-in.</strong><br>
11
+ Local-first AI routing runtime that turns multiple AI providers into a single OpenAI-compatible endpoint.
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://www.npmjs.com/package/powergrid-ai"><img src="https://img.shields.io/npm/v/powergrid-ai?style=flat-square" alt="npm"></a>
16
+ <a href="https://pypi.org/project/powergrid-ai"><img src="https://img.shields.io/pypi/v/powergrid?style=flat-square" alt="PyPI"></a>
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## What is PowerGrid?
22
+
23
+ PowerGrid runs on your machine and makes multiple AI providers appear as **one endpoint**. Your apps talk to `localhost:8787`, and PowerGrid handles routing, failover, caching, and rate limit prediction — automatically.
24
+
25
+ ```
26
+ Your App ──→ localhost:8787/v1 ──→ PowerGrid ──→ Gemini
27
+ ├─→ Groq
28
+ ├─→ Cerebras
29
+ ├─→ OpenRouter
30
+ └─→ Ollama (local)
31
+ ```
32
+
33
+ **No vendor lock-in. No cloud dependency. Your keys never leave your machine.**
34
+
35
+ ---
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ npm install -g powergrid-ai
41
+ ```
42
+
43
+ The npm package detects Python 3.11+ and auto-installs the Python backend if needed.
44
+
45
+ ### Requirements
46
+
47
+ - **Python 3.11+** must be on your PATH
48
+ - The first run will auto-install `powergrid-ai` via pip
49
+
50
+ ---
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ # Setup — walks you through adding providers
56
+ powergrid setup
57
+
58
+ # Start the runtime
59
+ powergrid start
60
+
61
+ # Use it from any OpenAI-compatible client
62
+ curl http://localhost:8787/v1/chat/completions \
63
+ -H "Content-Type: application/json" \
64
+ -d '{
65
+ "model": "powergrid-auto",
66
+ "messages": [{"role": "user", "content": "Hello!"}]
67
+ }'
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Supported Providers
73
+
74
+ ### Core (free, no credit card required)
75
+
76
+ | Provider | Free Tier | Speed | Best For |
77
+ |----------|-----------|-------|----------|
78
+ | Google Gemini | Generous | Fast | General, reasoning, large context |
79
+ | Groq | 30 RPM | Blazing | Fast response, coding, tool calling |
80
+ | Cerebras | Generous | Very Fast | Large context, reasoning |
81
+ | OpenRouter | Rotating free models | Varies | Model variety, fallback |
82
+ | NVIDIA NIM | Generous | Fast | Large model catalog |
83
+ | Ollama | Unlimited (local) | Local | Privacy, offline, zero cost |
84
+
85
+ ### Extended
86
+
87
+ | Provider | Notes |
88
+ |----------|-------|
89
+ | Mistral AI | Strong European models, Codestral |
90
+ | Hugging Face | Open-source ecosystem |
91
+ | SambaNova | High-performance inference |
92
+ | Together AI | Open-source model hosting |
93
+ | Cloudflare Workers AI | Edge inference |
94
+ | Cohere | RAG + embeddings specialist |
95
+ | GitHub Models | Great selection via GitHub |
96
+
97
+ ### Community / Experimental
98
+
99
+ | Provider | Notes |
100
+ |----------|-------|
101
+ | SiliconFlow | Chinese/open-source models |
102
+ | Chutes AI | Decentralized inference |
103
+ | **Any OpenAI-compatible API** | Just provide a base URL |
104
+
105
+ ---
106
+
107
+ ## How It Works
108
+
109
+ ### Intelligent Routing (default)
110
+
111
+ Every request is analyzed and routed to the best provider based on:
112
+
113
+ ```
114
+ Request → Task Classification → Provider Scoring → Best Match
115
+ │ │
116
+ ├─ coding ├─ health (uptime %)
117
+ ├─ reasoning ├─ quota (RPM remaining)
118
+ ├─ creative ├─ capability match
119
+ ├─ fast_response ├─ priority weight
120
+ └─ long_context └─ latency score
121
+ ```
122
+
123
+ ### Automatic Failover
124
+
125
+ ```
126
+ Request → Provider A
127
+
128
+ ├─ 200 OK → return response
129
+ ├─ 429 Rate Limited → cooldown → retry Provider B
130
+ ├─ 5xx Error → backoff → retry Provider C
131
+ └─ Timeout → retry Provider B
132
+ ```
133
+
134
+ ### Predictive Rate Limit Protection
135
+
136
+ PowerGrid tracks usage patterns and shifts traffic **before** you hit rate limits.
137
+
138
+ ---
139
+
140
+ ## CLI Reference
141
+
142
+ | Command | Description |
143
+ |---------|-------------|
144
+ | `powergrid setup` | Interactive setup wizard |
145
+ | `powergrid init` | Initialize configuration |
146
+ | `powergrid start` | Start the runtime |
147
+ | `powergrid start --background` | Start as background process |
148
+ | `powergrid stop` | Stop background process |
149
+ | `powergrid status` | Show runtime status |
150
+ | `powergrid providers` | List configured providers |
151
+ | `powergrid provider` | Add provider interactively |
152
+ | `powergrid provider-remove NAME` | Remove a provider |
153
+ | `powergrid models` | List available models |
154
+ | `powergrid logs` | Show recent routing decisions |
155
+ | `powergrid test` | Test provider connectivity |
156
+ | `powergrid config` | Show config (redacted) |
157
+ | `powergrid cache-clear` | Clear response cache |
158
+ | `powergrid --version` | Show version |
159
+
160
+ ---
161
+
162
+ ## Agent Integrations
163
+
164
+ PowerGrid works with any tool that speaks the OpenAI API format.
165
+
166
+ ### OpenCode
167
+
168
+ ```json
169
+ {
170
+ "provider": {
171
+ "name": "powergrid",
172
+ "model": "powergrid-auto",
173
+ "api_key": "powergrid",
174
+ "base_url": "http://localhost:8787/v1"
175
+ }
176
+ }
177
+ ```
178
+
179
+ ### Claude Code / Codex / Aider
180
+
181
+ ```bash
182
+ export OPENAI_BASE_URL=http://localhost:8787/v1
183
+ export OPENAI_API_KEY=powergrid
184
+ ```
185
+
186
+ ### Cline (VS Code)
187
+
188
+ ```json
189
+ {
190
+ "cline.apiProvider": "openai-compatible",
191
+ "cline.openaiCompatibleBaseUrl": "http://localhost:8787/v1",
192
+ "cline.openaiCompatibleApiKey": "powergrid",
193
+ "cline.openaiCompatibleModelId": "powergrid-auto"
194
+ }
195
+ ```
196
+
197
+ ### Python
198
+
199
+ ```python
200
+ from openai import OpenAI
201
+
202
+ client = OpenAI(base_url="http://localhost:8787/v1", api_key="powergrid")
203
+ response = client.chat.completions.create(
204
+ model="powergrid-auto",
205
+ messages=[{"role": "user", "content": "Hello!"}]
206
+ )
207
+ ```
208
+
209
+ ### Node.js
210
+
211
+ ```javascript
212
+ import OpenAI from "openai";
213
+
214
+ const client = new OpenAI({
215
+ baseURL: "http://localhost:8787/v1",
216
+ apiKey: "powergrid",
217
+ });
218
+
219
+ const response = await client.chat.completions.create({
220
+ model: "powergrid-auto",
221
+ messages: [{ role: "user", content: "Hello!" }],
222
+ });
223
+ ```
224
+
225
+ ---
226
+
227
+ ## API Endpoints
228
+
229
+ | Endpoint | Method | Description |
230
+ |----------|--------|-------------|
231
+ | `/v1/models` | GET | List available models |
232
+ | `/v1/chat/completions` | POST | Chat completions (OpenAI-compatible) |
233
+ | `/health` | GET | Health check with provider status |
234
+ | `/status` | GET | PowerGrid status and stats |
235
+ | `/providers` | GET | Provider details (keys redacted) |
236
+ | `/routing/logs` | GET | Recent routing decisions |
237
+ | `/routing/stats` | GET | Aggregate routing statistics |
238
+
239
+ ---
240
+
241
+ ## Security & Privacy
242
+
243
+ - **Local-only by default** — binds to `127.0.0.1`
244
+ - **Keys stored securely** — OS credential store, not config files
245
+ - **No telemetry** — zero data sent anywhere
246
+ - **No key leakage** — API keys never appear in logs or responses
247
+ - **Config redaction** — `powergrid config` masks secrets
248
+
249
+ ---
250
+
251
+ ## Links
252
+
253
+ - [PyPI Package](https://pypi.org/project/powergrid-ai)
254
+ - [GitHub](https://github.com/micymike/powergrid)
255
+ - [Issues](https://github.com/micymike/powergrid/issues)
256
+
257
+ ---
258
+
259
+ ## License
260
+
261
+ MIT
262
+
263
+ ---
264
+
265
+ <p align="center">
266
+ Built with ❤️ by <a href="https://github.com/micymike">Michael Moses</a>
267
+ </p>
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "powergrid-ai",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Local-first AI routing runtime — one AI, many engines. Wraps the Python powergrid-ai package.",
5
+ "readmeFilename": "README.md",
5
6
  "keywords": [
6
7
  "ai",
7
8
  "routing",