Skip to main content
This guide shows you how to add Snow Leopard data retrieval to a Vercel AI SDK agent.

Prerequisites

Don’t have data? Use our sample superheroes dataset to get started, or choose from our other sample datasets.

Start from scratch

Clone and run the complete working example:
git clone https://github.com/SnowLeopard-AI/snowy-examples.git
cd snowy-examples/quickstart/vercel-ai
Install dependencies:
npm install
Set your environment variables:
export OPENAI_API_KEY=your-openai-key
export SNOWLEOPARD_API_KEY=your-snowleopard-key
export SNOWLEOPARD_DATAFILE_ID=your-datafile-id
Run the example:
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

npm install @snowleopard-ai/client

2. Create the Snow Leopard tool

Create a tool that calls Snow Leopard to retrieve data:
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:
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