tdm-vercel-ai
v0.1.0
Published
Payable tool wrappers for the Vercel AI SDK powered by TDM authorization
Downloads
14
Maintainers
Readme
tdm-vercel-ai
Make Vercel AI SDK tools payable with TDM.
This package keeps the integration thin:
- define a normal
tool(...) - add the TDM payment fields
- authorize through
POST /authorize - run the original business logic only after TDM allows it
Install
npm install tdm-vercel-ai tdm-sdk ai zodWhy this package exists
tdm-sdk already contains the core payable primitives. This package gives AI
SDK users a framework-shaped entry point that feels native to their tool stack.
Example
import { z } from "zod";
import { createTdmPayableTool } from "tdm-vercel-ai";
export const summarizePremiumUrl = createTdmPayableTool({
baseUrl: process.env.TDM_GATEWAY_URL!,
apiKey: process.env.TDM_API_KEY,
description: "Summarize a premium URL after TDM authorizes payment.",
inputSchema: z.object({
url: z.string().url(),
}),
inputExamples: [
{
input: {
tokenOrUuid: "demo-user",
operation: "demo:summarize-url",
resourceId: "url_summary",
priceUsd: "0.05",
url: "https://example.com/article",
},
},
],
execute: async ({ url }) => {
return {
ok: true,
summary: `Summary for ${url}`,
};
},
});Input shape
Every tool created by createTdmPayableTool(...) includes these TDM fields:
tokenOrUuidoperationresourceId?priceUsd?
Your own schema is merged into that base shape.
Notes
- This package uses the public TDM contract behind
POST /authorize. - It does not expose private gateway or treasury internals.
- For lower-level control, use
tdm-sdk/make-payabledirectly.
License
MIT
