Framework integrations
Vercel AI SDK
Section titled “Vercel AI SDK”Wrap any Route Tools call as a tool — the model picks when to call it; we pick the provider:
import { generateText, tool, stepCountIs } from 'ai';import { z } from 'zod';import { RouteTools } from 'route-tools';
const rt = new RouteTools({ apiKey: process.env.ROUTE_TOOLS_API_KEY! });
const { text } = await generateText({ model: 'anthropic/claude-fable-5', prompt: 'What changed in the latest Cloudflare Workers release?', stopWhen: stepCountIs(5), tools: { webSearch: tool({ description: 'Search the web for current information.', inputSchema: z.object({ query: z.string() }), execute: async ({ query }) => (await rt.search({ query })).result, }), readPage: tool({ description: 'Fetch a URL and return its content as markdown.', inputSchema: z.object({ url: z.string().url() }), execute: async ({ url }) => (await rt.scrape({ url })).result, }), },});LangChain (Python)
Section titled “LangChain (Python)”from langchain_core.tools import toolfrom route_tools import RouteTools
rt = RouteTools(api_key=os.environ["ROUTE_TOOLS_API_KEY"])
@tooldef web_search(query: str) -> str: """Search the web for current information.""" res = rt.search(query=query) return "\n".join(f"{r['title']} — {r['url']}\n{r['snippet']}" for r in res["result"]["results"])
@tooldef read_page(url: str) -> str: """Fetch a URL and return its content as markdown.""" return rt.scrape(url=url)["result"]["content"]
agent = create_react_agent(model, tools=[web_search, read_page])MCP clients (Claude, Cursor, anything)
Section titled “MCP clients (Claude, Cursor, anything)”Skip the glue code entirely — connect to the hosted MCP server and get all five tools:
{ "mcpServers": { "route-tools": { "url": "https://api.route.tools/mcp", "headers": { "Authorization": "Bearer rt_live_..." } } }}See MCP setup for per-client instructions.
OpenAI-style function calling
Section titled “OpenAI-style function calling”Use the OpenAPI spec to generate function
definitions, or hand-write them — the request schemas are small and stable. Execute the
call with a plain fetch/requests POST to /v1/tools/{category}.