# Use SimilarIQ with Vercel AI SDK

> SimilarIQ has no dedicated Vercel AI SDK provider or package. You connect it with the SDK's MCP client: call createMCPClient from @ai-sdk/mcp with an HTTP transport, the URL https://similariq.ai/mcp and an X-API-Key header, then pass await mcpClient.tools() to your model call. Each search returns up to 100 look-alike companies for $0.25.

Source: https://similariq.ai/integrations/vercel-ai-sdk · Updated 2026-11-25

## What the Vercel AI SDK is and how it loads MCP tools

The AI SDK is Vercel's TypeScript toolkit for building applications on language models. It gives you one interface for generating and streaming text across model providers, and a way to hand the model tools it can call. It is used in web backends, route handlers and scripts.

The SDK's documentation describes an MCP client in a package named `@ai-sdk/mcp`. You call `createMCPClient` with a transport configuration, and the client fetches tool definitions from the server. The docs recommend the HTTP transport for production and reserve stdio for local servers. The transport object takes `type: 'http'`, a `url`, optional `headers`, and an optional `authProvider` for OAuth.

SimilarIQ ships no AI SDK-specific package. It runs a hosted [MCP server](https://similariq.ai/features/mcp-server) at `https://similariq.ai/mcp` that speaks streamable HTTP and needs nothing installed, which fits the HTTP transport the SDK recommends. A Node SDK and a REST API are available for the non-MCP route.

## Why add look-alike search to an AI SDK app

Products built on the AI SDK tend to be chat or assistant features inside a larger application: a sales copilot, a research panel, an onboarding helper. Users of those features ask who a company competes with or which accounts resemble their customers. A model alone answers from memory with a short list and no way to rank it.

With the SimilarIQ tools attached, the model can call `find_similar_companies` and get up to 100 ranked companies. Each result has `rank`, `company`, `domain`, `matchScore`, a relationship `type` of Direct, Indirect, Adjacent or Emerging, `confidence` and `likelyCompetitor`. Your interface can render that as a table instead of a paragraph.

This is also a route to shipping a feature of your own. If you want a similar-companies panel in your product, the tool call gives you the data and your code controls the display. The [guide to building a similar companies feature](https://similariq.ai/guides/how-to-build-a-similar-companies-feature) covers the product decisions.

## Setup walkthrough: the MCP client

Add `@ai-sdk/mcp` to your project next to the AI SDK itself and your model provider package. Create a SimilarIQ API key in the app; it starts with `sk-live-` and is shown once. Store it in a server-side environment variable such as `SIMILARIQ_API_KEY`.

Create the client following the shape in the SDK docs: `const mcpClient = await createMCPClient({ transport: { type: 'http', url: 'https://similariq.ai/mcp', headers: { 'X-API-Key': process.env.SIMILARIQ_API_KEY } } })`, with `createMCPClient` imported from `@ai-sdk/mcp`. The docs' own example sends a bearer token in `headers`; SimilarIQ's server accepts its key in the `X-API-Key` header.

Fetch the tools with `const tools = await mcpClient.tools()` and pass `tools` to your text generation or streaming call along with the model and prompt. The docs call this schema discovery: every tool the server offers is loaded, and input types are inferred from the server's schemas. You get all ten SimilarIQ tools without writing a definition.

## Typed schemas, closing the client, and timeouts

The docs describe a second mode, schema definition. Pass a `schemas` object to `mcpClient.tools()` with a Zod `inputSchema` for each tool you want. You gain compile-time types, and the docs state that only the tools you list are pulled. For SimilarIQ that doubles as a permission control: list `find_similar_companies` with `z.object({ domain: z.string() })` and the model cannot start a bulk job. Check the tool's published input schema before fixing your own, since this page does not reproduce it.

Close the client when you are done. The docs show `await mcpClient.close()` and say to call it when a streamed response ends, or in a `finally` block for a non-streaming call. An unclosed client holds a connection open for the life of the process.

On timing: a SimilarIQ search takes roughly 30 to 60 seconds. The SDK's MCP page documents no connection or tool-call timeout for `createMCPClient`, so this page cannot quote a default. The limit you are more likely to meet is your hosting platform's maximum duration for a server function, which this page did not verify. Check it, and stream the response so the user sees progress while the tool runs.

## The REST and Node SDK alternative

You do not need MCP to give a model one tool. Define a tool in the AI SDK whose handler calls SimilarIQ directly. The request is `POST https://similariq.ai/api/v1/search` with the body `{"domain":"stripe.com","limit":100}` and the header `X-API-Key: sk-live-...`. The response is the full ranked list, synchronously.

The Node SDK removes the fetch boilerplate. Install it with `npm install similariq-sdk`. It needs Node 18 or later, has zero dependencies and ships TypeScript types. Its methods include `search`, `results`, `history`, `balance`, `bulk` and `bulkWait`. The [Node.js guide](https://similariq.ai/find-competitors-with-node-js) has a complete example. This page does not name the AI SDK's tool-definition helper, since only the MCP page was verified for this write-up.

Choose by scope. MCP gives the model history, bulk jobs, the watchlist and share links with no extra code. A hand-written tool gives you one capability and full control over its arguments and output shape.

## Example prompts

Once the tools are attached, users can type requests like these. The tool names are the ones the SimilarIQ server exposes.

- How many searches do I have left? Calls `get_search_balance`, free.
- Who are the closest competitors to figma.com? Calls `find_similar_companies`, one credit.
- Show only the Emerging ones from that list. Answered from the result already in context, no new call.
- Did we look this company up last week? Calls `list_recent_searches`.
- Open that earlier search again. Calls `get_search_results`, free and immediate.
- Save the first three to my watchlist. Calls `save_company`.
- Give me a link I can paste into a deck. Calls `create_share_link`.
- Run all of these domains overnight. Calls `start_bulk_search`, one credit per domain.

## Controlling spend in a user-facing app

A user-facing app changes the spending question, because the people triggering searches are your users and the balance is yours. One search is one credit, $0.25. If 50 users each trigger four searches a month, that is 200 searches and $50. Decide whether that is a cost of your feature or something to meter, and enforce it in your own code before the model is allowed to call the tool.

Cache on your side as well as SimilarIQ's. Re-reading a past search through `get_search_results` is free, so store the `searchId` against the domain in your database and reuse it. Instruct the model to check `list_recent_searches` before searching. Use schema definition to withhold `start_bulk_search` from chat surfaces where a single message could queue hundreds of domains.

The SDK docs mention a `maxRetries` setting that applies to tool calls made through the MCP client. A search that fails on SimilarIQ's side is refunded, but a retry sent after a client-side timeout can pay for a second search, so keep retries low for a paid tool. In SimilarIQ, the monthly cap is a hard ceiling on card charges; see [spend controls](https://similariq.ai/features/spend-controls).

## Two features to build

**Sales copilot panel.** A rep opens an account page in your CRM-adjacent app and asks for similar companies. The route handler creates the MCP client, streams a response, and the model calls `find_similar_companies` with the account's domain. Your UI renders the tool result as a sortable table with score and type columns. The rep saves a few with `save_company`. SimilarIQ returns companies and scores only; contact details and headcount must come from the systems you already use. See [sales agent workflows](https://similariq.ai/use-cases/sales-agent-workflows).

**Internal market-map generator.** A script, not a chat, takes five seed domains and calls the model with the bulk tools enabled. The model starts one bulk job, polls `get_bulk_job`, reads the results and writes a grouped summary by relationship type. The script closes the client in a `finally` block. Five domains cost $1.25. Because results persist in history, re-running the summary with a different prompt costs nothing.

## Troubleshooting and security

If `mcpClient.tools()` returns nothing or throws, confirm the transport `type` is `'http'`, the URL is exactly `https://similariq.ai/mcp`, and the header key is `X-API-Key`. A 401 means the key is missing or revoked. A 402 means the balance is empty. A 429 means the rate limiter is smoothing a burst. A 502 means the search failed and the credit was refunded, so a retry is safe. A request that dies with no status near a round number of seconds is usually your host's function limit.

Create the MCP client only in server code. A key placed in client-side code is visible to every visitor. Use one key per environment and revoke from the SimilarIQ app if one leaks. Company names in results come from the open web; render them as text, escape them in HTML, and do not let tool output alter the system prompt.

## Frequently asked questions

### Is there an official SimilarIQ package for the Vercel AI SDK?

No. SimilarIQ has no AI SDK provider, plugin or marketplace listing. You connect through the SDK's own MCP client pointed at the hosted SimilarIQ MCP server, or by writing a tool that calls the REST API or the Node SDK.

### Which function creates an MCP client in the AI SDK?

The SDK docs use `createMCPClient`, imported from `@ai-sdk/mcp`, with a transport object of `type: 'http'`, a `url` and optional `headers`. Calling `tools()` on the client returns tools you pass to a model call.

### Can I use OAuth instead of an API key?

The SDK's HTTP transport documents an optional `authProvider` for OAuth, and SimilarIQ's server supports OAuth 2.1. For a backend service, the `X-API-Key` header is simpler because no user sign-in step is involved.

### Will a 30 to 60 second search time out?

The SDK's MCP page states no timeout for the client, so there is no documented default to quote. Check your hosting platform's function duration limit, which is the more common cause, and stream the response.

### How do I limit which SimilarIQ tools the model can call?

Pass a `schemas` object to `tools()` naming only the tools you want. The SDK docs state that in this mode only the listed tools are pulled from the server.

### What does each tool call cost?

`find_similar_companies` costs one credit, $0.25, and `start_bulk_search` costs one credit per domain. The other eight tools, including balance, history and share links, are free.
