Quickstart

AI SDK by Vercel

Use Bluebag in your AI SDK powered agent

Bluebag ships native support for the AI SDK. Here's how to get started:

1. Install dependencies

npm install @bluebag/ai-sdk

2. Initialise with API Key

Set BLUEBAG_API_KEY in your environment (see API Keys).

Then initialise Bluebag:

import { Bluebag } from "@bluebag/ai-sdk";

const bluebag = new Bluebag({
  apiKey: process.env.BLUEBAG_API_KEY!,
});

3. Use in your app

In your ai-sdk method calls, use bluebag as shown below:

// streamText
import { streamText } from "ai";

const config = await bluebag.enhance({
  // pass streamText options here
  model: "",
  messages: [],
});

const result = streamText(config);

The same signature works for other ai-sdk methods such as generateText or generateObject

import { generateText } from "ai";

const config = await bluebag.enhance({
  // pass generateText options here
  model: "",
  messages: [],
});

const result = generateText(config);

All ai-sdk methods supported

Every ai-sdk method that accepts messages and tools works with the bluebag.enhance method.

4. Configure session options

Use activeSkills to scope which Skills can run, and stableId to keep per-user session context across calls:

const bluebag = new Bluebag({
  apiKey: process.env.BLUEBAG_API_KEY!,
  activeSkills: ["pdf-processing"],
  stableId: "user-123",
});

const config = await bluebag.enhance({
  model: anthropic("claude-3-5-sonnet-20241022"),
  messages,
});

On this page