> ## Documentation Index
> Fetch the complete documentation index at: https://docs.snowleopard.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel

> Integrate Snow Leopard with Vercel AI SDK for natural language data queries.

This guide shows you how to add Snow Leopard data retrieval to a [Vercel](https://vercel.com/) [AI SDK](https://sdk.vercel.ai/) agent.

## Prerequisites

* Node.js v18+
* OpenAI API key (or another [supported model provider](https://sdk.vercel.ai/providers/ai-sdk-providers))
* [Snow Leopard API key](https://auth.snowleopard.ai/account/api_keys)
* A datafile uploaded to [Snow Leopard Playground](https://try.snowleopard.ai)

<Note>
  Don't have data? Use our [sample superheroes dataset](https://github.com/SnowLeopard-AI/playground_datasets/raw/refs/heads/main/superheroes.db) to get started, or choose from our other [sample datasets](https://github.com/SnowLeopard-AI/playground_datasets/).
</Note>

## Start from scratch

Clone and run the [complete working example](https://github.com/SnowLeopard-AI/snowy-examples/tree/main/quickstart/vercel-ai):

```bash theme={null}
git clone https://github.com/SnowLeopard-AI/snowy-examples.git
cd snowy-examples/quickstart/vercel-ai
```

Install dependencies:

```bash theme={null}
npm install
```

Set your environment variables:

```bash theme={null}
export OPENAI_API_KEY=your-openai-key
export SNOWLEOPARD_API_KEY=your-snowleopard-key
export SNOWLEOPARD_DATAFILE_ID=your-datafile-id
```

Run the example:

```bash theme={null}
npm run snowy
```

You now have an interactive REPL where you can ask questions about your data.

## Bring your own agent

Already have a Vercel AI agent? Add Snow Leopard data retrieval with these steps.

### 1. Install dependencies

```bash theme={null}
npm install @snowleopard-ai/client
```

### 2. Create the Snow Leopard tool

Create a tool that calls Snow Leopard to retrieve data:

```javascript theme={null}
const { tool } = require('ai');
const { z } = require('zod');
const { SnowLeopardClient } = require('@snowleopard-ai/client');

const snowy = new SnowLeopardClient({ apiKey: '{your-snowleopard-api-key}' });

const getData = tool({
  description: 'Retrieve data from the database. ' +
               'Describe your data here - this becomes part of the tool description.',
  inputSchema: z.object({
    userQuestion: z.string().describe('the natural language query to answer'),
  }),
  execute: async ({ userQuestion }) => {
    return await snowy.retrieve({
      userQuery: userQuestion,
      datafileId: '{your-datafile-id}'
    });
  }
});
```

### 3. Customize the tool description

The tool's description tells the agent when and how to use it. Update it to describe your specific data:

```javascript theme={null}
const getData = tool({
  description: 'Retrieve customer order data. ' +
               'Contains order history, products, and customer information. ' +
               'Use this to answer questions about sales, orders, and customers.',
  // ...
});
```

## Next steps

* View the [full example on GitHub](https://github.com/SnowLeopard-AI/snowy-examples/tree/main/quickstart/vercel-ai)
* See our full [API documentation](https://docs.snowleopard.ai/) to learn about the [Retrieve](/playground/endpoints/retrieve) and [Response](/playground/endpoints/response) endpoints
* Explore [Recipes](/recipes) for production-ready agent examples
