tensormesh(modelId), the request is sent to /v1/chat/completions and the AI SDK parses the response against your schema.
extractJsonMiddleware() when a model may wrap JSON in Markdown code fences.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Generate schema-backed JSON with the Tensormesh AI SDK provider.
tensormesh(modelId), the request is sent to /v1/chat/completions and the AI SDK parses the response against your schema.
import {
extractJsonMiddleware,
Output,
streamText,
wrapLanguageModel,
} from "ai";
import { tensormesh } from "@tensormesh/ai-sdk-provider";
import { z } from "zod";
const launchPlanSchema = z.object({
title: z.string(),
audience: z.string(),
summary: z.string(),
integrationSteps: z.array(
z.object({
step: z.string(),
detail: z.string(),
}),
),
successSignals: z.array(z.string()),
});
const result = streamText({
model: wrapLanguageModel({
model: tensormesh("deepseek-ai/DeepSeek-V4-Flash"),
middleware: extractJsonMiddleware(),
}),
prompt:
"Create a launch plan for a TypeScript team adopting Tensormesh serverless inference. Return only the JSON object.",
output: Output.object({
schema: launchPlanSchema,
}),
});
for await (const partialObject of result.partialOutputStream) {
console.log(partialObject);
}
extractJsonMiddleware() when a model may wrap JSON in Markdown code fences.