powergrid-ai 1.3.0 → 1.3.2

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