Examples
AI SDK Example
Use AI SDK v6 language-model middleware and explicit tool instrumentation.
AI SDK v6 applies model middleware with wrapLanguageModel. isplay exposes a typed middleware plus a convenience wrapper.
import { generateText, tool } from "ai";
import { z } from "zod";
import { init } from "@isplay/sdk";
import { instrumentTools, wrapIsplayModel } from "@isplay/adapter-ai-sdk";
const client = init({
projectId: process.env.ISPLAY_PROJECT_ID!,
baseUrl: process.env.ISPLAY_API_URL,
serviceName: "ai-sdk-agent",
});
const model = wrapIsplayModel(yourModel, {
client,
provider: "openai",
model: "gpt-5.4-mini",
});
const tools = instrumentTools(
{
lookup_claim: tool({
description: "Look up claim details",
inputSchema: z.object({ claimId: z.string() }),
__isplaySideEffectClass: "read",
__isplaySchemaVersion: "1",
execute: async ({ claimId }) => ({ claimId, eligible: true }),
}),
},
{ client }
);
await client.withRun({ name: "ai-sdk-run" }, async () => {
await generateText({
model,
prompt: "Review claim C-104",
tools,
});
});Drain streamText streams so the middleware can write final model output and tool proposal records.