SDK
The TypeScript SDK is the best integration surface when you are building directly on AgentRouter from a server, worker, CLI, or agent runtime.
It stays capability-first:
- list domains
- inspect capabilities
- inspect routes or contract
- recommend a route
- execute explicitly
Use the API Reference tab for endpoint-level HTTP detail. Use this page for SDK install guidance, integration patterns, and working examples.
Why Start With The SDK
Use the SDK when you want:
- one explicit client object
- typed catalog discovery
- typed recommend and execute flows
- one place for API key, session token, and timeout configuration
- helper namespaces for
email,enrichment,social,post, andbroadcast - raw response access when you need domain-specific fields without losing normalized metadata
Use SKILL.md when another coding agent should read instructions and make HTTP calls itself.
Use CLI when a human operator, support engineer, or CI job should run the same capability-first flow from a terminal.
Use MCP when the runtime is MCP-compatible and you want hosted tool exposure.
Install
The same package also ships the agentrouter CLI. See CLI when you want terminal-first workflows on top of the same SDK semantics.
Create The Client
Use this SDK from server-side runtimes only. Do not expose AGENTIC_API_KEY in browser code.
Recommended Flow
Catalog First
The catalog is the source of truth for:
- canonical capability IDs
- capability contracts
- capability route metadata
- whether a domain supports intent routing
Generic Capability Methods
The generic capability methods are the stable contract.
Broadcast Example: Quote First, Approve Send Separately
broadcast.message.quote is live. broadcast.message.send is mapped but intentionally gated because one live execute creates a real public post.
Translation Example: DeepL Rephrase
translation.text.rephrase.deepl.mpp is live after the May 5, 2026 paid route-by-route retest. Use the generic capability methods and fetch route context before execution so your payload uses text, targetLanguage, and optional tone.
Geo Example: Abstract Timezone Conversion
geo.time.current.abstract-timezone.mpp and geo.time.convert.abstract-timezone.mpp are live after the May 9, 2026 paid route-by-route smoke. Use generic capability methods and fetch route context before execution so your payload uses location for current time or fromLocation, toLocation, and optional datetime for conversion.
Models Example: DeepSeek Chat Completion
models.chat.complete.deepseek.mpp, models.code.complete.deepseek.mpp, and models.list.deepseek.mpp are live through the generic capability surface after the May 5, 2026 production-mode smoke. Fetch route context before execution so your payload uses a supported model id such as deepseek-v4-flash.
Text Analysis Example: Recommend And Context Only
text.analyze.diffbot-nl.mpp is mapped and recommendable through Diffbot NL, but it is not live for execution yet. Direct Diffbot NL MPP wrapper checks on May 5, 2026 returned HTTP 429 before payment, so no AgentRouter credits were charged. Use recommend and route context until canExecuteNow is true and a paid route smoke succeeds.
Media Example: fal Image Routes
fal image generation and image edit are live on MPP image routes. media.video.generate.fal.mpp remains gated after upstream paymentauth 524 timeouts reproduced outside AgentRouter, so use recommend and route context for video generation until paid smoke evidence exists.
Web And Enrichment Example: Diffbot Routes
web.extract.diffbot.mpp, enrichment.people.enrich.diffbot.mpp, and enrichment.company.enrich.diffbot.mpp are live after the May 5, 2026 route-by-route retest. Fetch route context before execution so the SDK payload matches the selected Diffbot route.
Travel Example: Pin FlightAPI Airport Operations
When you need one concrete travel provider, fetch route context first and then pin the routeKey during execute:
Use the route context to confirm route-specific fields before execution. FlightAPI airport operations passed a May 8, 2026 production smoke through travel.airport.operations.flightapi.mpp.
Domain Helpers And Examples
The SDK also exposes high-value helper namespaces:
Enrichment
Social
Response Model
Recommend, route, and execute responses preserve normalized fields and the raw backend payload:
That lets you keep a stable integration while still inspecting domain-specific fields when needed.
Raw Requests And Auth
For endpoints that are not wrapped yet, you can fall back to the raw client:
The SDK supports:
- API key auth for normal server-side usage
- session token auth for session-backed flows
userIdpassthrough for local development helpers- per-call
timeoutMsoverrides
Observe Wallet And Usage
The SDK keeps wallet and usage close to execution so developers can audit spend and route behavior without switching abstractions.
Compatibility Notes
- Canonical capability IDs come from the catalog.
- The canonical email inbox acquisition capability ID is
inbox-acquire. - The backend still accepts the legacy alias
inbox-buy. - The SDK exposes both
client.email.inbox.acquireandclient.email.inbox.buy, but both target the canonical capability under the hood.