DEVUP Docs
Back to Dashboard

Integrations

Vercel AI SDK

Connect DEVUP AI to the Vercel AI SDK using the official devupai/ai provider. Build generative AI applications in Next.js and Node.js with text generation, streaming, tool calling, and streaming route handlers.

Prerequisites

Installation

Install the DEVUP AI SDK, the Vercel AI SDK core library, the OpenAI-compatible adapter, and Zod:

npm install devupai ai @ai-sdk/openai-compatible zod

Create the provider

Initialize the provider instance by importing createDevupAI from devupai/ai:

import { createDevupAI } from "devupai/ai";

const devupai = createDevupAI({
  apiKey: process.env.DEVUP_API_KEY,
});

generateText

Generate non-streaming text completions using generateText:

import { createDevupAI } from "devupai/ai";
import { generateText } from "ai";

const devupai = createDevupAI({
  apiKey: process.env.DEVUP_API_KEY,
});

const { text } = await generateText({
  model: devupai("deepseek-ai/DeepSeek-V4-Pro"),
  prompt: "Say hello in one word.",
});

console.log(text.trim());

streamText

Stream tokens in real time using streamText and iterate over textStream:

import { createDevupAI } from "devupai/ai";
import { streamText } from "ai";

const devupai = createDevupAI({
  apiKey: process.env.DEVUP_API_KEY,
});

const result = streamText({
  model: devupai("deepseek-ai/DeepSeek-V4-Pro"),
  prompt: "Count from 1 to 3.",
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}
console.log();

Tool calling

Define typed tools with Zod schemas and resolve responses across multi-step execution rounds:

import { createDevupAI } from "devupai/ai";
import { generateText, tool, stepCountIs } from "ai";
import { z } from "zod";

const devupai = createDevupAI({
  apiKey: process.env.DEVUP_API_KEY,
});

const getWeather = tool({
  description: "Get the current weather for a city",
  inputSchema: z.object({
    city: z.string().describe("The name of the city"),
  }),
  execute: async ({ city }) => {
    return { city, temperature: "22C" };
  },
});

const result = await generateText({
  model: devupai("deepseek-ai/DeepSeek-V4-Pro"),
  prompt: "What is the weather in Algiers? Use the get_weather tool.",
  tools: { get_weather: getWeather },
  stopWhen: stepCountIs(2),
});

console.log("Tool called:", result.toolCalls[0].toolName);
console.log("Final text:", result.text.trim());

Next.js route handler

Return a streaming HTTP response from an App Router API route handler using toTextStreamResponse:

import { createDevupAI } from "devupai/ai";
import { streamText } from "ai";

const devupai = createDevupAI({
  apiKey: process.env.DEVUP_API_KEY,
});

export async function POST(req: Request) {
  const { prompt } = await req.json();

  const result = streamText({
    model: devupai("deepseek-ai/DeepSeek-V4-Pro"),
    prompt,
  });

  return result.toTextStreamResponse();
}