Docs
Integrate Interlify with Vercel AI SDK - TypeScript

Integrate Interlify with Vercel AI SDK - TypeScript

A quick example of using Interlify with Vercel AI.

Vercel AI SDK is the TypeScript toolkit designed to help developers build AI-powered applications and agents with React, Next.js, Vue, Svelte, Node.js, and more.

Interlify now support Vercel AI for tools calling. You can easily integrate interlify in your Next.js project with Vercel AI.

To start, install Vercel AI, Vercel AI Groq client, dotenv, and interlify.

npm install @ai-sdk/groq ai dotenv interlify

Then create a .env file set these variables:

API_KEY = <YOUR_GROQ_API_KEY> INTERLIFY_API_KEY = <INTERLIFY_API_KEY> PROJECT_ID = <INTERLIFY_PROJECT_ID> ACCESS_TOKEN = <YOUR_API_ACCESS_TOKEN>

The code is as simple as below:

  import { Interlify } from "Interlify"; import { config } from 'dotenv'; import { createGroq } from '@ai-sdk/groq'; import { generateText, ToolSet } from 'ai';   config();   const client = createGroq({ apiKey: process.env.API_KEY });   const MODEL = client('llama-3.3-70b-versatile');   // Init the client const interlify = new Interlify({  apiKey: process.env.INTERLIFY_API_KEY || "",  projectId: process.env.PROJECT_ID || "",  authHeaders: [  { Authorization: `Bearer ${process.env.ACCESS_TOKEN}` }  ] });   // Get tools for Vercel AI const tools = await interlify.aiTools() as ToolSet;   const history = [  {   role: "system",   content: "You are online shoes shop customer service. You help customer on equries."  },{   role: "user",   content: "what shoes do you have?"  }]   const { text, toolResults } = await generateText({  model: MODEL,  // Pass tools to LLM  tools: tools,  messages: history });   console.log("text: ", text); console.log("toolResults: ", JSON.stringify(toolResults));  

That's it!

GL & HF!

For the complete code, please check our GitHub repo: https://github.com/Interlify/interlify-client-examples/blob/main/TypeScript/vercal-ai-interlify-example.ts.

Currently, Interlify works for OpenAI compatible client/models, such as OpenAI, DeepSeek, Groq Client, etc.

If you have any questions, ideas, requests, or feedback, we highly recommend visiting our Build Together page to share them with us. We are eager to hear from you!