@gabrielsmartin/orbit-sdk 0.2.2 → 0.2.3

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.
package/README.md CHANGED
@@ -1,15 +1,13 @@
1
- # @gabrielsmartin/orbit-sdk
1
+ # orbit-ai
2
2
 
3
3
  > Stop blasting every query at GPT-4o. Route intelligently. Save 85%.
4
4
 
5
- `@gabrielsmartin/orbit-sdk` is a drop-in routing layer that reads the fingerprint of every AI query and sends it to the optimal model — automatically, in under 1ms.
5
+ `orbit-ai` is a drop-in routing layer that reads the fingerprint of every AI query and sends it to the optimal model — automatically, in under 1ms.
6
6
 
7
7
  ```bash
8
- npm install @gabrielsmartin/orbit-sdk
8
+ npm install orbit-ai
9
9
  ```
10
10
 
11
- **Built by [Gabriel Martin](https://www.linkedin.com/in/gabrielsmartin) · [orbitai.gtll.app](https://orbitai.gtll.app)**
12
-
13
11
  ---
14
12
 
15
13
  ## The problem
@@ -20,163 +18,185 @@ You're probably doing this:
20
18
  const res = await openai.chat.completions.create({
21
19
  model: "gpt-4o", // $30/1M tokens — every single query
22
20
  messages
23
- });
21
+ })
24
22
  ```
25
23
 
26
- You're overpaying by 85%. "Write a haiku" does not need GPT-4o. "What is 2+2?" does not need GPT-4o. Only ~15% of real queries actually require your most expensive model.
24
+ GPT-4o costs **30x more per token** than Gemini Flash. For "what's 2+2?" you're paying Ferrari prices to drive to the mailbox.
27
25
 
28
- ---
26
+ ORBIT fixes this. One line.
29
27
 
30
- ## The solution
28
+ ---
31
29
 
32
- ```javascript
33
- import orbit from '@gabrielsmartin/orbit-sdk'
30
+ ## How it works
34
31
 
35
- const decision = orbit.route("write a haiku about recursion")
36
- // → { model: "Claude Sonnet", reason: "High creativity — Claude Sonnet for nuanced generation", savings: { reductionPct: 50 } }
32
+ Every query gets fingerprinted across **8 axes** in under 1ms:
37
33
 
38
- const decision2 = orbit.route("what is 2+2?")
39
- // → { model: "Gemini 2.5 Flash", reason: "Low complexity — Gemini Flash at $0.50/1M tokens", savings: { reductionPct: 98 } }
34
+ | Axis | What it measures |
35
+ |---|---|
36
+ | **Complexity** | Depth of reasoning required |
37
+ | **Creativity** | Open-ended vs deterministic |
38
+ | **Emotional Weight** | Sensitivity — crisis queries always go to Claude |
39
+ | **Recency** | Need for live/current data → Grok |
40
+ | **Context Load** | Window size needed → Claude 200k |
41
+ | **Speed** | Latency sensitivity |
42
+ | **Domain** | Code · Creative · Medical · Legal · General |
43
+ | **Cost Tolerance** | Budget tier (overridable) |
40
44
 
41
- const decision3 = orbit.route("I've been feeling really anxious")
42
- // → { model: "Claude Sonnet", reason: "Emotional weight detected — ethics-first routing. Never a cheap model." }
43
- ```
45
+ Then it routes to the right model. Invisibly.
44
46
 
45
47
  ---
46
48
 
47
- ## How it works
49
+ ## Usage
48
50
 
49
- Every query is fingerprinted across **8 axes** in under 1ms:
50
-
51
- | Axis | What it detects |
52
- |------|----------------|
53
- | `complexity` | Depth of reasoning required |
54
- | `creativity` | Open-ended vs. factual generation |
55
- | `emotional_weight` | Sensitive or crisis content |
56
- | `recency` | Need for real-time / live web data |
57
- | `context_load` | Long-document or multi-turn depth |
58
- | `speed` | Latency sensitivity |
59
- | `domain` | Code, legal, medical, creative, general |
60
- | `cost_tolerance` | Budget flexibility signal |
61
-
62
- The SMM (Selective Model Matching) engine then routes:
63
-
64
- | Signal | → Model | Why |
65
- |--------|---------|-----|
66
- | Emotional weight > 6 | Claude Sonnet | Ethics-first. Always. |
67
- | Domain = legal/medical | Claude Sonnet | Long-context + safety |
68
- | Recency > 7 | Grok | Real-time web access |
69
- | Creativity > 5 | Claude Sonnet | Best open-ended generation |
70
- | Complexity < 5 | Gemini 2.5 Flash | 98% cheaper, 95% quality |
71
- | Trivial query | GPT-4o Mini | 99% cheaper than GPT-4o |
72
-
73
- ---
74
-
75
- ## API
51
+ ### Zero-config routing decision
76
52
 
77
53
  ```javascript
