Search1API
Integrations

Vercel

Use Search1API with Vercel AI SDK tools or connect an authorized Search1API account through Vercel Connect.

Search1API offers two Vercel integrations: an AI SDK tools package and a Vercel Connect connector.

Choose an integration

AI SDK toolsVercel Connect
PurposeAdd search, news, and page reading to an AI SDK agentRetrieve Search1API credentials at runtime
Package@search1api/ai-sdk@vercel/connect
AuthenticationYour Search1API API key on the serverA Search1API account authorized through Connect
Where it runsCompatible server-side JavaScript runtimes, including Next.jsVercel projects linked to the connector

Choose the tools package for generateText or streamText workflows. Choose Connect to manage access to a user's Search1API account through Vercel.

AI SDK tools

Install the tools package:

npm install @search1api/ai-sdk ai zod
export SEARCH1API_API_KEY="your-api-key"

Pass search1apiTools() to your AI SDK call's tools option. It exposes search, news, and crawl; you can choose which tools to include and set search parameters in application code.

The AI SDK guide covers tool calling, streaming, configuration, and error handling. A complete Next.js example is available in the organization's repository. Configure your model provider's credentials separately from your Search1API API key.

Vercel Connect

Open Search1API on Vercel Connect to create a connector, or run these commands from your consuming project with an authenticated Vercel CLI:

npm install @vercel/connect
vercel link
vercel connect create search1api --name acme-search1api
vercel env pull

Complete the account authorization and enable the connection for the project's target environment. Request a token in server-side code:

import { getToken } from '@vercel/connect';

// Pass the signed-in user's ID from your server-side authentication.
export async function searchForUser(userId: string, query: string) {
  const token = await getToken('search1api/acme-search1api', {
    subject: { type: 'user', id: userId },
  });

  const response = await fetch('https://api.search1api.com/search', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ query, max_results: 5, crawl_results: 0 }),
  });

  if (!response.ok) throw new Error(`Search1API returned ${response.status}`);
  return response.json();
}

getToken returns a credential string. Keep it on the server and use it when calling Search1API. Replace acme-search1api with your connector's name. See the Connect quickstart for setup and the SDK reference for user authorization and token errors.

Connect manages runtime credentials. The AI SDK package provides tool schemas and execution. If you need additional API capabilities such as sitemap discovery, see the REST API reference.

Verify your setup

  • AI SDK tools: ask your agent to search for a topic and read a result. Check that it calls the expected tools and returns source URLs.
  • Connect: request a token for an authorized user from the linked project and environment. If authorization is required, complete the user's connection before retrying.

Billing

Search1API requests use the credentials' Search1API account credits. See Credits and limits. Model usage and Vercel services follow their respective providers' billing.

Resources

On this page