npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@unirate/ai-sdk

v0.1.0

Published

Vercel AI SDK tools for the UniRate currency-exchange API. Drop-in tool() definitions for exchange, rate, currencies, and VAT — plus the UniRateAPIWrapper client. Zero runtime deps; ai + zod are peers.

Readme

@unirate/ai-sdk

Vercel AI SDK tools for the UniRate currency-exchange API.

Drop four ready-made tool() definitions into any AI SDK agent so your model can convert currencies, look up exchange rates, list supported currencies, and fetch VAT rates. Mirrors the @unirate/langchain-js package.

UniRate API · 593+ fiat, crypto & commodity instruments · Free tier available

Installation

npm install @unirate/ai-sdk ai zod

ai and zod are peer dependencies — install them alongside this package. Compatible with AI SDK v4 and v5 (each tool ships both the v4 parameters and v5 inputSchema field).

Quick start

import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { createUniRateTools } from "@unirate/ai-sdk";

const tools = createUniRateTools({ apiKey: process.env.UNIRATE_API_KEY });

const { text } = await generateText({
  model: openai("gpt-4o"),
  tools,
  maxSteps: 5,
  prompt: "Convert 250 USD to JPY, then tell me Germany's VAT rate.",
});

console.log(text);

createUniRateTools() returns a record keyed by tool name — exactly the shape the AI SDK's generateText / streamText expect for their tools option.

Tools

createUniRateTools() returns:

| Key | Purpose | Input | |---|---|---| | unirate_exchange | Convert an amount between two currencies | from_currency, to_currency, amount? | | unirate_rate | Current rate for a pair, or all rates from a base | from_currency, to_currency? | | unirate_currencies | List all supported currency codes | — | | unirate_vat | VAT rate for a country, or all countries | country? |

Each tool is also available as an individual factory:

import {
  createExchangeTool,
  createRateTool,
  createCurrenciesTool,
  createVatTool,
} from "@unirate/ai-sdk";

const tools = {
  fx: createExchangeTool({ apiKey: process.env.UNIRATE_API_KEY }),
  vat: createVatTool({ apiKey: process.env.UNIRATE_API_KEY }),
};

unirate_exchange

// model input: { from_currency: "USD", to_currency: "EUR", amount: 100 }
// tool output: "100 USD = 92.5 EUR (UniRate latest rate)"

unirate_rate

// { from_currency: "USD", to_currency: "EUR" }
// → "1 USD = 0.925 EUR (UniRate latest rate)"

// { from_currency: "USD" }  (omit target)
// → "Rates from USD (first 10): EUR: 0.925, GBP: 0.79, ..."

unirate_currencies

// {}
// → "UniRate supports 593 currencies: USD, EUR, GBP, ..."

unirate_vat

// { country: "DE" }
// → "Germany (DE) VAT rate: 19%"

// {}  (omit country)
// → "VAT rates for 50 countries (first 10): AT: 20%, BE: 21%, ..."

UniRateAPIWrapper

The wrapper class is exported for use outside an agent context (or to share one client instance across tools):

import { UniRateAPIWrapper, createUniRateTools } from "@unirate/ai-sdk";

const wrapper = new UniRateAPIWrapper(); // reads UNIRATE_API_KEY from env
const tools = createUniRateTools(wrapper); // shares the wrapper

console.log(await wrapper.getRate("USD", "EUR")); // 0.925
console.log(await wrapper.convert("USD", "EUR", 100)); // 92.5
console.log(await wrapper.listCurrencies()); // ["USD", "EUR", ...]
console.log(await wrapper.getVatRate("DE")); // { country_code: "DE", country_name: "Germany", vat_rate: 19 }

Errors

All errors extend UniRateError:

| HTTP | Class | Meaning | |---|---|---| | 400 | InvalidRequestError | Bad parameters | | 401 | AuthenticationError | Missing/invalid API key | | 403 | ProRequiredError | Endpoint requires a Pro subscription | | 404 | InvalidCurrencyError | Unknown currency | | 429 | RateLimitError | Rate limit exceeded | | 503 / other | UniRateError | Service unavailable / generic (carries .status) |

Errors surface through the tool's execute — handle them in your agent loop as you would any tool error.

Security

  • Zero runtime dependencies; ai and zod are peers provided by your app.
  • Native fetch only — no transitive HTTP-client supply-chain surface.
  • API key never leaves the server; tools are designed for server-side agent use.
  • Published to npm with provenance attestation.

Part of the UniRate ecosystem

Official UniRate clients & framework integrations: Python · Node · React · Vue · Nuxt · Next.js · SvelteKit · NestJS · Remix · Angular · Astro · Eleventy · LangChain (Python) · LangChain.js · MCP server

License

MIT © Unirate Team