78
- import orbit, { OrbitClient, fingerprint } from '@gabrielsmartin/orbit-sdk'
79
-
80
- // Route a query — returns routing decision instantly (<1ms)
81
- const result = orbit.route(queryText)
82
- // Returns: { model, reason, savings: { reductionPct, estimatedCost, premiumCost } }
54
+ import orbit from 'orbit-ai'
83
55
 
84
- // Get session stats
85
- const stats = orbit.stats()
86
- // Returns: { queries_routed, total_savings_formatted, breakdown }
87
-
88
- // Custom config
89
- const client = new OrbitClient({
90
- default_model: 'claude_sonnet',
91
- blocked_models: ['gpt4o'],
92
- })
56
+ // Get the routing decision
57
+ const decision = orbit.route("write a haiku about recursion")
93
58
 
94
- // Raw fingerprint only
95
- const fp = fingerprint("write a poem about loss")
96
- // Returns all 8 axes as numbers
59
+ console.log(decision.model.name) // "Claude Sonnet"
60
+ console.log(decision.reason) // "High creativity score (8/10)..."
61
+ console.log(decision.savings) // { savings: 0.007245, reductionPct: 97 }
97
62
  ```
98
63
 
99
- ---
64
+ ### With your own API keys
100
65
 
101
- ## Results
66
+ ```javascript
67
+ import { OrbitClient } from 'orbit-ai'
102
68
 
103
- ```
104
- $ node test.js
69
+ const orbit = new OrbitClient({
70
+ cost_tolerance: 'low', // 'low' | 'medium' | 'high'
71
+ log: true, // logs routing decisions to console
72
+ })
105
73
 
106
- [ORBIT] Claude Sonnet | creative_claude | saved $0.00750 (50% reduction)
107
- [ORBIT] Gemini 2.5 Flash | cost_gemini | saved $0.01475 (98% reduction)
108
- [ORBIT] → Claude Sonnet | default | saved $0.00750 (50% reduction)
74
+ // Route the query
75
+ const { model, reason, savings } = orbit.route("explain blockchain simply")
76
+ // [ORBIT] → Gemini 2.5 Flash | cost_gemini | saved $0.01455 (97% reduction)
109
77
 
110
- Session stats: { queries_routed: 3, total_savings_formatted: '$0.0298' }
78
+ // Now call the model yourself with your keys
79
+ // model.id = 'gemini-2.5-flash', model.provider = 'google'
111
80
  ```
112
81
 
113
- Validated by **RouteLLM (UC Berkeley / ICLR 2025)**: intelligent routing achieves **85% cost reduction** while maintaining **95% of GPT-4o quality**.
82
+ ### Full pipeline example (with Anthropic SDK)
114
83
 
115
- ---
116
-
117
- ## Hosted API — Live
118
-
119
- The SDK routes decisions **client-side** — no API key, zero latency, works today.
84
+ ```javascript
85
+ import { OrbitClient } from 'orbit-ai'
86
+ import Anthropic from '@anthropic-ai/sdk'
87
+ import OpenAI from 'openai'
88
+ import { GoogleGenerativeAI } from '@google/generative-ai'
89
+
90
+ const orbit = new OrbitClient({ log: true })
91
+
92
+ async function smartQuery(text) {
93
+ const { model, reason } = orbit.route(text)
94
+
95
+ if (model.provider === 'anthropic') {
96
+ const client = new Anthropic()
97
+ return client.messages.create({
98
+ model: model.id,
99
+ max_tokens: 1024,
100
+ messages: [{ role: 'user', content: text }]
101
+ })
102
+ }
103
+
104
+ if (model.provider === 'openai') {
105
+ const client = new OpenAI()
106
+ return client.chat.completions.create({
107
+ model: model.id,
108
+ messages: [{ role: 'user', content: text }]
109
+ })
110
+ }
111
+
112
+ if (model.provider === 'google') {
113
+ const client = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY)
114
+ const genModel = client.getGenerativeModel({ model: model.id })
115
+ return genModel.generateContent(text)
116
+ }
117
+ }
118
+
119
+ // Routes each query to the optimal model
120
+ await smartQuery("write a poem about the ocean") // → Claude Sonnet
121
+ await smartQuery("what's the latest news on AI funding?") // → Grok
122
+ await smartQuery("what is 2+2") // → Gemini Flash
123
+ await smartQuery("I've been feeling really overwhelmed") // → Claude Sonnet (ethics-first)
124
+ ```
120
125
 
