AI SDK Provider
Use the BrandApp AI provider with Vercel AI SDK's generateText() and streamText() — both demonstrated live below.
Uses createBrandappProvider() with Vercel AI SDK's generateText() and streamText(). The provider exposes BrandApp-specific metadata via providerMetadata.
lib/ai-provider.ts
import { createBrandappProvider } from "@reopt-ai/brandapp-sdk/ai-provider";
import { generateText } from "ai";
// Create a Vercel AI SDK compatible provider
const brandapp = createBrandappProvider({
clientId: process.env.BRANDAPP_CLIENT_ID!,
clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
brandappId: process.env.BRANDAPP_ID!,
});
// Use with generateText()
const { text, providerMetadata } = await generateText({
model: brandapp("anthropic/claude-haiku-4.5"),
prompt: "Explain quantum computing in one sentence.",
});
console.log(text);
// Access BrandApp-specific metadata
const meta = providerMetadata?.brandapp;
console.log("Credit cost:", meta?.creditCost);
console.log("Remaining:", meta?.creditsRemaining);