Skip to content
dhanu docs
Browse pages

SDKs

Vercel AI SDK provider

Use generateText and streamText from the AI SDK on Dhanu with @dhanu/ai-sdk-provider.

If your app is already written against the Vercel AI SDK, swap the provider and it runs on your Dhanu workspace’s models and credits.

npm i ai @dhanu/ai-sdk-provider
import { generateText, streamText } from "ai";
import { dhanu } from "@dhanu/ai-sdk-provider";

const { text } = await generateText({
  model: dhanu(),
  system: "You answer in Nepali and English.",
  prompt: "Explain what a Bikram Sambat date is.",
});

const result = streamText({ model: dhanu(), prompt: "Write a haiku about Kathmandu." });
for await (const chunk of result.textStream) process.stdout.write(chunk);

dhanu reads DHANU_API_KEY and DHANU_BASE_URL; createDhanu({ apiKey, baseUrl, projectId }) builds a provider explicitly. Conversation history is sent as one prompt (system messages become system), usage and cost come back in usage and providerMetadata.dhanu. Two things to know:

  • The model id is informational. Dhanu routes every call to a model itself, so dhanu() and dhanu("anything") behave the same.
  • Tools and sampling parameters are not forwarded. They come back as warnings. Give Dhanu tools by putting the work on a staff member instead.