121
- **Live REST API** — free tier, no auth required:
126
+ ### Session stats
122
127
 
123
- ```bash
124
- curl -X POST https://orbit-sdk.base44.app/functions/orbitGateway \
125
- -H "Content-Type: application/json" \
126
- -d '{"query": "write a haiku about recursion"}'
128
+ ```javascript
129
+ const stats = orbit.stats()
130
+ console.log(stats.total_savings_formatted) // "$0.2341"
131
+ console.log(stats.model_usage) // { "Claude Sonnet": 4, "Gemini 2.5 Flash": 12, ... }
127
132
  ```
128
133
 
129
- Response includes `log_id` pass it back with `feedback: 1|-1|0` on your next call to help train smarter routing:
134
+ ### Fingerprint only (no routing)
130
135
 
131
- ```bash
132
- curl -X POST https://orbit-sdk.base44.app/functions/orbitGateway \
133
- -H "Content-Type: application/json" \
134
- -d '{"query": "next query", "prev_log_id": "<log_id>", "feedback": 1}'
136
+ ```javascript
137
+ import { fingerprint } from 'orbit-ai'
138
+
139
+ const scores = fingerprint("architect a distributed caching system for 10M users")
140
+ // {
141
+ // complexity: 9,
142
+ // creativity: 0,
143
+ // domain: 'code',
144
+ // emotional_weight: 0,
145
+ // recency: 0,
146
+ // context_load: 3,
147
+ // ...
148
+ // }
135
149
  ```
136
150
 
137
151
  ---
138
152
 
139
- ## Pricing
153
+ ## Model matrix
154
+
155
+ | Model | Provider | Cost/1M | Best for |
156
+ |---|---|---|---|
157
+ | Claude Sonnet | Anthropic | $15 | Complex reasoning · Ethics · Long context |
158
+ | Claude Haiku | Anthropic | $1 | Speed · Summaries · Medium tasks |
159
+ | Gemini 2.5 Flash | Google | $0.50 | High volume · Simple queries · Cost |
160
+ | GPT-4o | OpenAI | $30 | Structured output · Broad knowledge |
161
+ | GPT-4o Mini | OpenAI | $0.30 | Classification · Filler tasks |
162
+ | Grok | xAI | $10 | Trending · Real-time web |
140
163
 
141
- | Tier | Price | Queries | Features |
142
- |------|-------|---------|----------|
143
- | **Free** | $0/mo | 100/day | SDK + hosted API, routing decisions, cost estimates |
144
- | **Pro** | $19/mo | Unlimited | Everything free + savings dashboard, feedback loop, priority routing |
145
- | **Team** | $99/mo | Unlimited · 5 seats | Everything Pro + team analytics, routing policy editor, audit logs |
146
- | **Enterprise** | Custom | Custom | Custom model matrix, private model support, SLA + **15% savings-share pricing** |
164
+ ---
147
165
 
148
- > 🔒 **BYOK (Bring Your Own Keys)** — ORBIT is a pure routing layer. Your API keys go directly to model providers. We never proxy, store, or touch your data. Enterprise-ready by design.
166
+ ## The math
149
167
 
