Documentation Index
Fetch the complete documentation index at: https://docs.stellartools.dev/llms.txt
Use this file to discover all available pages before exploring further.
The @stellartools/aisdk-adapter package wraps Vercel AI SDK functions with metered billing. Each call checks the customer’s credit balance, runs the model, and charges by token usage.
Install
npm install @stellartools/aisdk-adapter ai
Usage
The adapter exports generateText, generateObject, streamText, and streamObject directly. Pass your StellarTools config alongside the usual AI SDK options.
import { generateText } from "@stellartools/aisdk-adapter";
import { openai } from "@ai-sdk/openai";
const response = await generateText({
api_key: process.env.STELLAR_TOOLS_API_KEY!,
product_id: "prod_llm_ai",
customer_id: "cust_xxx",
model: openai("gpt-4o"),
prompt: "Write a haiku about Stellar",
});
console.log(response.text);
Streaming:
import { streamText } from "@stellartools/aisdk-adapter";
import { openai } from "@ai-sdk/openai";
await streamText({
api_key: process.env.STELLAR_TOOLS_API_KEY!,
product_id: "prod_llm_ai",
customer_id: "cust_xxx",
model: openai("gpt-4o"),
messages: [{ role: "user", content: "Hello" }],
});
The preflight check runs before the model call. If the customer does not have enough credits, the adapter throws before any tokens are used.
Options
Your StellarTools API key.
The credit product ID to charge for usage.
The StellarTools customer ID to bill.