@agentlify/mcp-server 2.0.0
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 +230 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +841 -0
- package/dist/index.js.map +1 -0
- package/docs/cost-optimization.md +281 -0
- package/docs/example-chatbot.md +424 -0
- package/docs/migration-anthropic.md +192 -0
- package/docs/migration-openai.md +383 -0
- package/docs/pricing.md +351 -0
- package/docs/quickstart.md +242 -0
- package/docs/router-configuration.md +644 -0
- package/docs/routing-strategies.md +236 -0
- package/docs/sdk-javascript.md +253 -0
- package/docs/sdk-python.md +52 -0
- package/package.json +40 -0
- package/src/index.ts +946 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
# Migrating from OpenAI to Agentlify
|
|
2
|
+
|
|
3
|
+
**Zero code changes required** - Keep using the OpenAI SDK with Agentlify's intelligent routing!
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Why Use Agentlify?
|
|
8
|
+
|
|
9
|
+
✅ **40-60% cost savings** with intelligent model routing
|
|
10
|
+
✅ **Zero code changes** - just update SDK configuration
|
|
11
|
+
✅ **Automatic fallbacks** for improved reliability
|
|
12
|
+
✅ **100+ models** from OpenAI, Anthropic, Google, and more
|
|
13
|
+
✅ **Real-time cost tracking** with detailed analytics
|
|
14
|
+
✅ **Multi-provider access** through familiar OpenAI interface
|
|
15
|
+
|
|
16
|
+
## Quick Comparison
|
|
17
|
+
|
|
18
|
+
| Feature | OpenAI Only | Agentlify |
|
|
19
|
+
| ---------------- | ----------------------- | ----------------------------- |
|
|
20
|
+
| Cost | High (single provider) | 40-60% lower (auto-routing) |
|
|
21
|
+
| Reliability | Single point of failure | Automatic fallbacks |
|
|
22
|
+
| Model Choice | OpenAI models only | 100+ models from 6+ providers |
|
|
23
|
+
| Cost Tracking | Manual | Real-time dashboard |
|
|
24
|
+
| Setup Time | 5 minutes | **2 minutes** (config only!) |
|
|
25
|
+
| **Code Changes** | N/A | **Zero!** Same SDK |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Migration Steps
|
|
30
|
+
|
|
31
|
+
### Step 1: Create Agentlify Account & Router
|
|
32
|
+
|
|
33
|
+
1. **Sign up** at [agentlify.app](https://agentlify.app)
|
|
34
|
+
2. **Create a router** in the dashboard:
|
|
35
|
+
- Click "Create Router"
|
|
36
|
+
- Choose routing strategy (cost/quality/speed optimized)
|
|
37
|
+
- Router automatically gets access to all 100+ models
|
|
38
|
+
3. **Get your API key** from Settings → API Keys (starts with `mp_`)
|
|
39
|
+
4. **Copy your Router ID** from the router page
|
|
40
|
+
|
|
41
|
+
### Step 2: Update OpenAI SDK Configuration
|
|
42
|
+
|
|
43
|
+
**That's literally it!** Just change two config options:
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Python Migration
|
|
48
|
+
|
|
49
|
+
### Before (Pure OpenAI):
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from openai import OpenAI
|
|
53
|
+
|
|
54
|
+
client = OpenAI(api_key="sk-...")
|
|
55
|
+
|
|
56
|
+
response = client.chat.completions.create(
|
|
57
|
+
model="gpt-4",
|
|
58
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
59
|
+
temperature=0.7
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### After (Agentlify):
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from openai import OpenAI # Same import!
|
|
67
|
+
|
|
68
|
+
# Only change these two lines:
|
|
69
|
+
client = OpenAI(
|
|
70
|
+
api_key="mp_xxx", # Your Agentlify API key
|
|
71
|
+
base_url="https://agentlify.co/api/router/your_router_id"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Everything else stays exactly the same!
|
|
75
|
+
response = client.chat.completions.create(
|
|
76
|
+
model="gpt-4", # Optional - router optimizes automatically
|
|
77
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
78
|
+
temperature=0.7
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# NEW: Access Agentlify metadata
|
|
82
|
+
print(f"Cost: ${response._meta.cost}")
|
|
83
|
+
print(f"Model used: {response._meta.modelUsed}")
|
|
84
|
+
print(f"Latency: {response._meta.latency}ms")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### What Changed:
|
|
88
|
+
|
|
89
|
+
1. ✅ **`api_key`**: Use Agentlify key (`mp_xxx`) instead of OpenAI key
|
|
90
|
+
2. ✅ **`base_url`**: Point to your router endpoint
|
|
91
|
+
3. ✅ **That's it!** All other code works exactly the same
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## JavaScript/TypeScript Migration
|
|
96
|
+
|
|
97
|
+
### Before (Pure OpenAI):
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const { OpenAI } = require('openai');
|
|
101
|
+
|
|
102
|
+
const client = new OpenAI({
|
|
103
|
+
apiKey: 'sk-...',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const response = await client.chat.completions.create({
|
|
107
|
+
model: 'gpt-4',
|
|
108
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
109
|
+
temperature: 0.7,
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### After (Agentlify):
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
const { OpenAI } = require('openai'); // Same import!
|
|
117
|
+
|
|
118
|
+
// Only change these two lines:
|
|
119
|
+
const client = new OpenAI({
|
|
120
|
+
apiKey: process.env.AGENTLIFY_API_KEY, // mp_xxx
|
|
121
|
+
baseURL: `https://agentlify.co/api/router/${process.env.AGENTLIFY_ROUTER_ID}`,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Everything else stays exactly the same!
|
|
125
|
+
const response = await client.chat.completions.create({
|
|
126
|
+
model: 'gpt-4', // Optional - router optimizes automatically
|
|
127
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
128
|
+
temperature: 0.7,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// NEW: Access Agentlify metadata
|
|
132
|
+
console.log('Cost:', response._meta?.cost);
|
|
133
|
+
console.log('Model used:', response._meta?.modelUsed);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### What Changed:
|
|
137
|
+
|
|
138
|
+
1. ✅ **`apiKey`**: Use Agentlify key
|
|
139
|
+
2. ✅ **`baseURL`**: Point to your router
|
|
140
|
+
3. ✅ **That's it!** No other code changes needed
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Environment Variables
|
|
145
|
+
|
|
146
|
+
Create a `.env` file:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Agentlify credentials
|
|
150
|
+
AGENTLIFY_API_KEY=mp_your_api_key_here
|
|
151
|
+
AGENTLIFY_ROUTER_ID=your_router_id_here
|
|
152
|
+
|
|
153
|
+
# Optional: Keep OpenAI as fallback
|
|
154
|
+
OPENAI_API_KEY=sk_your_openai_key_here
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Feature Parity
|
|
160
|
+
|
|
161
|
+
**Everything works exactly the same:**
|
|
162
|
+
|
|
163
|
+
| OpenAI Feature | Agentlify Support | Notes |
|
|
164
|
+
| ---------------- | ------------------ | --------------------------- |
|
|
165
|
+
| Chat Completions | ✅ Fully supported | Identical API |
|
|
166
|
+
| Streaming | ✅ Fully supported | `stream: true` works |
|
|
167
|
+
| Function Calling | ✅ Fully supported | Same format |
|
|
168
|
+
| Tool Calling | ✅ Fully supported | Modern tools API |
|
|
169
|
+
| JSON Mode | ✅ Fully supported | `response_format` supported |
|
|
170
|
+
| Vision (GPT-4V) | ✅ Fully supported | All vision models |
|
|
171
|
+
| Embeddings | ✅ Fully supported | Multi-provider |
|
|
172
|
+
| System Prompts | ✅ Fully supported | Identical behavior |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Streaming Example
|
|
177
|
+
|
|
178
|
+
### Python:
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
stream = client.chat.completions.create(
|
|
182
|
+
messages=[{"role": "user", "content": "Write a poem"}],
|
|
183
|
+
stream=True
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
for chunk in stream:
|
|
187
|
+
if chunk.choices[0].delta.content:
|
|
188
|
+
print(chunk.choices[0].delta.content, end='')
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### JavaScript:
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
const stream = await client.chat.completions.create({
|
|
195
|
+
messages: [{ role: 'user', content: 'Write a poem' }],
|
|
196
|
+
stream: true,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
for await (const chunk of stream) {
|
|
200
|
+
process.stdout.write(chunk.choices[0]?.delta?.content || '');
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Works exactly the same!**
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Function/Tool Calling Example
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
const response = await client.chat.completions.create({
|
|
212
|
+
messages: [{ role: 'user', content: "What's the weather in NYC?" }],
|
|
213
|
+
tools: [
|
|
214
|
+
{
|
|
215
|
+
type: 'function',
|
|
216
|
+
function: {
|
|
217
|
+
name: 'get_weather',
|
|
218
|
+
description: 'Get current weather',
|
|
219
|
+
parameters: {
|
|
220
|
+
type: 'object',
|
|
221
|
+
properties: {
|
|
222
|
+
location: { type: 'string' },
|
|
223
|
+
},
|
|
224
|
+
required: ['location'],
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Works identically with Agentlify!
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Cost Comparison
|
|
237
|
+
|
|
238
|
+
### Example: 1M input + 500K output tokens using GPT-4
|
|
239
|
+
|
|
240
|
+
| Provider | Monthly Cost |
|
|
241
|
+
| -------------------------- | ---------------- |
|
|
242
|
+
| OpenAI Direct | $100.00 |
|
|
243
|
+
| Agentlify (cost-optimized) | **$45.00** |
|
|
244
|
+
| **Savings** | **$55.00 (55%)** |
|
|
245
|
+
|
|
246
|
+
### How Agentlify Saves Money:
|
|
247
|
+
|
|
248
|
+
1. **Automatic routing** to cheapest suitable model
|
|
249
|
+
2. **Model alternatives** (uses GPT-4-Turbo when appropriate)
|
|
250
|
+
3. **Provider diversity** (Anthropic/Google when cheaper)
|
|
251
|
+
4. **Real-time optimization** based on usage patterns
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Testing Your Migration
|
|
256
|
+
|
|
257
|
+
### Use MCP `test_request` Tool:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
User: "Test my router with: Hello, how are you?"
|
|
261
|
+
|
|
262
|
+
AI Assistant:
|
|
263
|
+
Response: "I'm doing great! How can I help you today?"
|
|
264
|
+
Cost: $0.0008
|
|
265
|
+
Model used: gpt-4o-mini
|
|
266
|
+
Latency: 450ms
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Returns full response with exact cost and performance metrics.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Migration Checklist
|
|
274
|
+
|
|
275
|
+
- [ ] Create Agentlify account
|
|
276
|
+
- [ ] Create a router (cost/quality/speed optimized)
|
|
277
|
+
- [ ] Get API key (`mp_xxx`)
|
|
278
|
+
- [ ] Get Router ID from dashboard
|
|
279
|
+
- [ ] Update `api_key` in your code
|
|
280
|
+
- [ ] Update `base_url` / `baseURL` to router endpoint
|
|
281
|
+
- [ ] Test with sample request
|
|
282
|
+
- [ ] Monitor costs in dashboard
|
|
283
|
+
- [ ] Deploy to production!
|
|
284
|
+
|
|
285
|
+
**Total time: ~2 minutes**
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Common Questions
|
|
290
|
+
|
|
291
|
+
### Q: Will my code break?
|
|
292
|
+
|
|
293
|
+
**A:** No! The OpenAI SDK works identically. Just update config.
|
|
294
|
+
|
|
295
|
+
### Q: What if Agentlify goes down?
|
|
296
|
+
|
|
297
|
+
**A:** Routers have automatic fallbacks. If one model fails, it tries the next.
|
|
298
|
+
|
|
299
|
+
### Q: Can I still use GPT-4?
|
|
300
|
+
|
|
301
|
+
**A:** Yes! The router has access to all OpenAI models plus 100+ others.
|
|
302
|
+
|
|
303
|
+
### Q: How do I track costs?
|
|
304
|
+
|
|
305
|
+
**A:** Real-time dashboard at agentlify.app/dashboard + use the `get_usage_summary` MCP tool.
|
|
306
|
+
|
|
307
|
+
### Q: What about rate limits?
|
|
308
|
+
|
|
309
|
+
**A:** Agentlify spreads requests across providers, increasing your effective rate limit.
|
|
310
|
+
|
|
311
|
+
### Q: Do I need to learn a new SDK?
|
|
312
|
+
|
|
313
|
+
**A:** **No!** Keep using OpenAI SDK. Just change the config.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Framework Integration
|
|
318
|
+
|
|
319
|
+
### Works with everything that uses OpenAI SDK:
|
|
320
|
+
|
|
321
|
+
**LangChain:**
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
from langchain.chat_models import ChatOpenAI
|
|
325
|
+
|
|
326
|
+
chat = ChatOpenAI(
|
|
327
|
+
openai_api_key="mp_xxx",
|
|
328
|
+
openai_api_base="https://agentlify.co/api/router/your_router_id"
|
|
329
|
+
)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**LlamaIndex:**
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
from llama_index.llms import OpenAI
|
|
336
|
+
|
|
337
|
+
llm = OpenAI(
|
|
338
|
+
api_key="mp_xxx",
|
|
339
|
+
api_base="https://agentlify.co/api/router/your_router_id"
|
|
340
|
+
)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**Vercel AI SDK:**
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
import { OpenAI } from 'ai';
|
|
347
|
+
|
|
348
|
+
const config = {
|
|
349
|
+
apiKey: 'mp_xxx',
|
|
350
|
+
basePath: 'https://agentlify.co/api/router/your_router_id',
|
|
351
|
+
};
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Need Help?
|
|
357
|
+
|
|
358
|
+
### Use the MCP `migrate_code` tool for automatic conversion:
|
|
359
|
+
|
|
360
|
+
```
|
|
361
|
+
User: "Migrate this OpenAI code: [paste your code]"
|
|
362
|
+
|
|
363
|
+
AI Assistant:
|
|
364
|
+
✅ Converted code
|
|
365
|
+
✅ Estimated 45% cost savings
|
|
366
|
+
✅ Next steps
|
|
367
|
+
✅ Testing recommendations
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Next Steps
|
|
373
|
+
|
|
374
|
+
1. **Optimize further** - Use `optimize_router` to find additional savings
|
|
375
|
+
2. **Monitor usage** - Use `get_usage_summary` for daily/weekly reports
|
|
376
|
+
3. **Compare models** - Use `compare_models` to find the best fit
|
|
377
|
+
4. **Generate code** - Use `generate_integration_code` for production setup
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
**Ready to save 40-60% on AI costs?** Start migrating now! 🚀
|
|
382
|
+
|
|
383
|
+
**Key Takeaway:** You keep using the OpenAI SDK you know and love - just point it at Agentlify for intelligent routing and massive cost savings.
|
package/docs/pricing.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# Pricing & Billing
|
|
2
|
+
|
|
3
|
+
Understanding Agentlify's pricing model.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Agentlify uses **pay-as-you-go** pricing - you only pay for what you use.
|
|
10
|
+
|
|
11
|
+
**Key principle:** You pay for the **actual model used**, not a Agentlify markup. Our intelligent routing saves you 40-60% by choosing cheaper models automatically.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## How It Works
|
|
16
|
+
|
|
17
|
+
### 1. Router Routes Your Request
|
|
18
|
+
|
|
19
|
+
Your request goes to Agentlify router → Router selects best model → Request sent to that model
|
|
20
|
+
|
|
21
|
+
### 2. You Pay Actual Model Cost
|
|
22
|
+
|
|
23
|
+
- If router selects GPT-4o-mini: You pay GPT-4o-mini rates
|
|
24
|
+
- If router selects Claude 3.5 Sonnet: You pay Claude rates
|
|
25
|
+
- If router selects Gemini Pro: You pay Gemini rates
|
|
26
|
+
|
|
27
|
+
### 3. No Agentlify Markup
|
|
28
|
+
|
|
29
|
+
**$0** markup on model costs. You pay wholesale rates.
|
|
30
|
+
|
|
31
|
+
### 4. Savings from Intelligent Routing
|
|
32
|
+
|
|
33
|
+
Router automatically picks cheaper models → You save 40-60% vs. using premium models only
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Sample Model Pricing
|
|
38
|
+
|
|
39
|
+
### Budget Models (Recommended for most tasks)
|
|
40
|
+
|
|
41
|
+
| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|
|
42
|
+
| -------------- | --------------------- | ---------------------- |
|
|
43
|
+
| GPT-4o-mini | $0.15 | $0.60 |
|
|
44
|
+
| Claude 3 Haiku | $0.25 | $1.25 |
|
|
45
|
+
| Gemini Flash | $0.35 | $1.05 |
|
|
46
|
+
|
|
47
|
+
### Mid-Tier Models
|
|
48
|
+
|
|
49
|
+
| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|
|
50
|
+
| ----------------- | --------------------- | ---------------------- |
|
|
51
|
+
| GPT-4-Turbo | $10.00 | $30.00 |
|
|
52
|
+
| Claude 3.5 Sonnet | $3.00 | $15.00 |
|
|
53
|
+
| Gemini Pro | $0.50 | $1.50 |
|
|
54
|
+
|
|
55
|
+
### Premium Models
|
|
56
|
+
|
|
57
|
+
| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|
|
58
|
+
| ------------- | --------------------- | ---------------------- |
|
|
59
|
+
| GPT-4 | $30.00 | $60.00 |
|
|
60
|
+
| Claude 3 Opus | $15.00 | $75.00 |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Real Cost Examples
|
|
65
|
+
|
|
66
|
+
### Example 1: Customer Support Chatbot
|
|
67
|
+
|
|
68
|
+
**Usage:**
|
|
69
|
+
|
|
70
|
+
- 10,000 conversations/month
|
|
71
|
+
- Avg 1,000 input + 500 output tokens per conversation
|
|
72
|
+
|
|
73
|
+
**Cost with GPT-4 only:**
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
Input: 10M tokens × $30/1M = $300
|
|
77
|
+
Output: 5M tokens × $60/1M = $300
|
|
78
|
+
Total: $600/month
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Cost with Agentlify (cost-optimized):**
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
70% GPT-4o-mini: $180 (10,500M tokens)
|
|
85
|
+
25% GPT-4-Turbo: $75 (3,750M tokens)
|
|
86
|
+
5% GPT-4: $30 (750M tokens)
|
|
87
|
+
Total: $285/month
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Savings: $315/month (52%)**
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### Example 2: Content Generation
|
|
95
|
+
|
|
96
|
+
**Usage:**
|
|
97
|
+
|
|
98
|
+
- 1,000 articles/month
|
|
99
|
+
- Avg 500 input + 2,000 output tokens per article
|
|
100
|
+
|
|
101
|
+
**Cost with Claude 3 Opus only:**
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Input: 0.5M tokens × $15/1M = $7.50
|
|
105
|
+
Output: 2M tokens × $75/1M = $150
|
|
106
|
+
Total: $157.50/month
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Cost with Agentlify (quality-optimized):**
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
60% Claude 3.5 Sonnet: $54 (1.2M output)
|
|
113
|
+
30% GPT-4-Turbo: $18 (0.6M output)
|
|
114
|
+
10% Claude Opus: $15 (0.2M output)
|
|
115
|
+
Total: $87/month
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Savings: $70.50/month (45%)**
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Billing Model
|
|
123
|
+
|
|
124
|
+
### Pay-As-You-Go (Default)
|
|
125
|
+
|
|
126
|
+
- Purchase credits upfront
|
|
127
|
+
- Credits deducted per request
|
|
128
|
+
- Never expire
|
|
129
|
+
- Top up anytime
|
|
130
|
+
|
|
131
|
+
**Credit packages:**
|
|
132
|
+
|
|
133
|
+
- $10 starter
|
|
134
|
+
- $50 basic
|
|
135
|
+
- $100 standard
|
|
136
|
+
- $500+ enterprise
|
|
137
|
+
|
|
138
|
+
### Auto-Refill
|
|
139
|
+
|
|
140
|
+
Enable automatic credit top-ups:
|
|
141
|
+
|
|
142
|
+
- Set low balance threshold (e.g., $10)
|
|
143
|
+
- Set refill amount (e.g., $50)
|
|
144
|
+
- Charged automatically when balance low
|
|
145
|
+
- Never run out of credits
|
|
146
|
+
|
|
147
|
+
**Setup via Dashboard or MCP:**
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
User: "Enable auto-refill with $50 when balance below $10"
|
|
151
|
+
AI: ✅ Auto-refill configured
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Subscription Plans (Optional)
|
|
157
|
+
|
|
158
|
+
### Pro Plan - $49/month
|
|
159
|
+
|
|
160
|
+
Includes:
|
|
161
|
+
|
|
162
|
+
- $60 in credits (20% bonus)
|
|
163
|
+
- Priority routing
|
|
164
|
+
- Advanced analytics
|
|
165
|
+
- Email support
|
|
166
|
+
|
|
167
|
+
### Business Plan - $249/month
|
|
168
|
+
|
|
169
|
+
Includes:
|
|
170
|
+
|
|
171
|
+
- $325 in credits (30% bonus)
|
|
172
|
+
- Dedicated router instances
|
|
173
|
+
- Custom model selection
|
|
174
|
+
- Priority support
|
|
175
|
+
- SSO integration
|
|
176
|
+
|
|
177
|
+
### Enterprise Plan - Custom
|
|
178
|
+
|
|
179
|
+
Includes:
|
|
180
|
+
|
|
181
|
+
- Custom credit amounts
|
|
182
|
+
- SLA guarantees
|
|
183
|
+
- Dedicated account manager
|
|
184
|
+
- Custom integrations
|
|
185
|
+
- On-premise options
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Credit Usage
|
|
190
|
+
|
|
191
|
+
### Check Balance
|
|
192
|
+
|
|
193
|
+
**Dashboard:** View balance in top-right corner
|
|
194
|
+
|
|
195
|
+
**API:**
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
const balance = await client.getBalance();
|
|
199
|
+
console.log('Balance:', balance.credits);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**MCP Tool:**
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
User: "What's my Agentlify balance?"
|
|
206
|
+
AI: Balance: $45.67 | Subscription: Pro | Used this month: $12.34
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Usage Tracking
|
|
210
|
+
|
|
211
|
+
Every response includes cost metadata:
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
const response = await client.chat.completions.create({
|
|
215
|
+
/*...*/
|
|
216
|
+
});
|
|
217
|
+
console.log('Request cost:', response._meta.cost); // e.g., 0.0008
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Cost Control
|
|
223
|
+
|
|
224
|
+
### 1. Set Budget Limits
|
|
225
|
+
|
|
226
|
+
Configure router with monthly budget:
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
const router = await createRouter({
|
|
230
|
+
name: 'my-router',
|
|
231
|
+
budget_limit: 100, // $100/month max
|
|
232
|
+
});
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 2. Monitor Usage
|
|
236
|
+
|
|
237
|
+
**Daily:** Check dashboard for cost trends
|
|
238
|
+
**Weekly:** Review model distribution
|
|
239
|
+
**Monthly:** Analyze savings vs. single-provider
|
|
240
|
+
|
|
241
|
+
### 3. Cost Alerts
|
|
242
|
+
|
|
243
|
+
Set up alerts in dashboard:
|
|
244
|
+
|
|
245
|
+
- Daily spending > $X
|
|
246
|
+
- Monthly approaching budget
|
|
247
|
+
- Unusual cost spikes
|
|
248
|
+
|
|
249
|
+
### 4. Use MCP Tools
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
User: "Show my usage for last 7 days"
|
|
253
|
+
AI: Total: $45 | Avg per request: $0.0045 | Trending: -12%
|
|
254
|
+
|
|
255
|
+
User: "Optimize my router"
|
|
256
|
+
AI: Switch to GPT-4-Turbo → Save $25/month
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Refunds & Credits
|
|
262
|
+
|
|
263
|
+
### Credit Purchases
|
|
264
|
+
|
|
265
|
+
- Non-refundable
|
|
266
|
+
- Never expire
|
|
267
|
+
- Transferable between routers
|
|
268
|
+
|
|
269
|
+
### Subscription
|
|
270
|
+
|
|
271
|
+
- Cancel anytime
|
|
272
|
+
- Unused credits roll over
|
|
273
|
+
- Prorated refunds available
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Enterprise Pricing
|
|
278
|
+
|
|
279
|
+
For high-volume usage (>$1,000/month), contact sales for:
|
|
280
|
+
|
|
281
|
+
- Custom pricing
|
|
282
|
+
- Volume discounts
|
|
283
|
+
- Reserved capacity
|
|
284
|
+
- SLA guarantees
|
|
285
|
+
- Dedicated support
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Free Tier
|
|
290
|
+
|
|
291
|
+
**$5 free credits** for new accounts:
|
|
292
|
+
|
|
293
|
+
- Test Agentlify
|
|
294
|
+
- ~500-5,000 requests (depending on models)
|
|
295
|
+
- No credit card required
|
|
296
|
+
- Upgrade anytime
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Comparison vs. Direct Providers
|
|
301
|
+
|
|
302
|
+
### Monthly cost for 10M input + 5M output tokens:
|
|
303
|
+
|
|
304
|
+
| Provider | Cost |
|
|
305
|
+
| ------------------------------ | -------------- |
|
|
306
|
+
| OpenAI Direct (GPT-4) | $600 |
|
|
307
|
+
| Anthropic Direct (Claude Opus) | $525 |
|
|
308
|
+
| **Agentlify (Cost-Optimized)** | **$250** |
|
|
309
|
+
| **Savings** | **$350 (58%)** |
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Frequently Asked Questions
|
|
314
|
+
|
|
315
|
+
### Q: Is there a monthly minimum?
|
|
316
|
+
|
|
317
|
+
**A:** No minimum. Pay only for what you use.
|
|
318
|
+
|
|
319
|
+
### Q: Do credits expire?
|
|
320
|
+
|
|
321
|
+
**A:** No, credits never expire.
|
|
322
|
+
|
|
323
|
+
### Q: Can I get a refund?
|
|
324
|
+
|
|
325
|
+
**A:** Credits are non-refundable. Subscriptions can be cancelled anytime with prorated refunds.
|
|
326
|
+
|
|
327
|
+
### Q: What payment methods?
|
|
328
|
+
|
|
329
|
+
**A:** Credit card, debit card, ACH (enterprise).
|
|
330
|
+
|
|
331
|
+
### Q: How do I track costs?
|
|
332
|
+
|
|
333
|
+
**A:** Real-time dashboard + every API response includes cost metadata + MCP tools.
|
|
334
|
+
|
|
335
|
+
### Q: Can I set spending limits?
|
|
336
|
+
|
|
337
|
+
**A:** Yes, configure budget limits per router.
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Getting Started
|
|
342
|
+
|
|
343
|
+
1. Sign up at [agentlify.app](https://agentlify.app)
|
|
344
|
+
2. Get $5 free credits
|
|
345
|
+
3. Create a router
|
|
346
|
+
4. Start making requests
|
|
347
|
+
5. Monitor savings in dashboard
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
**Bottom Line:** Pay wholesale model prices with no markup, save 40-60% through intelligent routing, and never worry about running out of credits with auto-refill!
|