Skip to content

minpeter/ai-sdk-tool-call-middleware

Repository files navigation

AI SDK Tool monorepo banner

npm - parser npm downloads - parser codecov

Tooling for Vercel AI SDK: enable tool calling with models lacking native tools, plus evaluation utilities.

  • @ai-sdk-tool/parser: add tool-calling via middleware; works with any provider supported by AI SDK wrapLanguageModel.
  • @ai-sdk-tool/eval: benchmarks and evaluation helpers (BFCL, JSON generation).

Usage at a glance

import { wrapLanguageModel, streamText } from "ai";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { xmlToolMiddleware } from "@ai-sdk-tool/parser";

const client = createOpenAICompatible({
  /* baseURL, apiKey */
});

const result = streamText({
  model: wrapLanguageModel({
    model: client("your-model-name"),
    middleware: xmlToolMiddleware,
  }),
  tools: {
    /* your tools */
  },
  prompt: "Find weather for Seoul today",
});

for await (const part of result.fullStream) {
  // handle text and tool events
}

About

Vercel AI SDK and middleware for models that do not support function calls

Resources

License

Stars

Watchers

Forks

Contributors 11