# apifare for Vercel AI SDK One prepaid, capped key for every API your agent needs, under hard caps and a kill switch. 1. Get a token: https://apifare.com/start?origin=page:integrations-vercel-ai-sdk (shown once). 2. Connect with createMCPClient from @ai-sdk/mcp (not the older experimental_createMCPClient from ai) and pass its tools to generateText. The token is read from the APIPAY_TOKEN environment variable and sent as an Authorization header. ``` npm i @ai-sdk/mcp ai zod ``` ``` import { createMCPClient } from '@ai-sdk/mcp'; import { generateText, isStepCount } from 'ai'; const mcpClient = await createMCPClient({ transport: { type: 'http', url: 'https://apifare.com/mcp', headers: { Authorization: `Bearer ${process.env.APIPAY_TOKEN}` }, }, }); try { const tools = await mcpClient.tools(); const { text } = await generateText({ model: 'openai/gpt-5.4', tools, stopWhen: isStepCount(10), prompt: "What's the weather in London?", }); console.log(text); } finally { await mcpClient.close(); } ``` Set APIPAY_TOKEN, then run it as an ES module (for the top-level await). The finally block closes the client, as the AI SDK docs ask. 3. Try it: "search the web for X", then "fetch a URL", then "what's the weather in London". 4. Caps and the kill switch are checked before dispatch. An empty balance returns HTTP 402 with a top-up link (see /errors.md). Prices: https://apifare.com/capabilities. Config checked against https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools on 2026-09-13.