The Vercel AI SDK powers AI-enabled Next.js apps with streaming, tool calling, and multi-model support. Jarvis SDK adds 700+ executable tools that your AI SDK agents can call server-side — perfect for building production AI features.
npm install ai @ai-sdk/openai
Sign up at jarvissdk.com and create an API key.
Create Zod-typed tool definitions that call Jarvis SDK.
Pass tools to streamText() or generateText() in your API route.
Copy this into your project to get started immediately.
// app/api/chat/route.ts
import { streamText, tool } from "ai";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";
const JARVIS_API_KEY = process.env.JARVIS_API_KEY!;
async function callJarvis(module: string, action: string, params: Record<string, unknown> = {}) {
const res = await fetch(`https://jarvissdk.com/api/v1/modules/${module}/execute`, {
method: "POST",
headers: { "x-api-key": JARVIS_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ action, params }),
});
const data = await res.json();
return data.result ?? data;
}
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: openai("gpt-4o"),
messages,
tools: {
executeModule: tool({
description: "Execute a Jarvis SDK module (700+ tools available)",
parameters: z.object({
module: z.string().describe("Module name (e.g., text-toolkit, hash-toolkit)"),
action: z.string().describe("Action name (e.g., summarize, sha256)"),
params: z.record(z.unknown()).optional().describe("Action parameters"),
}),
execute: async ({ module, action, params }) => {
return callJarvis(module, action, params ?? {});
},
}),
searchTools: tool({
description: "Search the Jarvis SDK marketplace for tools",
parameters: z.object({
query: z.string().describe("Search query"),
}),
execute: async ({ query }) => {
const res = await fetch(
`https://jarvissdk.com/api/v1/catalog/search?q=${encodeURIComponent(query)}`,
{ headers: { "x-api-key": JARVIS_API_KEY } },
);
return res.json();
},
}),
},
});
return result.toDataStreamResponse();
}Jarvis SDK tool results stream seamlessly through the AI SDK's data stream protocol — no buffering or special handling.
Define tool parameters with Zod schemas. The AI SDK validates inputs before they reach Jarvis SDK.
Tools run on your server in Next.js API routes — your API key stays safe, and you get server-side caching.
Works with any model provider the AI SDK supports: OpenAI, Anthropic, Google, Mistral, and more.
Yes. The tools defined in your route handler work with the AI SDK's useChat() hook on the frontend. Tool results stream back to the client automatically.
Yes. Set maxSteps in streamText() and the model can chain multiple Jarvis SDK tool calls together.
Yes. Add Next.js cache headers or use unstable_cache() around your callJarvis function for deterministic tools like hashing or encoding.
Free tier includes 1,000 executions/month. No credit card required.