@agentrouter/agentrouter 0.1.12 → 0.2.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 CHANGED
@@ -1,769 +1,24 @@
1
- # AgentRouter SDK
1
+ # AgentRouter CLI
2
2
 
3
- TypeScript SDK for the AgentRouter.
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
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.
27
4
 
28
5
  ```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(recommendation.recommendedRouteKey);
51
-
52
- const result = await client.capabilities.execute({
53
- domain: recommendation.resolution.domainKey,
54
- capability: recommendation.resolution.capabilityId,
55
- routeKey: recommendation.recommendedRouteKey,
56
- input: {
57
- inbox_name: "launch-updates",
58
- },
59
- allowFallback: true,
60
- });
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
61
10
  ```
62
11
 
63
- If you want the hosted mapping step directly, call:
64
-
65
- ```ts
66
- const resolution = await client.intent.resolve(
67
- "can you help me buy an email inbox?",
68
- );
69
- ```
70
-
71
- Structured:
72
-
73
- ```ts
74
- import { AgentRouterClient } from "@agentrouter/agentrouter";
75
-
76
- const client = new AgentRouterClient({
77
- apiKey: process.env.AGENTIC_API_KEY,
78
- });
79
-
80
- const domains = await client.catalog.domains.list();
81
- const capabilities = await client.catalog.capabilities.list("email");
82
-
83
- const recommendation = await client.capabilities.recommend({
84
- domain: "email",
85
- capability: "send",
86
- input: {
87
- optimizationPreferences: ["cost", "quality"],
88
- },
89
- });
90
-
91
- const result = await client.capabilities.execute({
92
- domain: "email",
93
- capability: "send",
94
- input: {
95
- to: "maya@example.com",
96
- subject: "Hello from AgentRouter",
97
- html: "<p>Hello</p>",
98
- },
99
- provider: recommendation.recommendedProvider,
100
- allowFallback: true,
101
- });
102
- ```
103
-
104
- ## CLI
105
-
106
- The package also ships a thin CLI wrapper over the same SDK semantics.
107
-
108
- Create an API key at `https://www.agentrouter.to/agentic-api/install` and
109
- export it before hosted CLI requests:
110
-
111
- ```bash
112
- export AGENTIC_API_KEY=your_key_here
113
- ```
114
-
115
- Install locally:
116
-
117
- ```bash
118
- npm install @agentrouter/agentrouter
119
- npx agentrouter domains list
120
- ```
121
-
122
- Or run it without adding the package to your app:
123
-
124
- ```bash
125
- npx -p @agentrouter/agentrouter agentrouter domains list
126
- ```
127
-
128
- Examples:
129
-
130
- ```bash
131
- agentrouter wallet
132
- agentrouter capabilities list email
133
- agentrouter capabilities list models
134
- agentrouter capabilities list text
135
- agentrouter capabilities list translation
136
- agentrouter capabilities list finance
137
- agentrouter capabilities list tax
138
- agentrouter capabilities list captcha
139
- agentrouter capabilities list commerce
140
- agentrouter capabilities list lottery
141
- agentrouter capabilities list music
142
- agentrouter capabilities list property
143
- agentrouter capabilities list media
144
- agentrouter capabilities list web
145
- agentrouter routes context email.send.resend
146
- agentrouter routes context models.chat.complete.deepseek.mpp
147
- agentrouter routes context models.chat.complete.groq.mpp
148
- agentrouter routes context text.analyze.diffbot-nl.mpp
149
- agentrouter routes context translation.text.rephrase.deepl.mpp
150
- agentrouter routes context web.extract.diffbot.mpp
151
- agentrouter routes context web.publication.list.dripstack.mpp
152
- agentrouter routes context web.publication.post.get.dripstack.mpp
153
- agentrouter routes context enrichment.people.enrich.diffbot.mpp
154
- agentrouter routes context finance.equity.quote.alphavantage.mpp
155
- agentrouter routes context finance.fx.rate.abstract-exchange-rates.mpp
156
- agentrouter routes context finance.fx.convert.abstract-exchange-rates.mpp
157
- agentrouter routes context finance.fx.rate.historical.abstract-exchange-rates.mpp
158
- agentrouter routes context tax.vat.validate.abstract-vat.mpp
159
- agentrouter routes context tax.vat.calculate.abstract-vat.mpp
160
- agentrouter routes context tax.vat.categories.list.abstract-vat.mpp
161
- agentrouter routes context captcha.task.create.twocaptcha.mpp
162
- agentrouter routes context commerce.product.search.kicksdb.stockx.mpp
163
- agentrouter routes context lottery.round.active.megapot
164
- agentrouter routes context music.song.generate.suno.mpp
165
- agentrouter routes context property.records.search.rentcast.mpp
166
- agentrouter routes context media.image.generate.fal.mpp
167
- agentrouter routes context travel.airport.operations.flightapi.mpp
168
- agentrouter recommend email send --input '{"optimizationPreferences":["cost"]}'
169
- agentrouter recommend text analyze --input '{"provider":"diffbot-nl","fields":"entities,sentiment,language","optimizationPreferences":["quality"]}' --json
170
- agentrouter execute models chat-complete --input '{"model":"deepseek-v4-flash","messages":[{"role":"user","content":"Say AgentRouter DeepSeek smoke OK."}]}' --route-key models.chat.complete.deepseek.mpp --json
171
- 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
172
- agentrouter execute web extract --input '{"url":"https://www.example.com/article"}' --route-key web.extract.diffbot.mpp --json
173
- agentrouter execute web publication-list --input '{"allowFallback":false}' --route-key web.publication.list.dripstack.mpp --json
174
- agentrouter execute web publication-posts-list --input '{"publicationSlug":"newsletter.morning-brew.morningbrew.com","allowFallback":false}' --route-key web.publication.posts.list.dripstack.mpp --json
175
- 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
176
- agentrouter execute enrichment people-enrich --input '{"fullName":"Sam Altman","companyName":"OpenAI"}' --route-key enrichment.people.enrich.diffbot.mpp --json
177
- agentrouter recommend finance equity-quote --input '{"symbol":"MSFT","optimizationPreferences":["speed","quality"]}' --json
178
- agentrouter recommend finance fx-convert --input '{"fromCurrency":"USD","toCurrency":"JPY","amount":25,"optimizationPreferences":["cost"]}' --json
179
- agentrouter execute email send --input @send-email.json --route-key email.send.resend --allow-fallback
180
- agentrouter execute finance equity-quote --input '{"symbol":"MSFT"}' --route-key finance.equity.quote.alphavantage.mpp --json
181
- agentrouter execute finance fx-convert --input '{"fromCurrency":"USD","toCurrency":"JPY","amount":25}' --route-key finance.fx.convert.abstract-exchange-rates.mpp --json
182
- agentrouter execute tax vat-validate --input '{"vatNumber":"DE123456789","countryCode":"DE","allowFallback":false}' --route-key tax.vat.validate.abstract-vat.mpp --provider abstract-vat --json
183
- 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
184
- 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
185
- agentrouter execute travel airport-operations --input '{"iataCode":"JFK","mode":"departures","limit":1}' --route-key travel.airport.operations.flightapi.mpp --provider flightapi --json
186
- agentrouter route enrichment --input '{"intent":"Find the work email for the VP Engineering at Example Corp"}'
187
- ```
188
-
189
- 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.
190
-
191
- 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`.
192
-
193
- 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.
194
-
195
- 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.
196
-
197
- Environment variables:
198
-
199
- - `AGENTIC_API_BASE_URL`
200
- - `AGENTIC_API_KEY`
201
- - `AGENTIC_API_SESSION_TOKEN`
202
- - `AGENTIC_API_USER_ID`
203
- - `AGENTIC_API_TIMEOUT_MS`
204
-
205
- ## Recommended Flow
206
-
207
- 1. List domains with `client.catalog.domains.list()`
208
- 2. List capabilities with `client.catalog.capabilities.list(domainKey)`
209
- 3. Inspect routes or contracts for a capability
210
- 4. Ask for a recommendation
211
- 5. Execute explicitly
212
-
213
- This keeps your integration stable even when providers or routes change.
214
-
215
- ## Catalog Discovery
216
-
217
- ```ts
218
- const domain = await client.catalog.domains.get("enrichment");
219
-
220
- const capability = await client.catalog.capabilities.get("email", "send");
221
-
222
- const routes = await client.catalog.capabilities.routes("email", "send");
223
-
224
- const contract = await client.catalog.capabilities.contract("email", "send");
225
-
226
- const routeContext = await client.catalog.routes.context("email.send.resend");
227
- ```
228
-
229
- Capability contracts describe the common input shape for a workflow. Route
230
- contexts describe the executable surface for one selected route, including
231
- route-specific fields and possible provider/wrapper values. Read each possible
232
- value's label and description to map natural language to the exact value.
233
-
234
- When you want one concrete route, execute through the capability endpoint and
235
- pass `routeKey`; the SDK sends it in the request body.
236
-
237
- ```ts
238
- const result = await client.capabilities.execute({
239
- domain: "travel",
240
- capability: "flight-search",
241
- routeKey: "travel.flight.search.stabletravel.googleflights.agentcash",
242
- input: {
243
- departure_id: "JFK",
244
- arrival_id: "LAX",
245
- outbound_date: "2026-05-01",
246
- type: "2",
247
- travel_class: "1",
248
- adults: 1,
249
- },
250
- allowFallback: false,
251
- });
252
- ```
253
-
254
- The same generic surface also works for physical-mail workflows:
255
-
256
- ```ts
257
- const postcard = await client.capabilities.execute({
258
- domain: "post",
259
- capability: "postcard-send",
260
- routeKey: "post.postcard.send.papercut.mpp",
261
- input: {
262
- roast: "Launch follow-up postcard",
263
- github_username: "codepoet",
264
- type: "digital",
265
- },
266
- allowFallback: false,
267
- });
268
- ```
269
-
270
- It also works for public-broadcast price checks:
271
-
272
- ```ts
273
- const broadcastQuote = await client.capabilities.execute({
274
- domain: "broadcast",
275
- capability: "message-quote",
276
- routeKey: "broadcast.message.quote.billboard.mpp",
277
- input: {},
278
- allowFallback: false,
279
- });
280
- ```
281
-
282
- 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`.
283
-
284
- For text analysis, use the generic surface for recommendation and route context only until the Diffbot NL route clears its runtime gate:
285
-
286
- ```ts
287
- const textRecommendation = await client.capabilities.recommend({
288
- domain: "text",
289
- capability: "analyze",
290
- input: {
291
- provider: "diffbot-nl",
292
- fields: "entities,sentiment,language",
293
- optimizationPreferences: ["quality"],
294
- },
295
- });
296
-
297
- const textContext = await client.catalog.routes.context(
298
- "text.analyze.diffbot-nl.mpp",
299
- );
300
-
301
- console.log(textRecommendation.recommendedRouteKey);
302
- console.log(textContext.routeKey);
303
- ```
304
-
305
- 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.
306
-
307
- It also works for route-pinned fal image generation through the media domain:
308
-
309
- ```ts
310
- const heroImage = await client.capabilities.execute({
311
- domain: "media",
312
- capability: "image-generate",
313
- routeKey: "media.image.generate.fal.mpp",
314
- input: {
315
- prompt: "Create a clean launch hero image for an AI developer tool",
316
- aspectRatio: "16:9",
317
- },
318
- provider: "fal",
319
- allowFallback: false,
320
- });
321
-
322
- console.log(heroImage.primaryImageUrl);
323
- ```
324
-
325
- 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.
326
-
327
- It also works for DeepL Write rephrase through the translation domain:
328
-
329
- ```ts
330
- const rewrite = await client.capabilities.execute({
331
- domain: "translation",
332
- capability: "text-rephrase",
333
- routeKey: "translation.text.rephrase.deepl.mpp",
334
- input: {
335
- text: "Please make this product update friendlier.",
336
- targetLanguage: "EN-US",
337
- tone: "prefer_friendly",
338
- },
339
- allowFallback: false,
340
- });
341
-
342
- console.log(rewrite.rewrittenText);
343
- ```
344
-
345
- For DeepL rephrase, fetch route context before execution and use the exposed DeepL Write fields: `text`, `targetLanguage`, and optional `tone`.
346
-
347
- It also works for route-pinned airport schedule operations on FlightAPI:
348
-
349
- ```ts
350
- const airportOperations = await client.capabilities.execute({
351
- domain: "travel",
352
- capability: "airport-operations",
353
- routeKey: "travel.airport.operations.flightapi.mpp",
354
- input: {
355
- iataCode: "JFK",
356
- mode: "departures",
357
- limit: 1,
358
- },
359
- provider: "flightapi",
360
- allowFallback: false,
361
- });
362
- ```
363
-
364
- 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.
365
-
366
- If your deployment exposes the finance domain, it also works for finance market-data routes:
367
-
368
- ```ts
369
- const marketStatus = await client.capabilities.execute({
370
- domain: "finance",
371
- capability: "market-status",
372
- routeKey: "finance.market.status.alphavantage.mpp",
373
- input: {},
374
- allowFallback: false,
375
- });
376
-
377
- const quote = await client.capabilities.execute({
378
- domain: "finance",
379
- capability: "equity-quote",
380
- routeKey: "finance.equity.quote.alphavantage.mpp",
381
- input: {
382
- symbol: "MSFT",
383
- },
384
- allowFallback: false,
385
- });
386
-
387
- const fxRate = await client.capabilities.execute({
388
- domain: "finance",
389
- capability: "fx-rate",
390
- routeKey: "finance.fx.rate.abstract-exchange-rates.mpp",
391
- input: {
392
- fromCurrency: "USD",
393
- toCurrency: "EUR",
394
- },
395
- allowFallback: false,
396
- });
397
-
398
- const fxConversion = await client.capabilities.execute({
399
- domain: "finance",
400
- capability: "fx-convert",
401
- routeKey: "finance.fx.convert.abstract-exchange-rates.mpp",
402
- input: {
403
- fromCurrency: "USD",
404
- toCurrency: "JPY",
405
- amount: 25,
406
- },
407
- allowFallback: false,
408
- });
409
-
410
- const historicalFxRate = await client.capabilities.execute({
411
- domain: "finance",
412
- capability: "fx-rate-historical",
413
- routeKey: "finance.fx.rate.historical.abstract-exchange-rates.mpp",
414
- input: {
415
- fromCurrency: "USD",
416
- toCurrency: "GBP",
417
- date: "2024-01-01",
418
- },
419
- allowFallback: false,
420
- });
421
- ```
422
-
423
- If your deployment exposes the tax domain, the same generic surface works for VAT validation, calculation, and category-rate lookup:
424
-
425
- ```ts
426
- const vatValidation = await client.capabilities.execute({
427
- domain: "tax",
428
- capability: "vat-validate",
429
- routeKey: "tax.vat.validate.abstract-vat.mpp",
430
- input: {
431
- vatNumber: "DE123456789",
432
- countryCode: "DE",
433
- },
434
- allowFallback: false,
435
- });
436
-
437
- const vatCalculation = await client.capabilities.execute({
438
- domain: "tax",
439
- capability: "vat-calculate",
440
- routeKey: "tax.vat.calculate.abstract-vat.mpp",
441
- input: {
442
- countryCode: "DE",
443
- amount: 100,
444
- calculationType: "add",
445
- },
446
- allowFallback: false,
447
- });
448
-
449
- const vatCategories = await client.capabilities.execute({
450
- domain: "tax",
451
- capability: "vat-categories-list",
452
- routeKey: "tax.vat.categories.list.abstract-vat.mpp",
453
- input: {
454
- countryCode: "DE",
455
- },
456
- allowFallback: false,
457
- });
458
- ```
459
-
460
- If your deployment exposes the agents domain, the same generic surface also works for hosted-agent discovery and stateless paid execution:
461
-
462
- ```ts
463
- const agentSearch = await client.capabilities.recommend({
464
- domain: "agents",
465
- capability: "search",
466
- input: {
467
- query: "privy",
468
- optimizationPreferences: ["quality"],
469
- },
470
- });
471
-
472
- const agentRun = await client.capabilities.execute({
473
- domain: "agents",
474
- capability: "run",
475
- routeKey: "agents.run.autoexchange.mpp",
476
- input: {
477
- id: "ab7527c0-6099-4145-9d8b-47f09dab9390",
478
- prompt: "Say hello in one short sentence.",
479
- stateless: true,
480
- },
481
- allowFallback: false,
482
- });
483
- ```
484
-
485
- 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`:
486
-
487
- ```ts
488
- const modelChat = await client.capabilities.execute({
489
- domain: "models",
490
- capability: "chat-complete",
491
- routeKey: "models.chat.complete.deepseek.mpp",
492
- input: {
493
- model: "deepseek-v4-flash",
494
- messages: [
495
- {
496
- role: "user",
497
- content: "Say AgentRouter DeepSeek smoke OK.",
498
- },
499
- ],
500
- },
501
- allowFallback: false,
502
- });
503
-
504
- const modelList = await client.capabilities.execute({
505
- domain: "models",
506
- capability: "list",
507
- routeKey: "models.list.deepseek.mpp",
508
- input: {},
509
- allowFallback: false,
510
- });
511
-
512
- console.log(modelChat.completionText);
513
- console.log(modelList.models);
514
- ```
515
-
516
- Fetch route context before execution to choose a supported model id. The May 5, 2026 live DeepSeek list route returned `deepseek-v4-flash` and `deepseek-v4-pro`, and the May 10, 2026 Groq chat smoke returned `AgentRouter Groq smoke OK` from `llama-3.1-8b-instant`.
517
-
518
- ## Domain Helpers
519
-
520
- The generic capability methods are the main contract. The SDK also includes
521
- helper namespaces where they improve ergonomics:
522
-
523
- - `client.email`
524
- - `client.enrichment`
525
- - `client.social`
526
- - `client.web`
527
- - `client.post`
528
- - `client.broadcast`
529
-
530
- Finance and hosted agents are currently best accessed through the generic
531
- capability methods rather than a dedicated helper namespace:
532
-
533
- ```ts
534
- const fxRate = await client.capabilities.execute({
535
- domain: "finance",
536
- capability: "fx-rate",
537
- routeKey: "finance.fx.rate.abstract-exchange-rates.mpp",
538
- input: {
539
- fromCurrency: "USD",
540
- toCurrency: "EUR",
541
- },
542
- allowFallback: false,
543
- });
544
-
545
- const fxConversion = await client.capabilities.execute({
546
- domain: "finance",
547
- capability: "fx-convert",
548
- routeKey: "finance.fx.convert.abstract-exchange-rates.mpp",
549
- input: {
550
- fromCurrency: "USD",
551
- toCurrency: "JPY",
552
- amount: 25,
553
- },
554
- allowFallback: false,
555
- });
556
-
557
- const historicalFxRate = await client.capabilities.execute({
558
- domain: "finance",
559
- capability: "fx-rate-historical",
560
- routeKey: "finance.fx.rate.historical.abstract-exchange-rates.mpp",
561
- input: {
562
- fromCurrency: "USD",
563
- toCurrency: "GBP",
564
- date: "2024-01-01",
565
- },
566
- allowFallback: false,
567
- });
568
-
569
- const hostedAgent = await client.capabilities.execute({
570
- domain: "agents",
571
- capability: "run",
572
- routeKey: "agents.run.autoexchange.mpp",
573
- input: {
574
- id: "ab7527c0-6099-4145-9d8b-47f09dab9390",
575
- prompt: "Say hello in one short sentence.",
576
- stateless: true,
577
- },
578
- allowFallback: false,
579
- });
580
- ```
581
-
582
- Example:
583
-
584
- ```ts
585
- const routed = await client.enrichment.route({
586
- intent: "Find the work email for the VP Engineering at Example Corp",
587
- companyName: "Example Corp",
588
- title: "VP Engineering",
589
- });
590
-
591
- const contact = await client.enrichment.contactEnrich.execute(
592
- {
593
- linkedinUrl: "https://www.linkedin.com/in/example",
594
- },
595
- {
596
- allowFallback: true,
597
- },
598
- );
599
-
600
- const graphPerson = await client.capabilities.execute({
601
- domain: "enrichment",
602
- capability: "people-enrich",
603
- routeKey: "enrichment.people.enrich.diffbot.mpp",
604
- input: {
605
- fullName: "Sam Altman",
606
- companyName: "OpenAI",
607
- },
608
- allowFallback: false,
609
- });
610
-
611
- const graphCompany = await client.capabilities.execute({
612
- domain: "enrichment",
613
- capability: "company-enrich",
614
- routeKey: "enrichment.company.enrich.diffbot.mpp",
615
- input: {
616
- companyName: "OpenAI",
617
- domain: "openai.com",
618
- },
619
- allowFallback: false,
620
- });
621
-
622
- const letterRecommendation = await client.post.letter.send.recommend({
623
- to: {
624
- name: "Jianyu Li",
625
- address_line1: "11030 SE 2nd St",
626
- city: "Bellevue",
627
- state: "WA",
628
- zip: "98004",
629
- country: "US",
630
- },
631
- from: {
632
- name: "AgentRouter",
633
- address_line1: "2261 Market St",
634
- city: "San Francisco",
635
- state: "CA",
636
- zip: "94114",
637
- country: "US",
638
- },
639
- pdf: {
640
- url: "https://example.com/letter.pdf",
641
- },
642
- });
643
-
644
- const postcard = await client.post.postcard.send.execute(
645
- {
646
- roast: "Launch follow-up postcard",
647
- github_username: "codepoet",
648
- type: "digital",
649
- },
650
- {
651
- routeKey: "post.postcard.send.papercut.mpp",
652
- allowFallback: false,
653
- },
654
- );
655
-
656
- const broadcastQuote = await client.broadcast.message.quote.execute(
657
- {},
658
- {
659
- routeKey: "broadcast.message.quote.billboard.mpp",
660
- allowFallback: false,
661
- },
662
- );
663
-
664
- const broadcastSendRecommendation =
665
- await client.broadcast.message.send.recommend({
666
- text: "Launch update goes here.",
667
- optimizationPreferences: ["quality"],
668
- });
669
-
670
- const publications = await client.web.publications.list.execute(
671
- {},
672
- {
673
- routeKey: "web.publication.list.dripstack.mpp",
674
- allowFallback: false,
675
- },
676
- );
677
-
678
- const publicationPosts = await client.web.publications.posts.list.execute(
679
- {
680
- publicationSlug: "newsletter.morning-brew.morningbrew.com",
681
- },
682
- {
683
- routeKey: "web.publication.posts.list.dripstack.mpp",
684
- allowFallback: false,
685
- },
686
- );
687
-
688
- const publicationPost = await client.web.publications.post.get.execute(
689
- {
690
- publicationSlug: "newsletter.morning-brew.morningbrew.com",
691
- postSlug: "cheers-to-beer-20260506",
692
- },
693
- {
694
- routeKey: "web.publication.post.get.dripstack.mpp",
695
- allowFallback: false,
696
- },
697
- );
698
-
699
- const publicationPostGeneric = await client.capabilities.execute({
700
- domain: "web",
701
- capability: "publication-post-get",
702
- routeKey: "web.publication.post.get.dripstack.mpp",
703
- input: {
704
- publicationSlug: "newsletter.morning-brew.morningbrew.com",
705
- postSlug: "cheers-to-beer-20260506",
706
- },
707
- allowFallback: false,
708
- });
709
- ```
710
-
711
- Treat `broadcast.message.send` as a recommend-or-review step until a human explicitly approves the exact public message body and spend.
712
-
713
- 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.
714
-
715
- ## Auth
716
-
717
- Hosted usage:
718
-
719
- ```ts
720
- const client = new AgentRouterClient({
721
- apiKey: process.env.AGENTIC_API_KEY,
722
- baseUrl: "https://api.agentrouter.to/api/agentic-api",
723
- });
724
- ```
725
-
726
- Local development also supports user-scoped fallback against local AgentRouter
727
- servers:
728
-
729
- ```ts
730
- const wallet = await client.wallet.get({
731
- userId: "agentrouter-sdk-smoke-user",
732
- });
733
- ```
734
-
735
- ## Security Note
736
-
737
- Do not expose `AGENTIC_API_KEY` in browser client code. Use this SDK from
738
- server-side environments such as:
739
-
740
- - Node.js services
741
- - Next.js server routes and server actions
742
- - CLI tools
743
- - agent runtimes
744
-
745
- ## API Surface
746
-
747
- Top-level modules:
748
-
749
- - `client.catalog`
750
- - `client.capabilities`
751
- - `client.wallet`
752
- - `client.usage`
753
- - `client.auth`
754
- - `client.raw`
755
-
756
- ## 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.
757
19
 
758
- - Canonical capability IDs come from the catalog.
759
- - For email inbox acquisition, the canonical capability ID is `inbox-acquire`.
760
- - The backend may still accept legacy aliases such as `inbox-buy`, but the SDK
761
- normalizes to canonical capability IDs.
762
- - Recommend, route, and execute responses preserve the raw backend payload on
763
- `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.
764
21
 
765
- ## Resources
22
+ Docs: https://docs.agentrouter.to/integrations/cli
766
23
 
767
- - SDK docs: `https://docs.agentrouter.to/integrations/sdk`
768
- - Install flow: `https://www.agentrouter.to/agentic-api/install`
769
- - 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.