@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 +132 -112
- package/index.js +14 -0
- package/package.json +24 -28
- /package/{src/index.d.ts → index.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# orbit-ai
|
|
2
2
|
|
|
3
3
|
> Stop blasting every query at GPT-4o. Route intelligently. Save 85%.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
28
|
+
---
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
import orbit from '@gabrielsmartin/orbit-sdk'
|
|
30
|
+
## How it works
|
|
34
31
|
|
|
35
|
-
|
|
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
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
49
|
+
## Usage
|
|
48
50
|
|
|
49
|
-
|
|
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
|
|
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
|
|
85
|
-
const
|
|
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
|
-
//
|
|
95
|
-
|
|
96
|
-
//
|
|
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
|
-
|
|
66
|
+
```javascript
|
|
67
|
+
import { OrbitClient } from 'orbit-ai'
|
|
102
68
|
|
|
103
|
-
|
|
104
|
-
|
|
69
|
+
const orbit = new OrbitClient({
|
|
70
|
+
cost_tolerance: 'low', // 'low' | 'medium' | 'high'
|
|
71
|
+
log: true, // logs routing decisions to console
|
|
72
|
+
})
|
|
105
73
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
[ORBIT] →
|
|
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
|
-
|
|
78
|
+
// Now call the model yourself with your keys
|
|
79
|
+
// model.id = 'gemini-2.5-flash', model.provider = 'google'
|
|
111
80
|
```
|
|
112
81
|
|
|
113
|
-
|
|
82
|
+
### Full pipeline example (with Anthropic SDK)
|
|
114
83
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
126
|
+
### Session stats
|
|
122
127
|
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
134
|
+
### Fingerprint only (no routing)
|
|
130
135
|
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
166
|
+
## The math
|
|
149
167
|
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
177
|
+
## Live demo
|
|
158
178
|
|
|
159
|
-
-
|
|
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]
|
|
168
|
-
- [x]
|
|
169
|
-
- [x]
|
|
170
|
-
- [
|
|
171
|
-
- [ ]
|
|
172
|
-
- [ ]
|
|
173
|
-
- [ ]
|
|
174
|
-
- [ ]
|
|
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
|
|
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
|
-
|
|
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.
|
|
4
|
-
"description": "Intelligent AI model routing. Drop-in replacement for OpenAI/Anthropic. Routes every query to the optimal model automatically.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
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
|
-
"
|
|
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 <
|
|
27
|
+
"author": "Gabriel Martin <admin@gtll.app>",
|
|
41
28
|
"license": "MIT",
|
|
42
29
|
"repository": {
|
|
43
30
|
"type": "git",
|
|
44
|
-
"url": "
|
|
31
|
+
"url": "https://github.com/gtllco/orbit"
|
|
45
32
|
},
|
|
46
|
-
"homepage": "https://
|
|
47
|
-
"
|
|
48
|
-
"
|
|
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": ">=
|
|
47
|
+
"node": ">=18.0.0"
|
|
52
48
|
}
|
|
53
|
-
}
|
|
49
|
+
}
|
|
File without changes
|