Skip to content

TypeScript SDK

Terminal window
npm install route-tools

Works anywhere fetch does — Node 18+, Bun, Deno, Cloudflare Workers, browsers.

import { RouteTools } from 'route-tools';
const rt = new RouteTools({
apiKey: process.env.ROUTE_TOOLS_API_KEY!,
// optional: default routing applied to every call
routing: { sort: 'price' },
});
const search = await rt.search({ query: 'best vector databases 2026' });
const page = await rt.scrape({ url: 'https://example.com/article' });
const doc = await rt.parse({ document_url: 'https://example.com/report.pdf' });
const img = await rt.image({ prompt: 'isometric watercolor data center' });
const run = await rt.code({ language: 'python', code: 'print(40 + 2)' });
console.log(search.provider); // which provider won the route
console.log(search.usage.price); // what the call cost (USD)
console.log(search.routing.attempted); // the failover chain
import { RouteToolsError } from 'route-tools';
try {
await rt.search({ query: 'hello' });
} catch (err) {
if (err instanceof RouteToolsError) {
err.code; // 'insufficient_credits' | 'all_providers_failed' | ...
err.status; // HTTP status
err.attempted; // per-provider failure detail on 502s
err.requestId; // pass to support
}
}
await rt.balance(); // { credits_remaining_usd: 1.84, ... }
await rt.catalog(); // live providers + prices per category

The REST API is a single normalized endpoint — see the OpenAPI spec to generate clients, or call it directly with any HTTP library (quickstart).