The Ampersand AI SDK enables AI agents to seamlessly perform operations on connected SaaS tools through Ampersand’s platform.

The Ampersand AI SDK is in alpha. It may change in non backwards-compatible ways. (Although we are very serious about semantic versioning.)

If you have any feedback, please file an issue on Github.

Installation

npm install @amp-labs/ai
# or
yarn add @amp-labs/ai
# or
pnpm add @amp-labs/ai

Usage

The SDK provides several modules that can be used depending on your framework preference:

Use with Vercel AI SDK

AI SDK by Vercel unifies LLM access in TypeScript & makes it easy to build AI agents.

This is a simple example of how to use the AI SDK tools by Ampersand in a Vercel AI agent.

import { openai } from '@ai-sdk/openai';
import { generateObject, generateText } from 'ai';
import { z } from 'zod';
import { createRecord, updateRecord } from "@amp-labs/ai/aisdk";

// Vercel Agent with AI SDK tools by Ampersand
async function handleCustomerQuery(query: string) {
  const model = openai('gpt-4o');

  const { text: response } = await generateText({
    model:
      classification.complexity === 'simple'
        ? openai('gpt-4o-mini')
        : openai('o3-mini'),
    system: '... your system prompt here',
    prompt: query,
    tools: {
      // AI SDK tools by Ampersand being used here
      createRecord,
      updateRecord,
    },
  });

  return { response };
}

Use with Mastra

Mastra is a Typescript toolkit that offers agent workflows and eval tools so teams can turn prototypes into production-ready AI agents.

This is a simple example of how to use the AI SDK tools by Ampersand in an agent built with Mastra.

import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
import { createRecord, updateRecord } from "@amp-labs/ai/mastra";

// Mastra Agent with Mastra tools
export const mastraToolsAgent: Agent = new Agent({
  name: "Mastra Tools Agent",
  instructions: "You can use tools defined in Mastra.",
  model: openai("gpt-4o-mini"),
  tools: {
    createRecord,
    updateRecord,
  },
});

Available Tools

The SDK provides the following tools for interacting with SaaS platforms:

ToolDescriptionPurpose
createRecordCreates a new record in the connected SaaS platformCreate new records like contacts, deals, tickets etc.
updateRecordUpdates an existing record in the connected SaaS platformModify existing records with new data
sendReadRequestMakes authenticated GET API calls to the provider through AmpersandReading and searching records
sendRequestMakes authenticated API calls to the provider through AmpersandDo any action that is available via the API
checkConnectionVerifies if there is an active connection to the SaaS providerValidate connection status before creating an installation
createInstallationCreates a new installation for a providerCreate an installation for an existing connection
checkInstallationChecks if there is an active installation for a providerVerify installation status
startOAuthReturns URL for initiating OAuth flow for connecting to a providerAuthenticates a new user

Have a tool in mind that we could add? Let us know on Discord!