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

@javaabu/dhivehigpt-sdk

v1.1.0

Published

TypeScript/JavaScript SDK for the DhivehiGPT API

Readme

DhivehiGPT TypeScript SDK

Tests Coverage npm version License: MIT

A lightweight, dependency-free TypeScript/JavaScript SDK for the DhivehiGPT API — voices, text-to-speech, subscription balance, and task pricing.

Works in any modern Node.js server (18+) and in any JavaScript runtime with a global fetch. Ships as both ESM and CommonJS with full TypeScript types, and has zero runtime dependencies.

Installation

npm install @javaabu/dhivehigpt-sdk

You'll need an API key, generated from the API Keys page of your team account. This requires a DhivehiGPT team account with an active subscription, and only team owners and admins can generate API keys.

Quick start

import { DhivehiGPT } from '@javaabu/dhivehigpt-sdk';

// Reads the API key from the DHIVEHIGPT_API_KEY environment variable automatically.
const client = new DhivehiGPT();

// List available voices
const { data: voices } = await client.voices.list({ gender: 'female' });

// Generate a TTS audio
const audio = await client.tts.generate({
  text: 'ދިވެހިޖީޕީޓީއަށް މަރުޙަބާ',
  voice: 'hajja',
});

console.log(audio.audio_url);

CommonJS works the same way:

const { DhivehiGPT } = require('@javaabu/dhivehigpt-sdk');

const client = new DhivehiGPT(); // also reads DHIVEHIGPT_API_KEY

Usage

The client exposes one namespace per API resource:

client.voices.list(params?);        // GET /v1/voices
client.voices.get(slug);            // GET /v1/voices/{slug}

client.tts.list(params?);             // GET /v1/tts
client.tts.generate({ text, voice }); // POST /v1/tts
client.tts.get(uuid);                 // GET /v1/tts/{uuid}
client.tts.update(uuid, { title });   // PUT /v1/tts/{uuid}
client.tts.delete(uuid);              // DELETE /v1/tts/{uuid}

client.subscriptions.getBalance();  // GET /v1/balance

client.tasks.list(params?);              // GET /v1/tasks
client.tasks.get(slug);                  // GET /v1/tasks/{slug}
client.tasks.calculate({ task, units }); // POST /v1/tasks/calculate

Error handling

Every non-2xx response throws a typed error you can catch:

import { AuthenticationError, InsufficientCreditsError, ValidationError } from '@javaabu/dhivehigpt-sdk';

try {
  await client.tts.generate({ text: '...', voice: 'hajja' });
} catch (error) {
  if (error instanceof InsufficientCreditsError) {
    // team is out of credits
  } else if (error instanceof AuthenticationError) {
    // missing, invalid, or revoked API key
  } else if (error instanceof ValidationError) {
    console.log(error.errors); // field-level validation errors
  } else {
    throw error;
  }
}

Client options

new DhivehiGPT({
  apiKey: '...',            // optional if DHIVEHIGPT_API_KEY is set in the environment
  baseUrl: '...',           // defaults to https://api.dhivehigpt.com
  apiVersion: 'v1',         // defaults to "v1"
  timeoutMs: 10_000,        // optional request timeout
  headers: { 'X-Foo': 1 },  // optional extra headers on every request
  fetch: myFetch,           // optional custom fetch implementation
});

Full documentation

The full documentation, including every resource, type, and error, is published at docs.javaabu.com/docs/dhivehigpt-sdk-typescript.

See also the examples directory for runnable sample scripts.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving this package? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.