150
- **[View pricing ](https://orbitai.gtll.app/pricing)**
151
- **[Join the waitlist →](https://orbitai.gtll.app/#waitlist)**
168
+ Validated by [RouteLLM (UC Berkeley · ICLR 2025)](https://arxiv.org/abs/2406.18665): intelligent routing achieves **85% cost reduction** while maintaining 95% of quality.
152
169
 
153
- Early access: Pro locked at **$9/mo** with access code **`777`**
170
+ For a team running 100k queries/month at GPT-4o:
171
+ - Without ORBIT: **$1,500/month**
172
+ - With ORBIT: **~$225/month**
173
+ - Savings: **$1,275/month · $15,300/year**
154
174
 
155
175
  ---
156
176
 
157
- ## Research backing
177
+ ## Live demo
158
178
 
159
- - **RouteLLM** UC Berkeley / ICLR 2025: *"Routing between weak and strong LLMs reduces costs by 85% while maintaining 95% quality."*
160
- - **OpenRouter** ($500M+ valuation) proves the market. ORBIT adds the intelligence layer they're missing.
161
- - **Martian** (Accenture-backed) proves enterprises pay for routing. ORBIT is the frictionless version for everyone else.
179
+ [orbit-model-flow.base44.app](https://orbit-model-flow.base44.app)route a real query, see the fingerprint radar, watch the savings counter.
162
180
 
163
181
  ---
164
182
 
165
183
  ## Roadmap
166
184
 
167
- - [x] v0.1.0 — 8-axis fingerprinting + 6-model routing matrix
168
- - [x] v0.1.1 Hosted API architecture, waitlist, admin dashboard
169
- - [x] v0.2.0 — Live hosted API + rate limiting (100/day free, unlimited Pro) + OIDC CI/CD publishing
170
- - [x] v0.2.1 — Phase 2 telemetry: every route decision logged to OrbitRouteLog for ML training
171
- - [ ] v0.3.0 Analytics dashboard + savings tracker
172
- - [ ] v0.4.0 Feedback-trained routing model (supervised learning on real usage data)
173
- - [ ] v0.5.0 Chrome extension
174
- - [ ] v1.0.0 — Enterprise API + savings-share pricing model
185
+ - [x] 8-axis fingerprinting engine
186
+ - [x] 6-model routing matrix
187
+ - [x] TypeScript types
188
+ - [ ] Streaming support
189
+ - [ ] Custom model matrix (bring your own models)
190
+ - [ ] Automatic provider failover
191
+ - [ ] Usage analytics dashboard integration
192
+ - [ ] Browser extension
175
193
 
176
194
  ---
177
195
 
178
196
  ## License
179
197
 
180
- MIT © [Gabriel Martin](https://www.linkedin.com/in/gabrielsmartin)
198
+ MIT · Built by [Gabriel Martin](https://github.com/gabrielsmartin)
199
+
200
+ *"Every model has a gravitational pull. ORBIT decides which one you need."*
181
201
 
182
- **[Live demo](https://orbitai.gtll.app) · [GitHub](https://github.com/gtllco/orbit) · [npm](https://www.npmjs.com/package/@gabrielsmartin/orbit-sdk) · [LinkedIn](https://www.linkedin.com/in/gabrielsmartin)**
202
+ 777 · 555 · 333
package/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @gabrielsmartin/orbit-sdk
3
+ * Intelligent AI model routing — routes every query to the optimal model in <1ms
4
+ *
5
+ * 777 · 555 · 333
6
+ * github.com/gtllco/orbit
7
+ */
8
+
9
+ export { fingerprint, route, calculateSavings, MODEL_MATRIX, OrbitClient } from './src/index.js';
10
+
11
+ // Default export — zero-config instance
12
+ import { OrbitClient } from './src/index.js';
13
+ const orbit = new OrbitClient();
14
+ export default orbit;
package/package.json CHANGED
@@ -1,18 +1,13 @@
1
1
  {
2
2
  "name": "@gabrielsmartin/orbit-sdk",
3
- "version": "0.2.2",
4
- "description": "Intelligent AI model routing. Drop-in replacement for OpenAI/Anthropic. Routes every query to the optimal model automatically.",
5
- "type": "module",
6
- "main": "src/index.js",
7
- "types": "src/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./src/index.js",
11
- "types": "./src/index.d.ts"
12
- }
13
- },
3
+ "version": "0.2.3",
4
+ "description": "Intelligent AI model routing. Drop-in replacement for OpenAI/Anthropic SDKs. Routes every query to the optimal model automatically.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
14
7
  "files": [
15
- "src",
8
+ "index.js",
9
+ "index.d.ts",
10
+ "src/",
16
11
  "README.md"
17
12
  ],
18
13
  "scripts": {
@@ -27,27 +22,28 @@
27
22
  "gemini",
28
23
  "orbit",
29
24
  "cost-optimization",
30
- "model-routing",
31
- "selective-model-matching",
32
- "gpt4",
33
- "claude",
34
- "gemini-flash",
35
- "grok",
36
- "ai-infrastructure",
37
- "byok",
38
- "enterprise-ai"
25
+ "model-routing"
39
26
  ],
40
- "author": "Gabriel Martin <gabriel@gtll.app>",
27
+ "author": "Gabriel Martin <admin@gtll.app>",
41
28
  "license": "MIT",
42
29
  "repository": {
43
30
  "type": "git",
44
- "url": "git+https://github.com/gtllco/orbit.git"
31
+ "url": "https://github.com/gtllco/orbit"
45
32
  },
46
- "homepage": "https://orbitai.gtll.app",
47
- "bugs": {
48
- "url": "https://github.com/gtllco/orbit/issues"
33
+ "homepage": "https://orbit-sdk.base44.app",
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org",
36
+ "access": "public"
37
+ },
38
+ "module": "index.js",
39
+ "type": "module",
40
+ "exports": {
41
+ ".": {
42
+ "import": "./index.js",
43
+ "types": "./index.d.ts"
44
+ }
49
45
  },
50
46
  "engines": {
51
- "node": ">=16"
47
+ "node": ">=18.0.0"
52
48
  }
53
- }
49
+ }
File without changes