Integrations
AI SDK Adapter
Capture AI SDK v6 generate and stream calls with language-model middleware, extract tool proposals, and wrap tool execute handlers.
@isplay/adapter-ai-sdk provides middleware and tool wrappers for common AI SDK shapes.
Install for AI SDK
npm install isplay @isplay/sdk @isplay/adapter-ai-sdk aiInitialize the SDK in the process before model calls:
import { init } from "@isplay/sdk";
const client = init({
projectId: process.env.ISPLAY_PROJECT_ID!,
baseUrl: process.env.ISPLAY_API_URL,
});Exports
| Export | Purpose |
|---|---|
createIsplayMiddleware(options) | Returns typed AI SDK v6 LanguageModelMiddleware. Requires client or projectId. |
wrapIsplayModel(model, options) | Wraps a v6 language model with isplay middleware using wrapLanguageModel. |
instrumentTools(tools, options) | Wraps AI SDK execute handlers. Requires client or projectId. |
recordToolProposals(client, modelCallId, result) | Extracts tool calls from provider result and records proposals. |
extractToolCalls(value) | Finds common tool-call shapes recursively. |
extractLogprobSignals(value) | Pulls logprob-like provider metadata. |
inferProvider(model) | Infers provider metadata from model object when possible. |
inferModel(model) | Infers model name from model object when possible. |
Middleware
import { createIsplayMiddleware, wrapIsplayModel } from "@isplay/adapter-ai-sdk";
const isplayMiddleware = createIsplayMiddleware({
client,
provider: "openai",
model: "gpt-5.4-mini",
});
const model = wrapIsplayModel(yourModel, { client });The middleware:
- Starts a model call with provider, model, operation, params, and settings.
- Calls
doGenerate()ordoStream(). - Records tool proposals extracted from the result or stream chunks.
- Finishes the model call with output, usage, logprobs, or error.
Drain streams
For wrapStream, the model call finishes when the transformed stream flushes. If your application does not consume the stream, capture remains incomplete.
Tool Instrumentation
import { instrumentTools } from "@isplay/adapter-ai-sdk";
const tools = instrumentTools(
{
lookupClaim: {
description: "Read claim details.",
inputSchema,
__isplaySideEffectClass: "read",
__isplaySchemaVersion: "1",
__isplayImplementationVersion: "2026-05-24",
async execute(args) {
return lookupClaim(args.claimId);
},
},
},
{ client }
);instrumentTools() preserves non-executable tool entries. For tools with execute, it wraps execution with adapter-kit wrapTool().
Captured Evidence
| Evidence | Source |
|---|---|
| Model provider/model | Adapter options or inference from model object. |
| Operation | generate for wrapGenerate, stream for wrapStream. |
| Request params | AI SDK middleware params. |
| Response output | Result object, or stream result with captured chunks. |
| Usage | result.usage when present. |
| Logprobs | Extracted from result or provider metadata. |
| Tool proposals | Extracted recursively from result shapes. |
| Tool executions | Wrapped execute handlers. |
Advice
- Pass explicit provider/model options when inference is ambiguous.
- Add
__isplaySideEffectClassto every tool that can read, write, or mutate external systems. Shell/code-like names default toexternal_mutation; unknown tools remainunknown. - Capture tool schemas in context through adapter-kit if your tool definitions are not visible in request params.
- Keep AI SDK calls inside
client.withRun()or an adapter-managed run context. - Use
pause-for-fixturereplay policy for divergent tool calls; do not rerun side-effecting tools implicitly.