> ## Documentation Index
> Fetch the complete documentation index at: https://jigsaw-13.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> Integrate JigsawStack APIs using Vercel AI SDK to build powerful AI applications with tools and function calling

<img className="mx-auto text-black dark:text-white hidden dark:block" src="https://mintcdn.com/jigsaw-13/Yr5ohXUpCUOk0bXg/images/vercel/dark.png?fit=max&auto=format&n=Yr5ohXUpCUOk0bXg&q=85&s=b3aa2e38e334b001aae0531e2877eb81" alt="Vercel Logo" height="150" width="300" data-path="images/vercel/dark.png" />

<img className="mx-auto text-black dark:hidden" src="https://mintcdn.com/jigsaw-13/Yr5ohXUpCUOk0bXg/images/vercel/light.png?fit=max&auto=format&n=Yr5ohXUpCUOk0bXg&q=85&s=90bed1ee1691990ed8472d2afa1e11b9" alt="Vercel Logo" height="150" width="300" data-path="images/vercel/light.png" />

## Overview

JigsawStack seamlessly integrates with Vercel AI SDK, enabling you to extend your AI applications with powerful tools for web scraping, computer vision, audio processing, sentiment analysis, and more. This integration allows you to leverage JigsawStack's comprehensive API suite within Vercel's AI framework.

<Columns cols={2}>
  <Card title="JigsawStack NextJS StarterKit" icon={<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10s-4.477 10-10 10m4-14h-1.35v4H16zM9.346 9.71l6.059 7.828l1.054-.809L9.683 8H8v7.997h1.346z"/></svg>} href="https://vercel.com/templates/ai/jigsawstack-starter">
    A starter kit for building AI applications with JigsawStack and NextJS.
  </Card>

  <Card title="JigsawStack Vercel Integration" icon={<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M23 21.648H1L12 2.352z"/></svg>} href="https://vercel.com/marketplace/jigsawstack">
    A fast and easy way to integrate JigsawStack with Vercel.
  </Card>
</Columns>

## Prerequisites

Before you begin, ensure you have:

* A [JigsawStack account](https://jigsawstack.com/dashboard) with an active subscription
* Your [JigsawStack API key](https://jigsawstack.com/dashboard)
* Node.js (version 18.10.0 or higher)
* A project with Vercel AI SDK configured
* An AI provider (OpenAI, Anthropic, etc.) set up with Vercel AI SDK

## Installation

Install the required packages:

```bash npm theme={null}
npm install jigsawstack ai @ai-sdk/openai
```

```bash yarn theme={null}
yarn add jigsawstack ai @ai-sdk/openai
```

## Access JigsawStack APIs through Vercel's AI SDK

You can pass JigsawStack into Vercel AI. This allows you to extend the functionality of Vercel AI by bringing any of your JigsawStack tools into your apps.

To use JigsawStack with Vercel AI, simply instantiate the JigsawStack SDK by specifying Vercel AI as your provider:

```javascript theme={null}
import { JigsawStackToolSet } from 'jigsawstack';

const toolset = new JigsawStackToolSet({
  apiKey,
});

const allTools = await toolset.getTools();
```

This configures JigsawStack to return tools that can be used into your AI functions. From there, simply pass your tools into `generateText` or `streamText`. You can use any LLM supported by Vercel.

## Complete Example

Here is a simple example using all the tools available with JigsawStack

```javascript theme={null}
import { JigsawStackToolSet } from 'jigsawstack';
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";

const toolset = new JigsawStackToolSet({
  apiKey,
});

const allTools = await toolset.getTools();
const result = await generateText({
  model: openai("gpt-4o-mini"),
  tools: allTools,
  prompt: "I absolutely love this new AI technology! It's revolutionary and amazing!",
});

console.log(`text: "${text}"`);
console.log("toolResults");
console.log(JSON.stringify(toolResults));

```

## Single and Specific Tools

To get single / specific tools available with JigsawStack

```javascript theme={null}
const toolset = new JigsawStackToolSet({
  apiKey,
});

const specificTools = await toolset.getTools({
  tools: ['web_search', 'vocr', 'object_detection']
});

const sentiment = await toolset.getTools({
  tools: ['sentiment']
});

```

## Available Tools

JigsawStack provides access to various tool categories:

* **General Tools**:
  * `sentiment`
  * `summary`
  * `embedding`
  * `prediction`
  * `text_to_sql`

* **Translate Tools**:
  * `translate_text`
  * `translate_image`

* **Web Tools**:
  * `web_search`
  * `ai_scrape`
  * `html_to_any`
  * `search_suggestions`

* **Vision Tools**:
  * `vocr`
  * `object_detection`

* **Audio Tools**:
  * `speech_to_text`

* **Validation Tools**:
  * `nsfw_detection`
  * `profanity_check`
  * `spell_check`
  * `spam_check`
