@agentrouter/agentrouter 0.1.13 → 0.2.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.
- package/README.md +16 -803
- package/dist/cli.js +3 -4
- package/dist/core.d.ts +28 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +598 -0
- package/dist/credentials.d.ts +43 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +98 -0
- package/dist/login-page.d.ts +2 -0
- package/dist/login-page.d.ts.map +1 -0
- package/dist/login-page.js +45 -0
- package/dist/login.d.ts +23 -0
- package/dist/login.d.ts.map +1 -0
- package/dist/login.js +90 -0
- package/dist/terminal.d.ts +3 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +32 -0
- package/icon.svg +11 -0
- package/package.json +9 -17
- package/dist/cli-core.d.ts +0 -13
- package/dist/cli-core.d.ts.map +0 -1
- package/dist/cli-core.js +0 -627
- package/dist/index.d.ts +0 -553
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -797
package/README.md
CHANGED
|
@@ -1,811 +1,24 @@
|
|
|
1
|
-
# AgentRouter
|
|
1
|
+
# AgentRouter CLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
AgentRouter supports both a structured capability-first flow and an intent-first
|
|
6
|
-
entrypoint. The intent-first path is backed by AgentRouter's hosted intent
|
|
7
|
-
resolver, so the SDK can start from a natural-language prompt, inspect the
|
|
8
|
-
selected route context, and then execute explicitly through one client.
|
|
9
|
-
|
|
10
|
-
- Package: `@agentrouter/agentrouter`
|
|
11
|
-
- Docs: `https://docs.agentrouter.to/integrations/sdk`
|
|
12
|
-
- Base URL: `https://api.agentrouter.to/api/agentic-api`
|
|
13
|
-
|
|
14
|
-
## Install
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @agentrouter/agentrouter
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Get an API Key
|
|
21
|
-
|
|
22
|
-
Hosted AgentRouter requests require an API key.
|
|
23
|
-
|
|
24
|
-
1. Open `https://www.agentrouter.to/agentic-api/install`
|
|
25
|
-
2. Sign in and copy your API key
|
|
26
|
-
3. Export it in your shell
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
export AGENTIC_API_KEY=your_key_here
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
For local development against a local AgentRouter server, you can also use
|
|
33
|
-
`userId` instead of an API key.
|
|
34
|
-
|
|
35
|
-
## Quick Start
|
|
36
|
-
|
|
37
|
-
Intent-first:
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
import { AgentRouterClient } from "@agentrouter/agentrouter";
|
|
41
|
-
|
|
42
|
-
const client = new AgentRouterClient({
|
|
43
|
-
apiKey: process.env.AGENTIC_API_KEY,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const recommendation = await client.recommend(
|
|
47
|
-
"can you help me buy an email inbox?",
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const routeContext = await client.catalog.routes.context(
|
|
51
|
-
recommendation.recommendedRouteKey,
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const result = await client.capabilities.execute({
|
|
55
|
-
domain: recommendation.resolution.domainKey,
|
|
56
|
-
capability: recommendation.resolution.capabilityId,
|
|
57
|
-
routeKey: recommendation.recommendedRouteKey,
|
|
58
|
-
input: {
|
|
59
|
-
inbox_name: "launch-updates",
|
|
60
|
-
},
|
|
61
|
-
allowFallback: true,
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
If you want the hosted mapping step directly, call:
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
const resolution = await client.intent.resolve(
|
|
69
|
-
"can you help me buy an email inbox?",
|
|
70
|
-
);
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Structured:
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
import { AgentRouterClient } from "@agentrouter/agentrouter";
|
|
77
|
-
|
|
78
|
-
const client = new AgentRouterClient({
|
|
79
|
-
apiKey: process.env.AGENTIC_API_KEY,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const domains = await client.catalog.domains.list();
|
|
83
|
-
const capabilities = await client.catalog.capabilities.list("email");
|
|
84
|
-
|
|
85
|
-
const recommendation = await client.capabilities.recommend({
|
|
86
|
-
domain: "email",
|
|
87
|
-
capability: "send",
|
|
88
|
-
input: {
|
|
89
|
-
optimizationPreferences: ["cost", "quality"],
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const result = await client.capabilities.execute({
|
|
94
|
-
domain: "email",
|
|
95
|
-
capability: "send",
|
|
96
|
-
input: {
|
|
97
|
-
to: "maya@example.com",
|
|
98
|
-
subject: "Hello from AgentRouter",
|
|
99
|
-
html: "<p>Hello</p>",
|
|
100
|
-
},
|
|
101
|
-
provider: recommendation.recommendedProvider,
|
|
102
|
-
allowFallback: true,
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## CLI
|
|
107
|
-
|
|
108
|
-
The package also ships a thin CLI wrapper over the same SDK semantics.
|
|
109
|
-
|
|
110
|
-
Create an API key at `https://www.agentrouter.to/agentic-api/install` and
|
|
111
|
-
export it before hosted CLI requests:
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
export AGENTIC_API_KEY=your_key_here
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Install locally:
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
npm install @agentrouter/agentrouter
|
|
121
|
-
npx agentrouter domains list
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Or run it without adding the package to your app:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
npx -p @agentrouter/agentrouter agentrouter domains list
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Examples:
|
|
3
|
+
Find, describe and invoke provider tools (web, social, SEO, sales data) from a terminal, scripts or CI, paying from one AgentRouter wallet. This package is a command-line tool only; there is no SDK to import.
|
|
131
4
|
|
|
132
5
|
```bash
|
|
133
|
-
agentrouter
|
|
134
|
-
agentrouter
|
|
135
|
-
agentrouter
|
|
136
|
-
agentrouter
|
|
137
|
-
agentrouter capabilities list translation
|
|
138
|
-
agentrouter capabilities list finance
|
|
139
|
-
agentrouter capabilities list tax
|
|
140
|
-
agentrouter capabilities list captcha
|
|
141
|
-
agentrouter capabilities list commerce
|
|
142
|
-
agentrouter capabilities list lottery
|
|
143
|
-
agentrouter capabilities list music
|
|
144
|
-
agentrouter capabilities list property
|
|
145
|
-
agentrouter capabilities list media
|
|
146
|
-
agentrouter capabilities list web
|
|
147
|
-
agentrouter routes context email.send.resend
|
|
148
|
-
agentrouter routes context models.chat.complete.deepseek.mpp
|
|
149
|
-
agentrouter routes context models.chat.complete.groq.mpp
|
|
150
|
-
agentrouter routes context text.analyze.diffbot-nl.mpp
|
|
151
|
-
agentrouter routes context translation.text.rephrase.deepl.mpp
|
|
152
|
-
agentrouter routes context web.extract.diffbot.mpp
|
|
153
|
-
agentrouter routes context web.publication.list.dripstack.mpp
|
|
154
|
-
agentrouter routes context web.publication.post.get.dripstack.mpp
|
|
155
|
-
agentrouter routes context enrichment.people.enrich.diffbot.mpp
|
|
156
|
-
agentrouter routes context finance.equity.quote.alphavantage.mpp
|
|
157
|
-
agentrouter routes context finance.fx.rate.abstract-exchange-rates.mpp
|
|
158
|
-
agentrouter routes context finance.fx.convert.abstract-exchange-rates.mpp
|
|
159
|
-
agentrouter routes context finance.fx.rate.historical.abstract-exchange-rates.mpp
|
|
160
|
-
agentrouter routes context tax.vat.validate.abstract-vat.mpp
|
|
161
|
-
agentrouter routes context tax.vat.calculate.abstract-vat.mpp
|
|
162
|
-
agentrouter routes context tax.vat.categories.list.abstract-vat.mpp
|
|
163
|
-
agentrouter routes context captcha.task.create.twocaptcha.mpp
|
|
164
|
-
agentrouter routes context commerce.product.search.kicksdb.stockx.mpp
|
|
165
|
-
agentrouter routes context lottery.round.active.megapot
|
|
166
|
-
agentrouter routes context music.song.generate.suno.mpp
|
|
167
|
-
agentrouter routes context property.records.search.rentcast.mpp
|
|
168
|
-
agentrouter routes context media.image.generate.fal.mpp
|
|
169
|
-
agentrouter routes context travel.airport.operations.flightapi.mpp
|
|
170
|
-
agentrouter recommend email send --input '{"optimizationPreferences":["cost"]}'
|
|
171
|
-
agentrouter recommend text analyze --input '{"provider":"diffbot-nl","fields":"entities,sentiment,language","optimizationPreferences":["quality"]}' --json
|
|
172
|
-
agentrouter execute models chat-complete --input '{"model":"deepseek-flash","messages":[{"role":"user","content":"Say AgentRouter DeepSeek smoke OK."}]}' --route-key models.chat.complete.deepseek.mpp --json
|
|
173
|
-
agentrouter execute translation text-rephrase --input '{"text":"Please make this product update friendlier.","targetLanguage":"EN-US","tone":"prefer_friendly"}' --route-key translation.text.rephrase.deepl.mpp --json
|
|
174
|
-
agentrouter execute web extract --input '{"url":"https://www.example.com/article"}' --route-key web.extract.diffbot.mpp --json
|
|
175
|
-
agentrouter execute web publication-list --input '{"allowFallback":false}' --route-key web.publication.list.dripstack.mpp --json
|
|
176
|
-
agentrouter execute web publication-posts-list --input '{"publicationSlug":"newsletter.morning-brew.morningbrew.com","allowFallback":false}' --route-key web.publication.posts.list.dripstack.mpp --json
|
|
177
|
-
agentrouter execute web publication-post-get --input '{"publicationSlug":"newsletter.morning-brew.morningbrew.com","postSlug":"cheers-to-beer-20260506","allowFallback":false}' --route-key web.publication.post.get.dripstack.mpp --json
|
|
178
|
-
agentrouter execute enrichment people-enrich --input '{"fullName":"Sam Altman","companyName":"OpenAI"}' --route-key enrichment.people.enrich.diffbot.mpp --json
|
|
179
|
-
agentrouter recommend finance equity-quote --input '{"symbol":"MSFT","optimizationPreferences":["speed","quality"]}' --json
|
|
180
|
-
agentrouter recommend finance fx-convert --input '{"fromCurrency":"USD","toCurrency":"JPY","amount":25,"optimizationPreferences":["cost"]}' --json
|
|
181
|
-
agentrouter execute email send --input @send-email.json --route-key email.send.resend --allow-fallback
|
|
182
|
-
agentrouter execute finance equity-quote --input '{"symbol":"MSFT"}' --route-key finance.equity.quote.alphavantage.mpp --json
|
|
183
|
-
agentrouter execute finance fx-convert --input '{"fromCurrency":"USD","toCurrency":"JPY","amount":25}' --route-key finance.fx.convert.abstract-exchange-rates.mpp --json
|
|
184
|
-
agentrouter execute tax vat-validate --input '{"vatNumber":"DE123456789","countryCode":"DE","allowFallback":false}' --route-key tax.vat.validate.abstract-vat.mpp --provider abstract-vat --json
|
|
185
|
-
agentrouter execute tax vat-calculate --input '{"countryCode":"DE","amount":100,"calculationType":"add","allowFallback":false}' --route-key tax.vat.calculate.abstract-vat.mpp --provider abstract-vat --json
|
|
186
|
-
agentrouter execute media image-generate --input '{"prompt":"Create a clean launch hero image for an AI developer tool","aspectRatio":"16:9","allowFallback":false}' --route-key media.image.generate.fal.mpp --provider fal --json
|
|
187
|
-
agentrouter execute travel airport-operations --input '{"iataCode":"JFK","mode":"departures","limit":1}' --route-key travel.airport.operations.flightapi.mpp --provider flightapi --json
|
|
188
|
-
agentrouter route enrichment --input '{"intent":"Find the work email for the VP Engineering at Example Corp"}'
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Finance commands require a deployment that actually exposes `GET /domains/finance`. If that domain returns `DOMAIN_NOT_FOUND` or the finance execute endpoints return `404`, the rollout is not live on that environment yet.
|
|
192
|
-
|
|
193
|
-
Tax VAT commands require a deployment that exposes `GET /domains/tax`. The live Abstract VAT routes are `tax.vat.validate.abstract-vat.mpp`, `tax.vat.calculate.abstract-vat.mpp`, and `tax.vat.categories.list.abstract-vat.mpp`.
|
|
194
|
-
|
|
195
|
-
Text analysis is currently recommend/context only. `text.analyze.diffbot-nl.mpp` is mapped through Diffbot NL, but May 5, 2026 direct wrapper checks returned HTTP 429 before payment and no AgentRouter credits were charged, so do not execute it until the catalog reports it executable and paid smoke evidence exists.
|
|
196
|
-
|
|
197
|
-
Media image generation and edit are live through fal MPP image routes. media.video.generate.fal.mpp remains gated after upstream paymentauth 524 timeouts reproduced outside AgentRouter, so use recommend/context for video generation until the catalog reports it executable and paid smoke evidence exists.
|
|
198
|
-
|
|
199
|
-
Environment variables:
|
|
200
|
-
|
|
201
|
-
- `AGENTIC_API_BASE_URL`
|
|
202
|
-
- `AGENTIC_API_KEY`
|
|
203
|
-
- `AGENTIC_API_SESSION_TOKEN`
|
|
204
|
-
- `AGENTIC_API_USER_ID`
|
|
205
|
-
- `AGENTIC_API_TIMEOUT_MS`
|
|
206
|
-
|
|
207
|
-
## Recommended Flow
|
|
208
|
-
|
|
209
|
-
1. List domains with `client.catalog.domains.list()`
|
|
210
|
-
2. List capabilities with `client.catalog.capabilities.list(domainKey)`
|
|
211
|
-
3. Inspect routes or contracts for a capability
|
|
212
|
-
4. Ask for a recommendation
|
|
213
|
-
5. Execute explicitly
|
|
214
|
-
|
|
215
|
-
This keeps your integration stable even when providers or routes change.
|
|
216
|
-
|
|
217
|
-
## Catalog Discovery
|
|
218
|
-
|
|
219
|
-
```ts
|
|
220
|
-
const domain = await client.catalog.domains.get("enrichment");
|
|
221
|
-
|
|
222
|
-
const capability = await client.catalog.capabilities.get("email", "send");
|
|
223
|
-
|
|
224
|
-
const routes = await client.catalog.capabilities.routes("email", "send");
|
|
225
|
-
|
|
226
|
-
const contract = await client.catalog.capabilities.contract("email", "send");
|
|
227
|
-
|
|
228
|
-
const routeContext = await client.catalog.routes.context("email.send.resend");
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
Capability contracts describe the common input shape for a workflow. Route
|
|
232
|
-
contexts describe the executable surface for one selected route, including
|
|
233
|
-
route-specific fields and possible provider/wrapper values. Read each possible
|
|
234
|
-
value's label and description to map natural language to the exact value.
|
|
235
|
-
|
|
236
|
-
When you want one concrete route, execute through the capability endpoint and
|
|
237
|
-
pass `routeKey`; the SDK sends it in the request body.
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
const result = await client.capabilities.execute({
|
|
241
|
-
domain: "travel",
|
|
242
|
-
capability: "flight-search",
|
|
243
|
-
routeKey: "travel.flight.search.stabletravel.googleflights.agentcash",
|
|
244
|
-
input: {
|
|
245
|
-
departure_id: "JFK",
|
|
246
|
-
arrival_id: "LAX",
|
|
247
|
-
outbound_date: "2026-05-01",
|
|
248
|
-
type: "2",
|
|
249
|
-
travel_class: "1",
|
|
250
|
-
adults: 1,
|
|
251
|
-
},
|
|
252
|
-
allowFallback: false,
|
|
253
|
-
});
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
The same generic surface also works for physical-mail workflows:
|
|
257
|
-
|
|
258
|
-
```ts
|
|
259
|
-
const postcard = await client.capabilities.execute({
|
|
260
|
-
domain: "post",
|
|
261
|
-
capability: "postcard-send",
|
|
262
|
-
routeKey: "post.postcard.send.papercut.mpp",
|
|
263
|
-
input: {
|
|
264
|
-
roast: "Launch follow-up postcard",
|
|
265
|
-
github_username: "codepoet",
|
|
266
|
-
type: "digital",
|
|
267
|
-
},
|
|
268
|
-
allowFallback: false,
|
|
269
|
-
});
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
It also works for public-broadcast price checks:
|
|
273
|
-
|
|
274
|
-
```ts
|
|
275
|
-
const broadcastQuote = await client.capabilities.execute({
|
|
276
|
-
domain: "broadcast",
|
|
277
|
-
capability: "message-quote",
|
|
278
|
-
routeKey: "broadcast.message.quote.billboard.mpp",
|
|
279
|
-
input: {},
|
|
280
|
-
allowFallback: false,
|
|
281
|
-
});
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
As of May 1, 2026, `broadcast.message.send.billboard.mpp` is still intentionally gated because one live execute would create a real public post and the latest observed supplier challenge was about `$40.96`.
|
|
285
|
-
|
|
286
|
-
For text analysis, use the generic surface for recommendation and route context only until the Diffbot NL route clears its runtime gate:
|
|
287
|
-
|
|
288
|
-
```ts
|
|
289
|
-
const textRecommendation = await client.capabilities.recommend({
|
|
290
|
-
domain: "text",
|
|
291
|
-
capability: "analyze",
|
|
292
|
-
input: {
|
|
293
|
-
provider: "diffbot-nl",
|
|
294
|
-
fields: "entities,sentiment,language",
|
|
295
|
-
optimizationPreferences: ["quality"],
|
|
296
|
-
},
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
const textContext = await client.catalog.routes.context(
|
|
300
|
-
"text.analyze.diffbot-nl.mpp",
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
console.log(textRecommendation.recommendedRouteKey);
|
|
304
|
-
console.log(textContext.routeKey);
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
The current Diffbot NL route is not a live execute example. It returned HTTP 429 before payment during May 5, 2026 direct wrapper checks, so keep integrations to recommend/context until `canExecuteNow` is true and a paid route smoke succeeds.
|
|
308
|
-
|
|
309
|
-
It also works for route-pinned fal image generation through the media domain:
|
|
310
|
-
|
|
311
|
-
```ts
|
|
312
|
-
const heroImage = await client.capabilities.execute({
|
|
313
|
-
domain: "media",
|
|
314
|
-
capability: "image-generate",
|
|
315
|
-
routeKey: "media.image.generate.fal.mpp",
|
|
316
|
-
input: {
|
|
317
|
-
prompt: "Create a clean launch hero image for an AI developer tool",
|
|
318
|
-
aspectRatio: "16:9",
|
|
319
|
-
},
|
|
320
|
-
provider: "fal",
|
|
321
|
-
allowFallback: false,
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
console.log(heroImage.primaryImageUrl);
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
media.video.generate.fal.mpp remains gated after upstream paymentauth 524 timeouts reproduced outside AgentRouter, so do not execute video generation until route context reports `canExecuteNow=true` and paid smoke evidence exists.
|
|
328
|
-
|
|
329
|
-
It also works for DeepL Write rephrase through the translation domain:
|
|
330
|
-
|
|
331
|
-
```ts
|
|
332
|
-
const rewrite = await client.capabilities.execute({
|
|
333
|
-
domain: "translation",
|
|
334
|
-
capability: "text-rephrase",
|
|
335
|
-
routeKey: "translation.text.rephrase.deepl.mpp",
|
|
336
|
-
input: {
|
|
337
|
-
text: "Please make this product update friendlier.",
|
|
338
|
-
targetLanguage: "EN-US",
|
|
339
|
-
tone: "prefer_friendly",
|
|
340
|
-
},
|
|
341
|
-
allowFallback: false,
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
console.log(rewrite.rewrittenText);
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
For DeepL rephrase, fetch route context before execution and use the exposed DeepL Write fields: `text`, `targetLanguage`, and optional `tone`.
|
|
348
|
-
|
|
349
|
-
It also works for route-pinned airport schedule operations on FlightAPI:
|
|
350
|
-
|
|
351
|
-
```ts
|
|
352
|
-
const airportOperations = await client.capabilities.execute({
|
|
353
|
-
domain: "travel",
|
|
354
|
-
capability: "airport-operations",
|
|
355
|
-
routeKey: "travel.airport.operations.flightapi.mpp",
|
|
356
|
-
input: {
|
|
357
|
-
iataCode: "JFK",
|
|
358
|
-
mode: "departures",
|
|
359
|
-
limit: 1,
|
|
360
|
-
},
|
|
361
|
-
provider: "flightapi",
|
|
362
|
-
allowFallback: false,
|
|
363
|
-
});
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
FlightAPI airport operations passed a May 8, 2026 production smoke through `travel.airport.operations.flightapi.mpp`. Fetch route context first and pin the route when you need that concrete provider.
|
|
367
|
-
|
|
368
|
-
If your deployment exposes the finance domain, it also works for finance market-data routes:
|
|
369
|
-
|
|
370
|
-
```ts
|
|
371
|
-
const marketStatus = await client.capabilities.execute({
|
|
372
|
-
domain: "finance",
|
|
373
|
-
capability: "market-status",
|
|
374
|
-
routeKey: "finance.market.status.alphavantage.mpp",
|
|
375
|
-
input: {},
|
|
376
|
-
allowFallback: false,
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
const quote = await client.capabilities.execute({
|
|
380
|
-
domain: "finance",
|
|
381
|
-
capability: "equity-quote",
|
|
382
|
-
routeKey: "finance.equity.quote.alphavantage.mpp",
|
|
383
|
-
input: {
|
|
384
|
-
symbol: "MSFT",
|
|
385
|
-
},
|
|
386
|
-
allowFallback: false,
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
const fxRate = await client.capabilities.execute({
|
|
390
|
-
domain: "finance",
|
|
391
|
-
capability: "fx-rate",
|
|
392
|
-
routeKey: "finance.fx.rate.abstract-exchange-rates.mpp",
|
|
393
|
-
input: {
|
|
394
|
-
fromCurrency: "USD",
|
|
395
|
-
toCurrency: "EUR",
|
|
396
|
-
},
|
|
397
|
-
allowFallback: false,
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
const fxConversion = await client.capabilities.execute({
|
|
401
|
-
domain: "finance",
|
|
402
|
-
capability: "fx-convert",
|
|
403
|
-
routeKey: "finance.fx.convert.abstract-exchange-rates.mpp",
|
|
404
|
-
input: {
|
|
405
|
-
fromCurrency: "USD",
|
|
406
|
-
toCurrency: "JPY",
|
|
407
|
-
amount: 25,
|
|
408
|
-
},
|
|
409
|
-
allowFallback: false,
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
const historicalFxRate = await client.capabilities.execute({
|
|
413
|
-
domain: "finance",
|
|
414
|
-
capability: "fx-rate-historical",
|
|
415
|
-
routeKey: "finance.fx.rate.historical.abstract-exchange-rates.mpp",
|
|
416
|
-
input: {
|
|
417
|
-
fromCurrency: "USD",
|
|
418
|
-
toCurrency: "GBP",
|
|
419
|
-
date: "2024-01-01",
|
|
420
|
-
},
|
|
421
|
-
allowFallback: false,
|
|
422
|
-
});
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
If your deployment exposes the tax domain, the same generic surface works for VAT validation, calculation, and category-rate lookup:
|
|
426
|
-
|
|
427
|
-
```ts
|
|
428
|
-
const vatValidation = await client.capabilities.execute({
|
|
429
|
-
domain: "tax",
|
|
430
|
-
capability: "vat-validate",
|
|
431
|
-
routeKey: "tax.vat.validate.abstract-vat.mpp",
|
|
432
|
-
input: {
|
|
433
|
-
vatNumber: "DE123456789",
|
|
434
|
-
countryCode: "DE",
|
|
435
|
-
},
|
|
436
|
-
allowFallback: false,
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
const vatCalculation = await client.capabilities.execute({
|
|
440
|
-
domain: "tax",
|
|
441
|
-
capability: "vat-calculate",
|
|
442
|
-
routeKey: "tax.vat.calculate.abstract-vat.mpp",
|
|
443
|
-
input: {
|
|
444
|
-
countryCode: "DE",
|
|
445
|
-
amount: 100,
|
|
446
|
-
calculationType: "add",
|
|
447
|
-
},
|
|
448
|
-
allowFallback: false,
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
const vatCategories = await client.capabilities.execute({
|
|
452
|
-
domain: "tax",
|
|
453
|
-
capability: "vat-categories-list",
|
|
454
|
-
routeKey: "tax.vat.categories.list.abstract-vat.mpp",
|
|
455
|
-
input: {
|
|
456
|
-
countryCode: "DE",
|
|
457
|
-
},
|
|
458
|
-
allowFallback: false,
|
|
459
|
-
});
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
If your deployment exposes the agents domain, the same generic surface also works for hosted-agent discovery and stateless paid execution:
|
|
463
|
-
|
|
464
|
-
```ts
|
|
465
|
-
const agentSearch = await client.capabilities.recommend({
|
|
466
|
-
domain: "agents",
|
|
467
|
-
capability: "search",
|
|
468
|
-
input: {
|
|
469
|
-
query: "privy",
|
|
470
|
-
optimizationPreferences: ["quality"],
|
|
471
|
-
},
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
const agentRun = await client.capabilities.execute({
|
|
475
|
-
domain: "agents",
|
|
476
|
-
capability: "run",
|
|
477
|
-
routeKey: "agents.run.autoexchange.mpp",
|
|
478
|
-
input: {
|
|
479
|
-
id: "ab7527c0-6099-4145-9d8b-47f09dab9390",
|
|
480
|
-
prompt: "Say hello in one short sentence.",
|
|
481
|
-
stateless: true,
|
|
482
|
-
},
|
|
483
|
-
allowFallback: false,
|
|
484
|
-
});
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
The generic surface also works for model inference through the `models` domain. The current live routes cover DeepSeek chat completion, code completion, and model listing, plus Groq chat completion and model listing through `models.chat.complete.groq.mpp` and `models.list.groq.mpp`:
|
|
488
|
-
|
|
489
|
-
```ts
|
|
490
|
-
const modelChat = await client.capabilities.execute({
|
|
491
|
-
domain: "models",
|
|
492
|
-
capability: "chat-complete",
|
|
493
|
-
routeKey: "models.chat.complete.deepseek.mpp",
|
|
494
|
-
input: {
|
|
495
|
-
model: "deepseek-flash",
|
|
496
|
-
messages: [
|
|
497
|
-
{
|
|
498
|
-
role: "user",
|
|
499
|
-
content: "Say AgentRouter DeepSeek smoke OK.",
|
|
500
|
-
},
|
|
501
|
-
],
|
|
502
|
-
},
|
|
503
|
-
allowFallback: false,
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
const modelList = await client.capabilities.execute({
|
|
507
|
-
domain: "models",
|
|
508
|
-
capability: "list",
|
|
509
|
-
routeKey: "models.list.deepseek.mpp",
|
|
510
|
-
input: {},
|
|
511
|
-
allowFallback: false,
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
console.log(modelChat.completionText);
|
|
515
|
-
console.log(modelList.models);
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
When the caller already knows the exact model id, recommendation is optional. Fetch the free catalog, select a model, and execute it directly:
|
|
519
|
-
|
|
520
|
-
```ts
|
|
521
|
-
const catalog = await client.models.catalog.list(); // 0 credits
|
|
522
|
-
const model = catalog.models.find(
|
|
523
|
-
(candidate) => candidate.id === "openai/gpt-4.1-nano",
|
|
524
|
-
);
|
|
525
|
-
|
|
526
|
-
if (!model) throw new Error("Model is not available");
|
|
527
|
-
|
|
528
|
-
const result = await client.models.chat.complete.execute(
|
|
529
|
-
{
|
|
530
|
-
model: model.id,
|
|
531
|
-
messages: [{ role: "user", content: "Write a one-line product hero." }],
|
|
532
|
-
max_tokens: 120,
|
|
533
|
-
temperature: 0.2,
|
|
534
|
-
top_p: 0.9,
|
|
535
|
-
},
|
|
536
|
-
{ allowFallback: true },
|
|
537
|
-
);
|
|
538
|
-
|
|
539
|
-
console.log(result.completionText, result.creditsCharged);
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
The OpenRouter catalog is dynamic. Read `catalog.modelCount` and each model's `agentRouterPricing` at runtime instead of hard-coding a model count or price. Prices are estimates in credits per million tokens. The final request charge is dynamic and `creditsCharged` in the execution response is authoritative.
|
|
543
|
-
|
|
544
|
-
Chat-complete requires `model` and `messages`. Its route fields also include `max_tokens`, `temperature`, `top_p`, `stop`, and `stream`. Code-complete requires `model` and `prompt`, and also accepts `suffix`, `max_tokens`, and `temperature`. Shared execution controls are `provider`, `routeKey`, `allowFallback`, and `optimizationPreferences` (`cost`, `speed`, `reliability`, or `quality`). Inspect the machine-readable contract and selected route context for the current exact surface:
|
|
545
|
-
|
|
546
|
-
```ts
|
|
547
|
-
const contract = await client.catalog.capabilities.contract(
|
|
548
|
-
"models",
|
|
549
|
-
"chat-complete",
|
|
550
|
-
);
|
|
551
|
-
const context = await client.catalog.routes.context(
|
|
552
|
-
"models.chat.complete.openrouter.mpp",
|
|
553
|
-
);
|
|
554
|
-
|
|
555
|
-
console.log(contract, context.execute?.fields);
|
|
6
|
+
npx @agentrouter/agentrouter connect # browser sign-in
|
|
7
|
+
npx @agentrouter/agentrouter find "recent X posts about a company"
|
|
8
|
+
npx @agentrouter/agentrouter describe anyapi.twitter.search
|
|
9
|
+
npx @agentrouter/agentrouter invoke anyapi.twitter.search --input '{"query":"from:AnthropicAI"}' --max-cost-usd 0.02 --output posts.json
|
|
556
10
|
```
|
|
557
11
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
- `client.email`
|
|
566
|
-
- `client.enrichment`
|
|
567
|
-
- `client.social`
|
|
568
|
-
- `client.web`
|
|
569
|
-
- `client.post`
|
|
570
|
-
- `client.broadcast`
|
|
571
|
-
|
|
572
|
-
Finance and hosted agents are currently best accessed through the generic
|
|
573
|
-
capability methods rather than a dedicated helper namespace:
|
|
574
|
-
|
|
575
|
-
```ts
|
|
576
|
-
const fxRate = await client.capabilities.execute({
|
|
577
|
-
domain: "finance",
|
|
578
|
-
capability: "fx-rate",
|
|
579
|
-
routeKey: "finance.fx.rate.abstract-exchange-rates.mpp",
|
|
580
|
-
input: {
|
|
581
|
-
fromCurrency: "USD",
|
|
582
|
-
toCurrency: "EUR",
|
|
583
|
-
},
|
|
584
|
-
allowFallback: false,
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
const fxConversion = await client.capabilities.execute({
|
|
588
|
-
domain: "finance",
|
|
589
|
-
capability: "fx-convert",
|
|
590
|
-
routeKey: "finance.fx.convert.abstract-exchange-rates.mpp",
|
|
591
|
-
input: {
|
|
592
|
-
fromCurrency: "USD",
|
|
593
|
-
toCurrency: "JPY",
|
|
594
|
-
amount: 25,
|
|
595
|
-
},
|
|
596
|
-
allowFallback: false,
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
const historicalFxRate = await client.capabilities.execute({
|
|
600
|
-
domain: "finance",
|
|
601
|
-
capability: "fx-rate-historical",
|
|
602
|
-
routeKey: "finance.fx.rate.historical.abstract-exchange-rates.mpp",
|
|
603
|
-
input: {
|
|
604
|
-
fromCurrency: "USD",
|
|
605
|
-
toCurrency: "GBP",
|
|
606
|
-
date: "2024-01-01",
|
|
607
|
-
},
|
|
608
|
-
allowFallback: false,
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
const hostedAgent = await client.capabilities.execute({
|
|
612
|
-
domain: "agents",
|
|
613
|
-
capability: "run",
|
|
614
|
-
routeKey: "agents.run.autoexchange.mpp",
|
|
615
|
-
input: {
|
|
616
|
-
id: "ab7527c0-6099-4145-9d8b-47f09dab9390",
|
|
617
|
-
prompt: "Say hello in one short sentence.",
|
|
618
|
-
stateless: true,
|
|
619
|
-
},
|
|
620
|
-
allowFallback: false,
|
|
621
|
-
});
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
Example:
|
|
625
|
-
|
|
626
|
-
```ts
|
|
627
|
-
const routed = await client.enrichment.route({
|
|
628
|
-
intent: "Find the work email for the VP Engineering at Example Corp",
|
|
629
|
-
companyName: "Example Corp",
|
|
630
|
-
title: "VP Engineering",
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
const contact = await client.enrichment.contactEnrich.execute(
|
|
634
|
-
{
|
|
635
|
-
linkedinUrl: "https://www.linkedin.com/in/example",
|
|
636
|
-
},
|
|
637
|
-
{
|
|
638
|
-
allowFallback: true,
|
|
639
|
-
},
|
|
640
|
-
);
|
|
641
|
-
|
|
642
|
-
const graphPerson = await client.capabilities.execute({
|
|
643
|
-
domain: "enrichment",
|
|
644
|
-
capability: "people-enrich",
|
|
645
|
-
routeKey: "enrichment.people.enrich.diffbot.mpp",
|
|
646
|
-
input: {
|
|
647
|
-
fullName: "Sam Altman",
|
|
648
|
-
companyName: "OpenAI",
|
|
649
|
-
},
|
|
650
|
-
allowFallback: false,
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
const graphCompany = await client.capabilities.execute({
|
|
654
|
-
domain: "enrichment",
|
|
655
|
-
capability: "company-enrich",
|
|
656
|
-
routeKey: "enrichment.company.enrich.diffbot.mpp",
|
|
657
|
-
input: {
|
|
658
|
-
companyName: "OpenAI",
|
|
659
|
-
domain: "openai.com",
|
|
660
|
-
},
|
|
661
|
-
allowFallback: false,
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
const letterRecommendation = await client.post.letter.send.recommend({
|
|
665
|
-
to: {
|
|
666
|
-
name: "Jianyu Li",
|
|
667
|
-
address_line1: "11030 SE 2nd St",
|
|
668
|
-
city: "Bellevue",
|
|
669
|
-
state: "WA",
|
|
670
|
-
zip: "98004",
|
|
671
|
-
country: "US",
|
|
672
|
-
},
|
|
673
|
-
from: {
|
|
674
|
-
name: "AgentRouter",
|
|
675
|
-
address_line1: "2261 Market St",
|
|
676
|
-
city: "San Francisco",
|
|
677
|
-
state: "CA",
|
|
678
|
-
zip: "94114",
|
|
679
|
-
country: "US",
|
|
680
|
-
},
|
|
681
|
-
pdf: {
|
|
682
|
-
url: "https://example.com/letter.pdf",
|
|
683
|
-
},
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
const postcard = await client.post.postcard.send.execute(
|
|
687
|
-
{
|
|
688
|
-
roast: "Launch follow-up postcard",
|
|
689
|
-
github_username: "codepoet",
|
|
690
|
-
type: "digital",
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
routeKey: "post.postcard.send.papercut.mpp",
|
|
694
|
-
allowFallback: false,
|
|
695
|
-
},
|
|
696
|
-
);
|
|
697
|
-
|
|
698
|
-
const broadcastQuote = await client.broadcast.message.quote.execute(
|
|
699
|
-
{},
|
|
700
|
-
{
|
|
701
|
-
routeKey: "broadcast.message.quote.billboard.mpp",
|
|
702
|
-
allowFallback: false,
|
|
703
|
-
},
|
|
704
|
-
);
|
|
705
|
-
|
|
706
|
-
const broadcastSendRecommendation =
|
|
707
|
-
await client.broadcast.message.send.recommend({
|
|
708
|
-
text: "Launch update goes here.",
|
|
709
|
-
optimizationPreferences: ["quality"],
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
const publications = await client.web.publications.list.execute(
|
|
713
|
-
{},
|
|
714
|
-
{
|
|
715
|
-
routeKey: "web.publication.list.dripstack.mpp",
|
|
716
|
-
allowFallback: false,
|
|
717
|
-
},
|
|
718
|
-
);
|
|
719
|
-
|
|
720
|
-
const publicationPosts = await client.web.publications.posts.list.execute(
|
|
721
|
-
{
|
|
722
|
-
publicationSlug: "newsletter.morning-brew.morningbrew.com",
|
|
723
|
-
},
|
|
724
|
-
{
|
|
725
|
-
routeKey: "web.publication.posts.list.dripstack.mpp",
|
|
726
|
-
allowFallback: false,
|
|
727
|
-
},
|
|
728
|
-
);
|
|
729
|
-
|
|
730
|
-
const publicationPost = await client.web.publications.post.get.execute(
|
|
731
|
-
{
|
|
732
|
-
publicationSlug: "newsletter.morning-brew.morningbrew.com",
|
|
733
|
-
postSlug: "cheers-to-beer-20260506",
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
routeKey: "web.publication.post.get.dripstack.mpp",
|
|
737
|
-
allowFallback: false,
|
|
738
|
-
},
|
|
739
|
-
);
|
|
740
|
-
|
|
741
|
-
const publicationPostGeneric = await client.capabilities.execute({
|
|
742
|
-
domain: "web",
|
|
743
|
-
capability: "publication-post-get",
|
|
744
|
-
routeKey: "web.publication.post.get.dripstack.mpp",
|
|
745
|
-
input: {
|
|
746
|
-
publicationSlug: "newsletter.morning-brew.morningbrew.com",
|
|
747
|
-
postSlug: "cheers-to-beer-20260506",
|
|
748
|
-
},
|
|
749
|
-
allowFallback: false,
|
|
750
|
-
});
|
|
751
|
-
```
|
|
752
|
-
|
|
753
|
-
Treat `broadcast.message.send` as a recommend-or-review step until a human explicitly approves the exact public message body and spend.
|
|
754
|
-
|
|
755
|
-
DripStack publication discovery is exposed through `web.publication.list.dripstack.mpp` and `web.publication.posts.list.dripstack.mpp` as free reads. `web.publication.post.get.dripstack.mpp` retrieves one selected article and is a paid route that starts at 50 credits, so inspect route context and make an explicit article choice before execution.
|
|
756
|
-
|
|
757
|
-
## Auth
|
|
758
|
-
|
|
759
|
-
Hosted usage:
|
|
760
|
-
|
|
761
|
-
```ts
|
|
762
|
-
const client = new AgentRouterClient({
|
|
763
|
-
apiKey: process.env.AGENTIC_API_KEY,
|
|
764
|
-
baseUrl: "https://api.agentrouter.to/api/agentic-api",
|
|
765
|
-
});
|
|
766
|
-
```
|
|
767
|
-
|
|
768
|
-
Local development also supports user-scoped fallback against local AgentRouter
|
|
769
|
-
servers:
|
|
770
|
-
|
|
771
|
-
```ts
|
|
772
|
-
const wallet = await client.wallet.get({
|
|
773
|
-
userId: "agentrouter-sdk-smoke-user",
|
|
774
|
-
});
|
|
775
|
-
```
|
|
776
|
-
|
|
777
|
-
## Security Note
|
|
778
|
-
|
|
779
|
-
Do not expose `AGENTIC_API_KEY` in browser client code. Use this SDK from
|
|
780
|
-
server-side environments such as:
|
|
781
|
-
|
|
782
|
-
- Node.js services
|
|
783
|
-
- Next.js server routes and server actions
|
|
784
|
-
- CLI tools
|
|
785
|
-
- agent runtimes
|
|
786
|
-
|
|
787
|
-
## API Surface
|
|
788
|
-
|
|
789
|
-
Top-level modules:
|
|
790
|
-
|
|
791
|
-
- `client.catalog`
|
|
792
|
-
- `client.capabilities`
|
|
793
|
-
- `client.wallet`
|
|
794
|
-
- `client.usage`
|
|
795
|
-
- `client.auth`
|
|
796
|
-
- `client.raw`
|
|
797
|
-
|
|
798
|
-
## Notes
|
|
12
|
+
- **Sign-in:** `agentrouter connect` opens the browser (OAuth with PKCE, loopback redirect). In CI set `AGENTROUTER_API_KEY` (create a key in the dashboard or with `agentrouter keys add <name>`).
|
|
13
|
+
- Use `agentrouter keys set` to store a dashboard key from a hidden prompt or stdin, and `agentrouter keys clear` to remove that local key.
|
|
14
|
+
- **Machine output:** `--json` prints only JSON on stdout; progress goes to stderr. Amounts are decimal strings.
|
|
15
|
+
- **Retries:** every `invoke` sends an idempotency key (printed to stderr, or pass `--idempotency-key`). Re-running with the same key returns the original run without another charge.
|
|
16
|
+
- **Long runs:** `--wait` polls the same run; `agentrouter runs get <run_id> --output file.json` exports a stored result later — results are never fetched by invoking again.
|
|
17
|
+
- **Prices:** `invoke` sends the `pricing_version` from `describe`. If the price changed it stops with exit code 5 and runs nothing.
|
|
18
|
+
- **MCP:** if your agent already has the AgentRouter MCP connected you do not need this CLI. MCP and CLI sign in separately; `agentrouter whoami` shows which wallet the CLI uses.
|
|
799
19
|
|
|
800
|
-
|
|
801
|
-
- For email inbox acquisition, the canonical capability ID is `inbox-acquire`.
|
|
802
|
-
- The backend may still accept legacy aliases such as `inbox-buy`, but the SDK
|
|
803
|
-
normalizes to canonical capability IDs.
|
|
804
|
-
- Recommend, route, and execute responses preserve the raw backend payload on
|
|
805
|
-
`raw`.
|
|
20
|
+
Exit codes: 0 ok · 1 error · 2 usage · 3 auth · 4 run failed · 5 price/version changed · 6 blocked by budget or balance · 7 still running · 8 output file not written · 9 not found.
|
|
806
21
|
|
|
807
|
-
|
|
22
|
+
Docs: https://docs.agentrouter.to/integrations/cli
|
|
808
23
|
|
|
809
|
-
|
|
810
|
-
- Install flow: `https://www.agentrouter.to/agentic-api/install`
|
|
811
|
-
- skill.md: `https://www.agentrouter.to/SKILL.md`
|
|
24
|
+
Catalog filtering: `agentrouter find "person profile" --category linkedin --group gtm --provider anyapi`. `--category` and `--group` accept comma-separated IDs. Read the two-level directory from `GET /v1/catalog`; categories include both product names and capabilities, and there is no separate platform filter.
|